use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class InstanceStatusChangedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE");
InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(id, 0L, timestamp, statusInfo);
JsonContent<InstanceStatusChangedEvent> jsonContent = jsonTester.write(event);
assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123");
assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0);
assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000);
assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("STATUS_CHANGED");
assertThat(jsonContent).extractingJsonPathValue("$.statusInfo").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.statusInfo.status").isEqualTo("OFFLINE");
assertThat(jsonContent).extractingJsonPathMapValue("$.statusInfo.details").isEmpty();
}
Aggregations