Search in sources :

Example 31 with InstanceId

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

the class InstanceRegistrationUpdatedEventMixinTest method verifySerializeWithoutRegistration.

@Test
public void verifySerializeWithoutRegistration() throws IOException {
    InstanceId id = InstanceId.of("test123");
    Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
    InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 12345678L, timestamp, null);
    JsonContent<InstanceRegistrationUpdatedEvent> 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("REGISTRATION_UPDATED");
    assertThat(jsonContent).extractingJsonPathMapValue("$.registration").isNull();
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instant(java.time.Instant) InstanceRegistrationUpdatedEvent(de.codecentric.boot.admin.server.domain.events.InstanceRegistrationUpdatedEvent) Test(org.junit.jupiter.api.Test)

Example 32 with InstanceId

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

the class JdkPerInstanceCookieStoreTest method different_handler_should_be_used_for_different_instance_id.

@Test
void different_handler_should_be_used_for_different_instance_id() throws IOException {
    InstanceId INSTANCE_ID2 = InstanceId.of("j");
    CookieHandler cookieHandler2 = mock(CookieHandler.class);
    when(store.createCookieHandler(INSTANCE_ID2)).thenReturn(cookieHandler2);
    MultiValueMap<String, String> storeMap = new LinkedMultiValueMap<>();
    final URI uri = URI.create("http://localhost/test");
    store.get(INSTANCE_ID, uri, storeMap);
    store.get(INSTANCE_ID2, uri, storeMap);
    verify(cookieHandler).get(uri, storeMap);
    verify(cookieHandler2).get(uri, storeMap);
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) URI(java.net.URI) CookieHandler(java.net.CookieHandler) 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