use of de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent in project spring-boot-admin by codecentric.
the class InfoUpdateTriggerTest method should_update_on_endpoints_detectes_event.
@Test
public void should_update_on_endpoints_detectes_event() {
// when registered event is emitted
this.events.next(new InstanceEndpointsDetectedEvent(this.instance.getId(), this.instance.getVersion(), this.instance.getEndpoints()));
// then should update
verify(this.updater, times(1)).updateInfo(this.instance.getId());
}
use of de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent in project spring-boot-admin by codecentric.
the class InstanceEndpointsDetectedEventMixinTest 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", "ENDPOINTS_DETECTED").put("endpoints", new JSONArray().put(new JSONObject().put("id", "info").put("url", "http://localhost:8080/info")).put(new JSONObject().put("id", "health").put("url", "http://localhost:8080/health"))).toString();
InstanceEndpointsDetectedEvent event = objectMapper.readValue(json, InstanceEndpointsDetectedEvent.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));
assertThat(event.getEndpoints()).containsExactlyInAnyOrder(Endpoint.of("info", "http://localhost:8080/info"), Endpoint.of("health", "http://localhost:8080/health"));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent in project spring-boot-admin by codecentric.
the class InstanceEndpointsDetectedEventMixinTest method verifySerialize.
@Test
public void verifySerialize() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
Endpoints endpoints = Endpoints.single("info", "http://localhost:8080/info").withEndpoint("health", "http://localhost:8080/health");
InstanceEndpointsDetectedEvent event = new InstanceEndpointsDetectedEvent(id, 12345678L, timestamp, endpoints);
JsonContent<InstanceEndpointsDetectedEvent> 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("ENDPOINTS_DETECTED");
assertThat(jsonContent).extractingJsonPathArrayValue("$.endpoints").hasSize(2);
assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[0].id").isIn("info", "health");
assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[0].url").isIn("http://localhost:8080/info", "http://localhost:8080/health");
assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[1].id").isIn("info", "health");
assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[1].url").isIn("http://localhost:8080/info", "http://localhost:8080/health");
}
use of de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent in project spring-boot-admin by codecentric.
the class InstanceEndpointsDetectedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceEndpointsDetectedEvent event = new InstanceEndpointsDetectedEvent(id, 0L, timestamp, null);
JsonContent<InstanceEndpointsDetectedEvent> 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("ENDPOINTS_DETECTED");
assertThat(jsonContent).extractingJsonPathArrayValue("$.endpoints").isNull();
}
Aggregations