Add smoke test for InfoContributor

See gh-39544
This commit is contained in:
gdmrw 2024-02-14 03:30:03 -08:00 committed by Moritz Halbritter
parent 0f341f4cb0
commit 3befeb2d7e

View File

@ -177,6 +177,18 @@ class SampleActuatorApplicationTests {
assertThat(entity.getBody()).contains(entry("legacy", "legacy"));
}
@Test
@SuppressWarnings("unchecked")
void testInfo() {
ResponseEntity<Map<String, Object>> entity = asMapEntity(
this.restTemplate.withBasicAuth("user", "password").getForEntity("/actuator/info", Map.class));
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).containsKey("build");
Map<String, Object> body = entity.getBody();
Map<String, Object> example = (Map<String, Object>) body.get("example");
assertThat(example).containsEntry("someKey", "someValue");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
static <K, V> ResponseEntity<Map<K, V>> asMapEntity(ResponseEntity<Map> entity) {
return (ResponseEntity) entity;