Merge pull request #39544 from gdmrw

* pr/39544:
  Add smoke test for InfoContributor

Closes gh-39544
This commit is contained in:
Moritz Halbritter 2024-02-16 09:20:17 +01:00
commit 8b2a7e8a19

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;