|
1 | 1 | package io.securecodebox.persistence.defectdojo.service;
|
2 | 2 |
|
| 3 | +import io.securecodebox.persistence.defectdojo.model.TestType; |
3 | 4 | import org.junit.jupiter.api.Test;
|
4 | 5 |
|
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.*; |
6 | 10 | 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; |
8 | 14 |
|
9 | 15 | /**
|
10 | 16 | * Tests for {@link TestTypeService}
|
11 | 17 | */
|
12 |
| -final class TestTypeServiceTest extends WireMockBaseTestCase{ |
| 18 | +final class TestTypeServiceTest extends WireMockBaseTestCase { |
13 | 19 | private final TestTypeService sut = new TestTypeService(conf());
|
| 20 | + |
| 21 | + @Test |
| 22 | + void search() throws URISyntaxException, IOException { |
| 23 | + stubFor( |
| 24 | + get("/api/v2/test_types/?offset=0&limit=100") |
| 25 | + .willReturn( |
| 26 | + ok() |
| 27 | + .withBody(readResponseBodyFromFixture("TestTypeService_response_fixture.json")) |
| 28 | + ) |
| 29 | + ); |
| 30 | + |
| 31 | + final var result = sut.search(); |
| 32 | + |
| 33 | + assertAll( |
| 34 | + () -> assertThat(result, hasSize(9)), |
| 35 | + () -> assertThat(result, containsInAnyOrder( |
| 36 | + TestType.builder() |
| 37 | + .id(99) |
| 38 | + .name("Acunetix360 Scan") |
| 39 | + .staticTool(false) |
| 40 | + .dynamicTool(false) |
| 41 | + .build(), |
| 42 | + TestType.builder() |
| 43 | + .id(19) |
| 44 | + .name("Acunetix Scan") |
| 45 | + .staticTool(false) |
| 46 | + .dynamicTool(false) |
| 47 | + .build(), |
| 48 | + TestType.builder() |
| 49 | + .id(125) |
| 50 | + .name("AnchoreCTL Policies Report") |
| 51 | + .staticTool(false) |
| 52 | + .dynamicTool(false) |
| 53 | + .build(), |
| 54 | + TestType.builder() |
| 55 | + .id(47) |
| 56 | + .name("AnchoreCTL Vuln Report") |
| 57 | + .staticTool(false) |
| 58 | + .dynamicTool(false) |
| 59 | + .build(), |
| 60 | + TestType.builder() |
| 61 | + .id(112) |
| 62 | + .name("Anchore Engine Scan") |
| 63 | + .staticTool(false) |
| 64 | + .dynamicTool(false) |
| 65 | + .build(), |
| 66 | + TestType.builder() |
| 67 | + .id(172) |
| 68 | + .name("Anchore Enterprise Policy Check") |
| 69 | + .staticTool(false) |
| 70 | + .dynamicTool(false) |
| 71 | + .build(), |
| 72 | + TestType.builder() |
| 73 | + .id(106) |
| 74 | + .name("Anchore Grype") |
| 75 | + .staticTool(true) |
| 76 | + .dynamicTool(false) |
| 77 | + .build(), |
| 78 | + TestType.builder() |
| 79 | + .id(1) |
| 80 | + .name("API Test") |
| 81 | + .staticTool(false) |
| 82 | + .dynamicTool(false) |
| 83 | + .build(), |
| 84 | + TestType.builder() |
| 85 | + .id(100) |
| 86 | + .name("AppSpider Scan") |
| 87 | + .staticTool(false) |
| 88 | + .dynamicTool(true) |
| 89 | + .build() |
| 90 | + )) |
| 91 | + ); |
| 92 | + } |
14 | 93 | }
|
0 commit comments