use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_empty_when_mgmt_equals_service_url.
@Test
public void should_return_empty_when_mgmt_equals_service_url() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/app/health")).managementUrl(this.wireMock.url("/app")).serviceUrl(this.wireMock.url("/app")).build());
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when/then
StepVerifier.create(strategy.detectEndpoints(instance)).verifyComplete();
this.wireMock.verify(0, anyRequestedFor(urlPathEqualTo("/app")));
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_empty_on_not_found.
@Test
public void should_return_empty_on_not_found() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
this.wireMock.stubFor(get("/mgmt").willReturn(notFound()));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
StepVerifier.create(strategy.detectEndpoints(instance)).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_endpoints_with_aligned_scheme.
@Test
public void should_return_endpoints_with_aligned_scheme() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
String host = "http://localhost:" + this.wireMock.httpsPort();
String body = "{\"_links\":{\"metrics-requiredMetricName\":{\"templated\":true,\"href\":\"" + host + "/mgmt/metrics/{requiredMetricName}\"},\"self\":{\"templated\":false,\"href\":\"" + host + "/mgmt\"},\"metrics\":{\"templated\":false,\"href\":\"" + host + "/mgmt/stats\"},\"info\":{\"templated\":false,\"href\":\"" + host + "/mgmt/info\"}}}";
this.wireMock.stubFor(get("/mgmt").willReturn(ok(body).withHeader("Content-Type", ActuatorMediaType.V2_JSON)));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
String secureHost = "https://localhost:" + this.wireMock.httpsPort();
StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(Endpoints.single("metrics", secureHost + "/mgmt/stats").withEndpoint("info", //
secureHost + "/mgmt/info")).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_empty_on_wrong_content_type.
@Test
public void should_return_empty_on_wrong_content_type() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
String body = "HELLOW WORLD";
this.wireMock.stubFor(get("/mgmt").willReturn(ok(body).withHeader("Content-Type", MediaType.TEXT_PLAIN_VALUE)));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
StepVerifier.create(strategy.detectEndpoints(instance)).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_empty_on_empty_endpoints.
@Test
public void should_return_empty_on_empty_endpoints() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
String body = "{\"_links\":{}}";
this.wireMock.stubFor(get("/mgmt").willReturn(okJson(body).withHeader("Content-Type", ActuatorMediaType.V2_JSON)));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
StepVerifier.create(strategy.detectEndpoints(instance)).verifyComplete();
}
Aggregations