use of de.codecentric.boot.admin.server.domain.values.InstanceId 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.values.InstanceId 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();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceDeregisteredEventMixinTest method verifySerialize.
@Test
public void verifySerialize() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceDeregisteredEvent event = new InstanceDeregisteredEvent(id, 12345678L, timestamp);
JsonContent<InstanceDeregisteredEvent> 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("DEREGISTERED");
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceDeregisteredEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceDeregisteredEvent event = new InstanceDeregisteredEvent(id, 0L, timestamp);
JsonContent<InstanceDeregisteredEvent> 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("DEREGISTERED");
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest method verifySerialize.
@Test
public void verifySerialize() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
Registration registration = Registration.create("test", "http://localhost:9080/heath").managementUrl("http://localhost:9080/").serviceUrl("http://localhost:8080/").source("http-api").metadata("PASSWORD", "qwertz123").metadata("user", "humptydumpty").build();
InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 12345678L, timestamp, registration);
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").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isEqualTo("http://localhost:9080/");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl").isEqualTo("http://localhost:9080/heath");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isEqualTo("http://localhost:8080/");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isEqualTo("http-api");
assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").containsOnly(entry("PASSWORD", "******"), entry("user", "humptydumpty"));
}
Aggregations