use of de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifySerializeWithEmptyInfo.
@Test
public void verifySerializeWithEmptyInfo() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 12345678L, timestamp, Info.from(Collections.emptyMap()));
JsonContent<InstanceInfoChangedEvent> jsonContent = jsonTester.write(event);
assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123");
assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678);
assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000);
assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("INFO_CHANGED");
assertThat(jsonContent).extractingJsonPathMapValue("$.info").isEmpty();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifyDeserializeWithOnlyRequiredProperties.
@Test
public void verifyDeserializeWithOnlyRequiredProperties() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("timestamp", 1587751031.000000000).put("type", "INFO_CHANGED").toString();
InstanceInfoChangedEvent event = objectMapper.readValue(json, InstanceInfoChangedEvent.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));
assertThat(event.getInfo()).isNull();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 0L, timestamp, null);
JsonContent<InstanceInfoChangedEvent> 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("INFO_CHANGED");
assertThat(jsonContent).extractingJsonPathMapValue("$.info").isNull();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifyDeserialize.
@Test
public void verifyDeserialize() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("version", 12345678L).put("timestamp", 1587751031.000000000).put("type", "INFO_CHANGED").put("info", new JSONObject().put("build", new JSONObject().put("version", "1.0.0")).put("foo", "bar")).toString();
InstanceInfoChangedEvent event = objectMapper.readValue(json, InstanceInfoChangedEvent.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));
Info info = event.getInfo();
assertThat(info).isNotNull();
assertThat(info.getValues()).containsOnly(entry("build", Collections.singletonMap("version", "1.0.0")), entry("foo", "bar"));
}
Aggregations