Search in sources :

Example 1 with Application

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

the class ApplicationRegistryTest method getApplications_allRegisteredApplications.

@Test
public void getApplications_allRegisteredApplications() {
    Instance instance1 = getInstance("App1");
    Instance instance2 = getInstance("App2");
    when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2));
    StepVerifier.create(this.applicationRegistry.getApplications()).recordWith(ArrayList::new).thenConsumeWhile((a) -> true).consumeRecordedWith((applications) -> assertThat(applications.stream().map(Application::getName)).containsExactlyInAnyOrder("App1", "App2")).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) Application(de.codecentric.boot.admin.server.domain.entities.Application) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Application

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

the class ApplicationRegistryTest method getStatus.

@ParameterizedTest
@CsvSource({ "UP, UP, UP", "DOWN, DOWN, DOWN", "UNKNOWN, UNKNOWN, UNKNOWN", "UP, DOWN, RESTRICTED", "UP, UNKNOWN, RESTRICTED", "UP, OUT_OF_SERVICE, RESTRICTED", "UP, OFFLINE, RESTRICTED", "UP, RESTRICTED, RESTRICTED", "DOWN, UP, RESTRICTED" })
public void getStatus(String instance1Status, String instance2Status, String expectedApplicationStatus) {
    Instance instance1 = getInstance("App1").withStatusInfo(StatusInfo.valueOf(instance1Status));
    Instance instance2 = getInstance("App1").withStatusInfo(StatusInfo.valueOf(instance2Status));
    when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2));
    StepVerifier.create(this.applicationRegistry.getApplications()).recordWith(ArrayList::new).thenConsumeWhile((a) -> true).consumeRecordedWith((applications) -> assertThat(applications.stream().map(Application::getStatus)).containsExactly(expectedApplicationStatus)).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) Application(de.codecentric.boot.admin.server.domain.entities.Application) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Application (de.codecentric.boot.admin.server.domain.entities.Application)2 Instance (de.codecentric.boot.admin.server.domain.entities.Instance)2 BuildVersion (de.codecentric.boot.admin.server.domain.values.BuildVersion)2 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)2 Registration (de.codecentric.boot.admin.server.domain.values.Registration)2 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)2 InstanceEventPublisher (de.codecentric.boot.admin.server.eventstore.InstanceEventPublisher)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 CsvSource (org.junit.jupiter.params.provider.CsvSource)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.verify (org.mockito.Mockito.verify)2 Mockito.when (org.mockito.Mockito.when)2 Flux (reactor.core.publisher.Flux)2