Skip to content

Commit cd24fb5

Browse files
committedMar 15, 2024
Capture & Replay Integration Test for ToolTypeService
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 2a921ab commit cd24fb5

File tree

3 files changed

+101
-3
lines changed

3 files changed

+101
-3
lines changed
 

‎src/main/java/io/securecodebox/persistence/defectdojo/service/ToolTypeService.java

+3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212

1313
public class ToolTypeService extends GenericDefectDojoService<ToolType> {
1414

15+
@Deprecated(forRemoval = true) // Unused
1516
public static final String GIT_SERVER_NAME = "Git Server";
17+
@Deprecated(forRemoval = true) // Unused
1618
public static final String BUILD_SERVER_NAME = "Build Server";
19+
@Deprecated(forRemoval = true) // Unused
1720
public static final String SECURITY_TEST_SERVER_NAME = "Security Test Orchestration Engine";
1821

1922
public ToolTypeService(Config config) {
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
11
package io.securecodebox.persistence.defectdojo.service;
22

3+
import io.securecodebox.persistence.defectdojo.model.ToolType;
34
import org.junit.jupiter.api.Test;
45

5-
import static org.junit.jupiter.api.Assertions.*;
6+
import java.io.IOException;
7+
import java.net.URISyntaxException;
8+
9+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
610
import static org.hamcrest.MatcherAssert.assertThat;
7-
import static org.hamcrest.Matchers.*;
11+
import static org.hamcrest.Matchers.containsInAnyOrder;
12+
import static org.hamcrest.Matchers.hasSize;
13+
import static org.junit.jupiter.api.Assertions.assertAll;
814

915
/**
1016
* Tests for {@link ToolTypeService}
1117
*/
1218
final class ToolTypeServiceTest extends WireMockBaseTestCase {
1319
private final ToolTypeService sut = new ToolTypeService(conf());
20+
21+
@Test
22+
void search() throws URISyntaxException, IOException {
23+
stubFor(
24+
get("/api/v2/tool_types/?offset=0&limit=100")
25+
.willReturn(
26+
ok()
27+
.withBody(readResponseBodyFromFixture("ToolTypeService_response_fixture.json"))
28+
)
29+
);
30+
31+
final var result = sut.search();
32+
33+
assertAll(
34+
() -> assertThat(result, hasSize(7)),
35+
() -> assertThat(result, containsInAnyOrder(
36+
ToolType.builder()
37+
.id(6)
38+
.name("BlackDuck API")
39+
.build(),
40+
ToolType.builder()
41+
.id(3)
42+
.name("Bugcrowd API")
43+
.build(),
44+
ToolType.builder()
45+
.id(4)
46+
.name("Cobalt.io")
47+
.build(),
48+
ToolType.builder()
49+
.id(1)
50+
.name("Edgescan")
51+
.build(),
52+
ToolType.builder()
53+
.id(7)
54+
.name("Security Test Orchestration Engine")
55+
.description("Security Test Orchestration Engine")
56+
.build(),
57+
ToolType.builder()
58+
.id(5)
59+
.name("SonarQube")
60+
.build(),
61+
ToolType.builder()
62+
.id(2)
63+
.name("Vulners")
64+
.build()
65+
))
66+
);
67+
}
1468
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
{}
1+
{
2+
"count": 7,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 6,
8+
"name": "BlackDuck API",
9+
"description": null
10+
},
11+
{
12+
"id": 3,
13+
"name": "Bugcrowd API",
14+
"description": null
15+
},
16+
{
17+
"id": 4,
18+
"name": "Cobalt.io",
19+
"description": null
20+
},
21+
{
22+
"id": 1,
23+
"name": "Edgescan",
24+
"description": null
25+
},
26+
{
27+
"id": 7,
28+
"name": "Security Test Orchestration Engine",
29+
"description": "Security Test Orchestration Engine"
30+
},
31+
{
32+
"id": 5,
33+
"name": "SonarQube",
34+
"description": null
35+
},
36+
{
37+
"id": 2,
38+
"name": "Vulners",
39+
"description": null
40+
}
41+
]
42+
}

0 commit comments

Comments
 (0)
Please sign in to comment.