use of de.codecentric.boot.admin.server.domain.events.InstanceRegistrationUpdatedEvent in project spring-boot-admin by codecentric.
the class InstanceRegistrationUpdatedEventMixinTest 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", "REGISTRATION_UPDATED").put("registration", new JSONObject().put("name", "test").put("managementUrl", "http://localhost:9080/").put("healthUrl", "http://localhost:9080/heath").put("serviceUrl", "http://localhost:8080/").put("source", "http-api").put("metadata", new JSONObject().put("PASSWORD", "******").put("user", "humptydumpty"))).toString();
InstanceRegistrationUpdatedEvent event = objectMapper.readValue(json, InstanceRegistrationUpdatedEvent.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));
Registration registration = event.getRegistration();
assertThat(registration).isNotNull();
assertThat(registration.getName()).isEqualTo("test");
assertThat(registration.getManagementUrl()).isEqualTo("http://localhost:9080/");
assertThat(registration.getHealthUrl()).isEqualTo("http://localhost:9080/heath");
assertThat(registration.getServiceUrl()).isEqualTo("http://localhost:8080/");
assertThat(registration.getSource()).isEqualTo("http-api");
assertThat(registration.getMetadata()).containsOnly(entry("PASSWORD", "******"), entry("user", "humptydumpty"));
}
Aggregations