-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenApiOperationServiceTest.java
More file actions
69 lines (54 loc) · 1.75 KB
/
OpenApiOperationServiceTest.java
File metadata and controls
69 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.apiflows.service;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class OpenApiOperationServiceTest {
private OpenApiOperationService service = new OpenApiOperationService();
@Test
void isUrlWithHttps() {
assertTrue(service.isUrl("https://example.com/spec.yaml"));
}
@Test
void isUrlWithHttp() {
assertTrue(service.isUrl("http://example.com/spec.yaml"));
}
@Test
void isUrlWithRelativePath() {
assertFalse(service.isUrl("./pet-coupons.openapi.yaml"));
}
@Test
void isUrlNull() {
assertFalse(service.isUrl(null));
}
@Test
void extractExampleByName() {
assertEquals("MyExample", service.extractExampleByName("#/components/examples/MyExample"));
}
@Test
void extractExampleByNameSimplePath() {
assertEquals("petExample", service.extractExampleByName("/components/examples/petExample"));
}
@Test
void getRootFolderNull() {
assertEquals(".", service.getRootFolder(null));
}
@Test
void getRootFolderFromUrl() {
String root = service.getRootFolder("https://example.com/api/spec.yaml");
assertEquals("https://example.com/api/", root);
}
@Test
void getRootFolderFromAbsolutePath() {
String root = service.getRootFolder("/Users/beppe/project/spec.yaml");
assertEquals("/Users/beppe/project", root);
}
@Test
void getRootFolderFromRelativePath() {
String root = service.getRootFolder("src/test/resources/pet-coupons.arazzo.yaml");
assertEquals("src/test/resources", root);
}
@Test
void getRootFolderNoParent() {
String root = service.getRootFolder("spec.yaml");
assertNull(root);
}
}