9
9
10
10
import java .io .IOException ;
11
11
import java .net .URISyntaxException ;
12
+ import java .util .HashMap ;
12
13
13
14
import static com .github .tomakehurst .wiremock .client .WireMock .*;
14
15
import static org .hamcrest .MatcherAssert .assertThat ;
21
22
*/
22
23
final class EndpointServiceTest extends WireMockBaseTestCase {
23
24
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 ()};
24
61
25
62
@ Test
26
63
void search () throws URISyntaxException , IOException {
@@ -36,49 +73,29 @@ void search() throws URISyntaxException, IOException {
36
73
37
74
assertAll (
38
75
() -> 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 ))
76
77
);
77
78
}
78
79
79
80
@ 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
+ );
82
99
}
83
100
84
101
@ Test
0 commit comments