Search in sources :

Example 11 with Info

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

the class InstanceInfoChangedEventMixinTest 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", "INFO_CHANGED").put("info", new JSONObject().put("build", new JSONObject().put("version", "1.0.0")).put("foo", "bar")).toString();
    InstanceInfoChangedEvent event = objectMapper.readValue(json, InstanceInfoChangedEvent.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));
    Info info = event.getInfo();
    assertThat(info).isNotNull();
    assertThat(info.getValues()).containsOnly(entry("build", Collections.singletonMap("version", "1.0.0")), entry("foo", "bar"));
}
Also used : JSONObject(org.json.JSONObject) InstanceInfoChangedEvent(de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent) Info(de.codecentric.boot.admin.server.domain.values.Info) Test(org.junit.jupiter.api.Test)

Aggregations

Info (de.codecentric.boot.admin.server.domain.values.Info)11 Test (org.junit.jupiter.api.Test)10 InstanceInfoChangedEvent (de.codecentric.boot.admin.server.domain.events.InstanceInfoChangedEvent)7 Registration (de.codecentric.boot.admin.server.domain.values.Registration)7 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)7 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)5 Instance (de.codecentric.boot.admin.server.domain.entities.Instance)5 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)5 Endpoints (de.codecentric.boot.admin.server.domain.values.Endpoints)5 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)5 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)5 Collections.singletonMap (java.util.Collections.singletonMap)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 StepVerifier (reactor.test.StepVerifier)5 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)4 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)4 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)4 WireMock.okJson (com.github.tomakehurst.wiremock.client.WireMock.okJson)4 WireMock.serverError (com.github.tomakehurst.wiremock.client.WireMock.serverError)4