Search in sources :

Example 6 with Endpoints

use of de.codecentric.boot.admin.server.domain.values.Endpoints 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 7 with Endpoints

use of de.codecentric.boot.admin.server.domain.values.Endpoints in project spring-boot-admin by codecentric.

the class EndpointsMixinTest method verifySerialize.

@Test
public void verifySerialize() throws IOException {
    Endpoints endpoints = Endpoints.single("info", "http://localhost:8080/info").withEndpoint("health", "http://localhost:8080/health");
    JsonContent<Endpoints> jsonContent = jsonTester.write(endpoints);
    assertThat(jsonContent).extractingJsonPathArrayValue("$").hasSize(2);
    assertThat(jsonContent).extractingJsonPathStringValue("$[0].id").isIn("info", "health");
    assertThat(jsonContent).extractingJsonPathStringValue("$[0].url").isIn("http://localhost:8080/info", "http://localhost:8080/health");
    assertThat(jsonContent).extractingJsonPathStringValue("$[1].id").isIn("info", "health");
    assertThat(jsonContent).extractingJsonPathStringValue("$[1].url").isIn("http://localhost:8080/info", "http://localhost:8080/health");
}
Also used : Endpoints(de.codecentric.boot.admin.server.domain.values.Endpoints) Test(org.junit.jupiter.api.Test)

Aggregations

Endpoints (de.codecentric.boot.admin.server.domain.values.Endpoints)7 Test (org.junit.jupiter.api.Test)5 InstanceEndpointsDetectedEvent (de.codecentric.boot.admin.server.domain.events.InstanceEndpointsDetectedEvent)3 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)3 Registration (de.codecentric.boot.admin.server.domain.values.Registration)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 AssertionFailedError (org.opentest4j.AssertionFailedError)2 Mono (reactor.core.publisher.Mono)2 StepVerifier (reactor.test.StepVerifier)2 InstanceDeregisteredEvent (de.codecentric.boot.admin.server.domain.events.InstanceDeregisteredEvent)1 InstanceEvent (de.codecentric.boot.admin.server.domain.events.InstanceEvent)1 InstanceInfoChangedEvent (de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent)1 InstanceRegisteredEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent)1 InstanceRegistrationUpdatedEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegistrationUpdatedEvent)1 InstanceStatusChangedEvent (de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent)1 Info (de.codecentric.boot.admin.server.domain.values.Info)1 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)1 Instant (java.time.Instant)1 JSONArray (org.json.JSONArray)1