99
1010import java .io .IOException ;
1111import java .net .URISyntaxException ;
12+ import java .util .HashMap ;
1213
1314import static com .github .tomakehurst .wiremock .client .WireMock .*;
1415import static org .hamcrest .MatcherAssert .assertThat ;
2122 */
2223final class EndpointServiceTest extends WireMockBaseTestCase {
2324 private final EndpointService sut = new EndpointService (conf ());
25+ private final Endpoint [] expectedFromSearch = new Endpoint []{
26+ Endpoint .builder ()
27+ .id (956 )
28+ .protocol ("tcp" )
29+ .host ("10.0.0.1" )
30+ .port (80 )
31+ .product (320 )
32+ .build (),
33+ Endpoint .builder ()
34+ .id (957 )
35+ .protocol ("tcp" )
36+ .host ("10.0.0.1" )
37+ .port (443 )
38+ .product (320 )
39+ .build (),
40+ Endpoint .builder ()
41+ .id (961 )
42+ .protocol ("tcp" )
43+ .host ("10.0.0.2" )
44+ .port (80 )
45+ .product (323 )
46+ .build (),
47+ Endpoint .builder ()
48+ .id (962 )
49+ .protocol ("tcp" )
50+ .host ("10.0.0.2" )
51+ .port (443 )
52+ .product (323 )
53+ .build (),
54+ Endpoint .builder ()
55+ .id (893 )
56+ .protocol ("tcp" )
57+ .host ("10.0.0.3" )
58+ .port (443 )
59+ .product (296 )
60+ .build ()};
2461
2562 @ Test
2663 void search () throws URISyntaxException , IOException {
@@ -36,49 +73,29 @@ void search() throws URISyntaxException, IOException {
3673
3774 assertAll (
3875 () -> assertThat (result , hasSize (5 )),
39- () -> assertThat (result , containsInAnyOrder (
40- Endpoint .builder ()
41- .id (956 )
42- .protocol ("tcp" )
43- .host ("10.0.0.1" )
44- .port (80 )
45- .product (320 )
46- .build (),
47- Endpoint .builder ()
48- .id (957 )
49- .protocol ("tcp" )
50- .host ("10.0.0.1" )
51- .port (443 )
52- .product (320 )
53- .build (),
54- Endpoint .builder ()
55- .id (961 )
56- .protocol ("tcp" )
57- .host ("10.0.0.2" )
58- .port (80 )
59- .product (323 )
60- .build (),
61- Endpoint .builder ()
62- .id (962 )
63- .protocol ("tcp" )
64- .host ("10.0.0.2" )
65- .port (443 )
66- .product (323 )
67- .build (),
68- Endpoint .builder ()
69- .id (893 )
70- .protocol ("tcp" )
71- .host ("10.0.0.3" )
72- .port (443 )
73- .product (296 )
74- .build ()
75- ))
76+ () -> assertThat (result , containsInAnyOrder (expectedFromSearch ))
7677 );
7778 }
7879
7980 @ Test
80- @ Disabled ("TODO: Implement test." )
81- void search_withQueryParams () {
81+ void search_withQueryParams () throws URISyntaxException , IOException {
82+ stubFor (
83+ get ("/api/v2/endpoints/?limit=100&bar=42&offset=0&foo=23" )
84+ .willReturn (
85+ ok ()
86+ .withBody (readFixtureFile ("EndpointService_response_fixture.json" ))
87+ )
88+ );
89+ final var params = new HashMap <String , Object >();
90+ params .put ("foo" , 23 );
91+ params .put ("bar" , 42 );
92+
93+ final var result = sut .search (params );
94+
95+ assertAll (
96+ () -> assertThat (result , hasSize (5 )),
97+ () -> assertThat (result , containsInAnyOrder (expectedFromSearch ))
98+ );
8299 }
83100
84101 @ Test
0 commit comments