Search in sources :

Example 31 with Registration

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

the class DefaultServiceInstanceConverterTest method should_convert_with_metadata.

@Test
public void should_convert_with_metadata() {
    ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("health.path", "ping");
    metadata.put("management.scheme", "https");
    metadata.put("management.address", "127.0.0.1");
    metadata.put("management.port", "1234");
    metadata.put("management.context-path", "mgmt");
    service.getMetadata().putAll(metadata);
    Registration registration = new DefaultServiceInstanceConverter().convert(service);
    assertThat(registration.getName()).isEqualTo("test");
    assertThat(registration.getServiceUrl()).isEqualTo("http://localhost:80");
    assertThat(registration.getManagementUrl()).isEqualTo("https://127.0.0.1:1234/mgmt");
    assertThat(registration.getHealthUrl()).isEqualTo("https://127.0.0.1:1234/mgmt/ping");
    assertThat(registration.getMetadata()).isEqualTo(metadata);
}
Also used : DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) HashMap(java.util.HashMap) Registration(de.codecentric.boot.admin.server.domain.values.Registration) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Test(org.junit.jupiter.api.Test)

Example 32 with Registration

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

the class DefaultServiceInstanceConverterTest method should_convert_service_with_uri.

@Test
public void should_convert_service_with_uri() {
    ServiceInstance service = new TestServiceInstance("test", URI.create("http://localhost/test"), Collections.emptyMap());
    Registration registration = new DefaultServiceInstanceConverter().convert(service);
    assertThat(registration.getName()).isEqualTo("test");
    assertThat(registration.getServiceUrl()).isEqualTo("http://localhost/test");
    assertThat(registration.getManagementUrl()).isEqualTo("http://localhost/test/actuator");
    assertThat(registration.getHealthUrl()).isEqualTo("http://localhost/test/actuator/health");
    assertThat(registration.getMetadata()).isEmpty();
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Test(org.junit.jupiter.api.Test)

Example 33 with Registration

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

the class DefaultServiceInstanceConverterTest method should_convert_with_defaults.

@Test
public void should_convert_with_defaults() {
    ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
    Registration registration = new DefaultServiceInstanceConverter().convert(service);
    assertThat(registration.getName()).isEqualTo("test");
    assertThat(registration.getServiceUrl()).isEqualTo("http://localhost:80");
    assertThat(registration.getManagementUrl()).isEqualTo("http://localhost:80/actuator");
    assertThat(registration.getHealthUrl()).isEqualTo("http://localhost:80/actuator/health");
}
Also used : DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Test(org.junit.jupiter.api.Test)

Example 34 with Registration

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

the class DefaultServiceInstanceConverterTest method should_convert_service_with_uri_and_custom_defaults.

@Test
public void should_convert_service_with_uri_and_custom_defaults() {
    DefaultServiceInstanceConverter converter = new DefaultServiceInstanceConverter();
    converter.setHealthEndpointPath("ping");
    converter.setManagementContextPath("mgmt");
    ServiceInstance service = new TestServiceInstance("test", URI.create("http://localhost/test"), Collections.emptyMap());
    Registration registration = converter.convert(service);
    assertThat(registration.getName()).isEqualTo("test");
    assertThat(registration.getServiceUrl()).isEqualTo("http://localhost/test");
    assertThat(registration.getManagementUrl()).isEqualTo("http://localhost/test/mgmt");
    assertThat(registration.getHealthUrl()).isEqualTo("http://localhost/test/mgmt/ping");
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Test(org.junit.jupiter.api.Test)

Example 35 with Registration

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

the class DefaultServiceInstanceConverterTest method should_convert_service_with_uri_and_metadata_different_port.

@Test
public void should_convert_service_with_uri_and_metadata_different_port() {
    Map<String, String> metadata = new HashMap<>();
    metadata.put("health.path", "ping");
    metadata.put("management.context-path", "mgmt");
    metadata.put("management.port", "1234");
    metadata.put("management.address", "127.0.0.1");
    ServiceInstance service = new TestServiceInstance("test", URI.create("http://localhost/test"), metadata);
    Registration registration = new DefaultServiceInstanceConverter().convert(service);
    assertThat(registration.getName()).isEqualTo("test");
    assertThat(registration.getServiceUrl()).isEqualTo("http://localhost/test");
    assertThat(registration.getManagementUrl()).isEqualTo("http://127.0.0.1:1234/mgmt");
    assertThat(registration.getHealthUrl()).isEqualTo("http://127.0.0.1:1234/mgmt/ping");
    assertThat(registration.getMetadata()).isEqualTo(metadata);
}
Also used : HashMap(java.util.HashMap) Registration(de.codecentric.boot.admin.server.domain.values.Registration) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Test(org.junit.jupiter.api.Test)

Aggregations

Registration (de.codecentric.boot.admin.server.domain.values.Registration)53 Test (org.junit.jupiter.api.Test)46 Instance (de.codecentric.boot.admin.server.domain.entities.Instance)15 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)12 ServiceInstance (org.springframework.cloud.client.ServiceInstance)9 JSONObject (org.json.JSONObject)8 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)8 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)7 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)6 Info (de.codecentric.boot.admin.server.domain.values.Info)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 StepVerifier (reactor.test.StepVerifier)6 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)5 InstanceRegisteredEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent)5 InstanceRegistrationUpdatedEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegistrationUpdatedEvent)5 Endpoints (de.codecentric.boot.admin.server.domain.values.Endpoints)5 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Collections.singletonMap (java.util.Collections.singletonMap)4 InstanceInfo (com.netflix.appinfo.InstanceInfo)3