Search in sources :

Example 21 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class CloudFoundryHttpHeaderProviderTest method test_no_header.

@Test
public void test_no_header() {
    Registration registration = Registration.create("foo", "http://health").build();
    Instance instance = Instance.create(InstanceId.of("id")).register(registration);
    assertThat(headersProvider.getHeaders(instance)).isEmpty();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 22 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ApplicationRegistryTest method deregister.

@Test
public void deregister() {
    Instance instance1 = getInstance("App1");
    InstanceId instance1Id = instance1.getId();
    when(this.instanceRegistry.getInstances("App1")).thenReturn(Flux.just(instance1));
    when(this.instanceRegistry.deregister(instance1Id)).thenReturn(Mono.just(instance1Id));
    StepVerifier.create(this.applicationRegistry.deregister("App1")).assertNext((instanceId) -> assertThat(instanceId).isEqualTo(instance1Id)).verifyComplete();
    verify(this.instanceRegistry).deregister(instance1Id);
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) CsvSource(org.junit.jupiter.params.provider.CsvSource) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) Application(de.codecentric.boot.admin.server.domain.entities.Application) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) InstanceEventPublisher(de.codecentric.boot.admin.server.eventstore.InstanceEventPublisher) BuildVersion(de.codecentric.boot.admin.server.domain.values.BuildVersion) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ApplicationRegistryTest method getApplications_oneRegisteredAndOneUnregisteredApplication.

@Test
public void getApplications_oneRegisteredAndOneUnregisteredApplication() {
    Instance instance1 = getInstance("App1");
    Instance instance2 = getInstance("App2").deregister();
    when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2));
    StepVerifier.create(this.applicationRegistry.getApplications()).assertNext((app) -> assertThat(app.getName()).isEqualTo("App1")).verifyComplete();
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) CsvSource(org.junit.jupiter.params.provider.CsvSource) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) Application(de.codecentric.boot.admin.server.domain.entities.Application) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) InstanceEventPublisher(de.codecentric.boot.admin.server.eventstore.InstanceEventPublisher) BuildVersion(de.codecentric.boot.admin.server.domain.values.BuildVersion) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ApplicationRegistryTest method getApplication_matchingUnregisteredApplications.

@Test
public void getApplication_matchingUnregisteredApplications() {
    Instance instance = getInstance("App1").deregister();
    when(this.instanceRegistry.getInstances("App1")).thenReturn(Flux.just(instance));
    StepVerifier.create(this.applicationRegistry.getApplication("App1")).verifyComplete();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ApplicationRegistryTest method getBuildVersion.

@Test
public void getBuildVersion() {
    Instance instance1 = getInstance("App1", "0.1");
    Instance instance2 = getInstance("App2", "0.2");
    // Empty list should return null:
    assertThat(this.applicationRegistry.getBuildVersion(Collections.emptyList())).isNull();
    // Single instance should return the version number:
    assertThat(this.applicationRegistry.getBuildVersion(Collections.singletonList(instance1))).isEqualTo(BuildVersion.valueOf("0.1"));
    // Multiple instances should return the version number range:
    assertThat(this.applicationRegistry.getBuildVersion(Arrays.asList(instance1, instance2))).isEqualTo(BuildVersion.valueOf("0.1 ... 0.2"));
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Instance (de.codecentric.boot.admin.server.domain.entities.Instance)44 Test (org.junit.jupiter.api.Test)42 Registration (de.codecentric.boot.admin.server.domain.values.Registration)23 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 StepVerifier (reactor.test.StepVerifier)14 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)13 BeforeEach (org.junit.jupiter.api.BeforeEach)13 Mono (reactor.core.publisher.Mono)10 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)9 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)8 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)8 Flux (reactor.core.publisher.Flux)8 ArrayList (java.util.ArrayList)7 Collections.singletonMap (java.util.Collections.singletonMap)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Application (de.codecentric.boot.admin.server.domain.entities.Application)6 Info (de.codecentric.boot.admin.server.domain.values.Info)6 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)6 Mockito.mock (org.mockito.Mockito.mock)6