Search in sources :

Example 1 with ATTRIBUTE_INSTANCE

use of de.codecentric.boot.admin.server.web.client.InstanceWebClient.ATTRIBUTE_INSTANCE in project spring-boot-admin by codecentric.

the class InstanceWebClientTest method should_add_instance_attribute.

@Test
public void should_add_instance_attribute() {
    Instance instance = Instance.create(InstanceId.of("i"));
    Mono<ClientResponse> response = InstanceWebClient.builder().filter((inst, req, next) -> {
        assertThat(req.attribute(ATTRIBUTE_INSTANCE)).hasValue(instance);
        assertThat(inst).isEqualTo(instance);
        return Mono.just(ClientResponse.create(HttpStatus.OK).build());
    }).build().instance(Mono.just(instance)).get().uri("http://test/health").exchangeToMono(Mono::just);
    StepVerifier.create(response).assertNext((r) -> assertThat(r.statusCode()).isEqualTo(HttpStatus.OK)).verifyComplete();
}
Also used : ClientResponse(org.springframework.web.reactive.function.client.ClientResponse) Test(org.junit.jupiter.api.Test) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) ATTRIBUTE_INSTANCE(de.codecentric.boot.admin.server.web.client.InstanceWebClient.ATTRIBUTE_INSTANCE) HttpStatus(org.springframework.http.HttpStatus) ClientResponse(org.springframework.web.reactive.function.client.ClientResponse) StepVerifier(reactor.test.StepVerifier) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mono(reactor.core.publisher.Mono) ResolveInstanceException(de.codecentric.boot.admin.server.web.client.exception.ResolveInstanceException) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Mono(reactor.core.publisher.Mono) Test(org.junit.jupiter.api.Test)

Aggregations

Instance (de.codecentric.boot.admin.server.domain.entities.Instance)1 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)1 ATTRIBUTE_INSTANCE (de.codecentric.boot.admin.server.web.client.InstanceWebClient.ATTRIBUTE_INSTANCE)1 ResolveInstanceException (de.codecentric.boot.admin.server.web.client.exception.ResolveInstanceException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.jupiter.api.Test)1 HttpStatus (org.springframework.http.HttpStatus)1 ClientResponse (org.springframework.web.reactive.function.client.ClientResponse)1 Mono (reactor.core.publisher.Mono)1 StepVerifier (reactor.test.StepVerifier)1