use of de.codecentric.boot.admin.server.domain.values.StatusInfo in project spring-boot-admin by codecentric.
the class InstanceStatusChangedEventMixinTest method verifyDeserializeWithOnlyRequiredProperties.
@Test
public void verifyDeserializeWithOnlyRequiredProperties() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("timestamp", 1587751031.000000000).put("type", "STATUS_CHANGED").put("statusInfo", new JSONObject().put("status", "OFFLINE")).toString();
InstanceStatusChangedEvent event = objectMapper.readValue(json, InstanceStatusChangedEvent.class);
assertThat(event).isNotNull();
assertThat(event.getInstance()).isEqualTo(InstanceId.of("test123"));
assertThat(event.getVersion()).isEqualTo(0L);
assertThat(event.getTimestamp()).isEqualTo(Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS));
StatusInfo statusInfo = event.getStatusInfo();
assertThat(statusInfo).isNotNull();
assertThat(statusInfo.getStatus()).isEqualTo("OFFLINE");
assertThat(statusInfo.getDetails()).isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.StatusInfo 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();
}
use of de.codecentric.boot.admin.server.domain.values.StatusInfo in project spring-boot-admin by codecentric.
the class StatusInfoMixinTest method verifySerialize.
@Test
public void verifySerialize() throws IOException {
StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE", Collections.singletonMap("foo", "bar"));
JsonContent<StatusInfo> jsonContent = jsonTester.write(statusInfo);
assertThat(jsonContent).extractingJsonPathStringValue("$.status").isEqualTo("OFFLINE");
assertThat(jsonContent).extractingJsonPathMapValue("$.details").containsOnly(entry("foo", "bar"));
assertThat(jsonContent).doesNotHaveJsonPath("$.up");
assertThat(jsonContent).doesNotHaveJsonPath("$.offline");
assertThat(jsonContent).doesNotHaveJsonPath("$.down");
assertThat(jsonContent).doesNotHaveJsonPath("$.unknown");
}
Aggregations