Search in sources :

Example 21 with InstanceId

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");
}
Also used : Endpoints(de.codecentric.boot.admin.server.domain.values.Endpoints) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instant(java.time.Instant) InstanceEndpointsDetectedEvent(de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent) Test(org.junit.jupiter.api.Test)

Example 22 with InstanceId

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();
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instant(java.time.Instant) InstanceEndpointsDetectedEvent(de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent) Test(org.junit.jupiter.api.Test)

Example 23 with InstanceId

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");
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instant(java.time.Instant) InstanceDeregisteredEvent(de.codecentric.boot.admin.server.domain.events.InstanceDeregisteredEvent) Test(org.junit.jupiter.api.Test)

Example 24 with InstanceId

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");
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instant(java.time.Instant) InstanceDeregisteredEvent(de.codecentric.boot.admin.server.domain.events.InstanceDeregisteredEvent) Test(org.junit.jupiter.api.Test)

Example 25 with InstanceId

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"));
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Registration(de.codecentric.boot.admin.server.domain.values.Registration) InstanceRegisteredEvent(de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)32 Test (org.junit.jupiter.api.Test)28 Instant (java.time.Instant)18 Registration (de.codecentric.boot.admin.server.domain.values.Registration)13 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 StepVerifier (reactor.test.StepVerifier)7 Instance (de.codecentric.boot.admin.server.domain.entities.Instance)6 ArrayList (java.util.ArrayList)6 Mono (reactor.core.publisher.Mono)6 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Flux (reactor.core.publisher.Flux)5 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)4 InstanceRegisteredEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent)4 InstanceStatusChangedEvent (de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent)4 Info (de.codecentric.boot.admin.server.domain.values.Info)4 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)4 Collections.singletonMap (java.util.Collections.singletonMap)4 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)4