use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceRegisteredEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
Registration registration = Registration.create("test", "http://localhost:9080/heath").build();
InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 0L, timestamp, registration);
JsonContent<InstanceRegisteredEvent> 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("REGISTERED");
assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl").isEqualTo("http://localhost:9080/heath");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isNull();
assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceStatusChangedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE");
InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(id, 0L, timestamp, statusInfo);
JsonContent<InstanceStatusChangedEvent> 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("STATUS_CHANGED");
assertThat(jsonContent).extractingJsonPathValue("$.statusInfo").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.statusInfo.status").isEqualTo("OFFLINE");
assertThat(jsonContent).extractingJsonPathMapValue("$.statusInfo.details").isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifySerializeWithEmptyInfo.
@Test
public void verifySerializeWithEmptyInfo() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 12345678L, timestamp, Info.from(Collections.emptyMap()));
JsonContent<InstanceInfoChangedEvent> 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("INFO_CHANGED");
assertThat(jsonContent).extractingJsonPathMapValue("$.info").isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceInfoChangedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 0L, timestamp, null);
JsonContent<InstanceInfoChangedEvent> 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("INFO_CHANGED");
assertThat(jsonContent).extractingJsonPathMapValue("$.info").isNull();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceRegistrationUpdatedEventMixinTest method verifySerializeWithOnlyRequiredProperties.
@Test
public void verifySerializeWithOnlyRequiredProperties() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
Registration registration = Registration.create("test", "http://localhost:9080/heath").build();
InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 0L, timestamp, registration);
JsonContent<InstanceRegistrationUpdatedEvent> 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("REGISTRATION_UPDATED");
assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl").isEqualTo("http://localhost:9080/heath");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isNull();
assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").isEmpty();
}
Aggregations