Java Code Examples for de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent#getStatusInfo()
The following examples show how to use
de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent#getStatusInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstanceStatusChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifyDeserialize() throws JSONException, JsonProcessingException { String json = new JSONObject().put("instance", "test123").put("version", 12345678L) .put("timestamp", 1587751031.000000000).put("type", "STATUS_CHANGED") .put("statusInfo", new JSONObject().put("status", "OFFLINE").put("details", new JSONObject().put("foo", "bar"))) .toString(); InstanceStatusChangedEvent event = objectMapper.readValue(json, InstanceStatusChangedEvent.class); assertThat(event).isNotNull(); assertThat(event.getInstance()).isEqualTo(InstanceId.of("test123")); assertThat(event.getVersion()).isEqualTo(12345678L); 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()).containsOnly(entry("foo", "bar")); }
Example 2
Source File: InstanceStatusChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@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(); }