|
27 | 27 |
|
28 | 28 | import java.time.Duration; |
29 | 29 | import java.util.Optional; |
| 30 | +import java.util.Set; |
30 | 31 | import java.util.Spliterator; |
31 | 32 | import java.util.Spliterators; |
32 | 33 | import java.util.concurrent.Callable; |
33 | 34 | import java.util.concurrent.ExecutionException; |
34 | 35 | import java.util.stream.Stream; |
35 | 36 | import java.util.stream.StreamSupport; |
36 | 37 |
|
37 | | -import static org.hamcrest.CoreMatchers.is; |
38 | 38 | import static org.hamcrest.MatcherAssert.assertThat; |
39 | 39 | import static org.junit.Assert.assertEquals; |
40 | 40 | import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; |
@@ -86,19 +86,22 @@ public void actuatorGrpcTest() throws ExecutionException, InterruptedException { |
86 | 86 |
|
87 | 87 | @Test |
88 | 88 | public void actuatorHealthTest() throws ExecutionException, InterruptedException { |
89 | | - ResponseEntity<String> response = restTemplate.getForEntity("/actuator/health", String.class); |
| 89 | + ResponseEntity<String> response = restTemplate.getForEntity("/actuator/health/grpc", String.class); |
90 | 90 | assertEquals(HttpStatus.OK, response.getStatusCode()); |
91 | 91 |
|
92 | 92 | final DocumentContext json = JsonPath.parse(response.getBody(), Configuration.builder() |
93 | 93 | .mappingProvider(new JacksonMappingProvider()) |
94 | 94 | .jsonProvider(new JacksonJsonProvider()) |
95 | 95 | .build()); |
96 | | - final String[] statuses = json.read("components.grpc.components.*status", new TypeRef<String[]>() { |
97 | | - }); |
98 | | - assertThat(statuses,Matchers.arrayWithSize(Matchers.greaterThan(0))); |
99 | | - for(String s:statuses) { |
100 | | - assertThat(s, is(Status.UP.getCode())); |
101 | | - } |
| 96 | + final TypeRef<Set<String>> setOfString = new TypeRef<Set<String>>() { |
| 97 | + }; |
| 98 | + final Set<String> services = json.read("components.keys()", setOfString); |
| 99 | + assertThat(services,Matchers.containsInAnyOrder( super.appServicesNames().toArray(new String[]{}))); |
| 100 | + |
| 101 | + final Set<String> statuses = json.read("components.*status", setOfString); |
| 102 | + assertThat(statuses,Matchers.contains(Status.UP.getCode())); |
| 103 | + |
| 104 | + |
102 | 105 |
|
103 | 106 | } |
104 | 107 |
|
|
0 commit comments