use of de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent in project spring-boot-admin by codecentric.
the class InfoUpdateTriggerTest method should_not_update_when_stopped.
@Test
public void should_not_update_when_stopped() {
// when registered event is emitted but the trigger has been stopped
this.trigger.stop();
clearInvocations(this.updater);
this.events.next(new InstanceRegisteredEvent(this.instance.getId(), this.instance.getVersion(), this.instance.getRegistration()));
// then should not update
verify(this.updater, never()).updateInfo(this.instance.getId());
}
use of de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent in project spring-boot-admin by codecentric.
the class MicrosoftTeamsNotifierTest method test_onApplicationRegisteredEvent_resolve.
@Test
@SuppressWarnings("unchecked")
void test_onApplicationRegisteredEvent_resolve() {
InstanceRegisteredEvent event = new InstanceRegisteredEvent(instance.getId(), 1L, instance.getRegistration());
StepVerifier.create(notifier.doNotify(event, instance)).verifyComplete();
ArgumentCaptor<HttpEntity<Message>> entity = ArgumentCaptor.forClass(HttpEntity.class);
verify(mockRestTemplate).postForEntity(eq(URI.create("http://example.com")), entity.capture(), eq(Void.class));
assertThat(entity.getValue().getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
assertMessage(entity.getValue().getBody(), notifier.getRegisteredTitle(), notifier.getMessageSummary(), "Test App with id TestAppId has registered with Spring Boot Admin", BLUE);
}
use of de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest method verifyDeserializeWithoutRegistration.
@Test
public void verifyDeserializeWithoutRegistration() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("version", 12345678L).put("timestamp", 1587751031.000000000).put("type", "REGISTERED").toString();
InstanceRegisteredEvent event = objectMapper.readValue(json, InstanceRegisteredEvent.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.getRegistration()).isNull();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest method verifySerializeWithoutRegistration.
@Test
public void verifySerializeWithoutRegistration() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 12345678L, timestamp, null);
JsonContent<InstanceRegisteredEvent> 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("REGISTERED");
assertThat(jsonContent).extractingJsonPathValue("$.registration").isNull();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest 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", "REGISTERED").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();
InstanceRegisteredEvent event = objectMapper.readValue(json, InstanceRegisteredEvent.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