use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class RegistrationDeserializerTest method test_1_5_json_format.
@Test
public void test_1_5_json_format() throws Exception {
String json = new JSONObject().put("name", "test").put("managementUrl", "http://test").put("healthUrl", "http://health").put("serviceUrl", "http://service").put("metadata", new JSONObject().put("labels", "foo,bar")).toString();
Registration value = objectMapper.readValue(json, Registration.class);
assertThat(value.getName()).isEqualTo("test");
assertThat(value.getManagementUrl()).isEqualTo("http://test");
assertThat(value.getHealthUrl()).isEqualTo("http://health");
assertThat(value.getServiceUrl()).isEqualTo("http://service");
assertThat(value.getMetadata()).isEqualTo(singletonMap("labels", "foo,bar"));
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class RegistrationDeserializerTest method test_onlyHealthUrl.
@Test
public void test_onlyHealthUrl() throws Exception {
String json = new JSONObject().put("name", "test").put("healthUrl", "http://test").toString();
Registration value = objectMapper.readValue(json, Registration.class);
assertThat(value.getName()).isEqualTo("test");
assertThat(value.getHealthUrl()).isEqualTo("http://test");
assertThat(value.getManagementUrl()).isNull();
assertThat(value.getServiceUrl()).isNull();
}
use of de.codecentric.boot.admin.server.domain.values.Registration 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"));
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest method verifyDeserializeWithOnlyRequiredProperties.
@Test
public void verifyDeserializeWithOnlyRequiredProperties() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("timestamp", 1587751031.000000000).put("type", "REGISTERED").put("registration", new JSONObject().put("name", "test").put("healthUrl", "http://localhost:9080/heath")).toString();
InstanceRegisteredEvent event = objectMapper.readValue(json, InstanceRegisteredEvent.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));
Registration registration = event.getRegistration();
assertThat(registration).isNotNull();
assertThat(registration.getName()).isEqualTo("test");
assertThat(registration.getManagementUrl()).isNull();
assertThat(registration.getHealthUrl()).isEqualTo("http://localhost:9080/heath");
assertThat(registration.getServiceUrl()).isNull();
assertThat(registration.getSource()).isNull();
assertThat(registration.getMetadata()).isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceRegistryTest method refresh.
@Test
public void refresh() {
// Given instance is already reegistered and has status and info.
StatusInfo status = StatusInfo.ofUp();
Info info = Info.from(singletonMap("foo", "bar"));
Registration registration = Registration.create("abc", "http://localhost:8080/health").build();
InstanceId id = idGenerator.generateId(registration);
Instance app = Instance.create(id).register(registration).withStatusInfo(status).withInfo(info);
StepVerifier.create(repository.save(app)).expectNextCount(1).verifyComplete();
// When instance registers second time
InstanceId refreshId = registry.register(Registration.create("abc", "http://localhost:8080/health").build()).block();
assertThat(refreshId).isEqualTo(id);
StepVerifier.create(registry.getInstance(id)).assertNext((registered) -> {
// Then info and status are retained
assertThat(registered.getInfo()).isEqualTo(info);
assertThat(registered.getStatusInfo()).isEqualTo(status);
}).verifyComplete();
}
Aggregations