Search in sources :

Example 21 with GreetingResponse

use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.

the class ServiceLocalTest method test_local_bidi_greeting_message_expect_IllegalArgumentException.

@Test
public void test_local_bidi_greeting_message_expect_IllegalArgumentException() {
    // get a proxy to the service api.
    GreetingService service = createProxy(microservices);
    // call the service. bidiThrowingGreeting
    Flux<GreetingResponse> responses = service.bidiGreetingIllegalArgumentExceptionMessage(Mono.just(ServiceMessage.builder().data(new GreetingRequest("IllegalArgumentException")).build())).map(ServiceMessage::data);
    // call the service.
    StepVerifier.create(responses).expectErrorMessage("IllegalArgumentException").verify(Duration.ofSeconds(3));
}
Also used : ServiceMessage(io.scalecube.services.api.ServiceMessage) GreetingRequest(io.scalecube.services.sut.GreetingRequest) GreetingResponse(io.scalecube.services.sut.GreetingResponse) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 22 with GreetingResponse

use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.

the class ServiceRemoteTest method test_remote_bidi_greeting_expect_NotAuthorized.

@Test
public void test_remote_bidi_greeting_expect_NotAuthorized() {
    // get a proxy to the service api.
    GreetingService service = createProxy();
    Sinks.Many<GreetingRequest> requests = Sinks.many().multicast().onBackpressureBuffer();
    // call the service.
    Flux<GreetingResponse> responses = service.bidiGreetingNotAuthorized(requests.asFlux().onBackpressureBuffer());
    // call the service.
    requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
    requests.emitComplete(FAIL_FAST);
    StepVerifier.create(responses).expectErrorMessage("Not authorized").verify(Duration.ofSeconds(3));
}
Also used : Sinks(reactor.core.publisher.Sinks) GreetingRequest(io.scalecube.services.sut.GreetingRequest) EmptyGreetingRequest(io.scalecube.services.sut.EmptyGreetingRequest) GreetingResponse(io.scalecube.services.sut.GreetingResponse) EmptyGreetingResponse(io.scalecube.services.sut.EmptyGreetingResponse) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 23 with GreetingResponse

use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.

the class ServiceRemoteTest method test_remote_async_greeting_return_Message.

@Test
public void test_remote_async_greeting_return_Message() {
    // get a proxy to the service api.
    GreetingService service = createProxy();
    // call the service.
    Publisher<GreetingResponse> future = service.greetingRequest(new GreetingRequest("joe"));
    assertEquals(" hello to: joe", Mono.from(future).block(Duration.ofSeconds(1)).getResult());
}
Also used : GreetingRequest(io.scalecube.services.sut.GreetingRequest) EmptyGreetingRequest(io.scalecube.services.sut.EmptyGreetingRequest) GreetingResponse(io.scalecube.services.sut.GreetingResponse) EmptyGreetingResponse(io.scalecube.services.sut.EmptyGreetingResponse) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 24 with GreetingResponse

use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.

the class ServiceRemoteTest method test_remote_greeting_return_GreetingResponse.

@Test
public void test_remote_greeting_return_GreetingResponse() {
    // get a proxy to the service api.
    GreetingService service = createProxy();
    // call the service.
    Publisher<GreetingResponse> future = service.greetingRequest(new GreetingRequest("joe"));
    assertEquals(" hello to: joe", Mono.from(future).block(Duration.ofSeconds(10000)).getResult());
}
Also used : GreetingRequest(io.scalecube.services.sut.GreetingRequest) EmptyGreetingRequest(io.scalecube.services.sut.EmptyGreetingRequest) GreetingResponse(io.scalecube.services.sut.GreetingResponse) EmptyGreetingResponse(io.scalecube.services.sut.EmptyGreetingResponse) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 25 with GreetingResponse

use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.

the class ServiceCallRemoteTest method test_remote_dispatcher_remote_greeting_request_completes_before_timeout.

@Test
public void test_remote_dispatcher_remote_greeting_request_completes_before_timeout() {
    Publisher<ServiceMessage> result = gateway.call().requestOne(GREETING_REQUEST_REQ, GreetingResponse.class);
    GreetingResponse greetings = Mono.from(result).block(TIMEOUT).data();
    System.out.println("greeting_request_completes_before_timeout : " + greetings.getResult());
    assertEquals(" hello to: joe", greetings.getResult());
}
Also used : ServiceMessage(io.scalecube.services.api.ServiceMessage) GreetingResponse(io.scalecube.services.sut.GreetingResponse) EmptyGreetingResponse(io.scalecube.services.sut.EmptyGreetingResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GreetingResponse (io.scalecube.services.sut.GreetingResponse)28 Test (org.junit.jupiter.api.Test)28 GreetingRequest (io.scalecube.services.sut.GreetingRequest)23 GreetingService (io.scalecube.services.sut.GreetingService)22 ServiceMessage (io.scalecube.services.api.ServiceMessage)15 EmptyGreetingResponse (io.scalecube.services.sut.EmptyGreetingResponse)14 EmptyGreetingRequest (io.scalecube.services.sut.EmptyGreetingRequest)11 Sinks (reactor.core.publisher.Sinks)10 Duration (java.time.Duration)7 GreetingServiceImpl (io.scalecube.services.sut.GreetingServiceImpl)6 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)6 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)6 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)6 Flux (reactor.core.publisher.Flux)6 Mono (reactor.core.publisher.Mono)6 FAIL_FAST (reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST)6 StepVerifier (reactor.test.StepVerifier)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 AfterEach (org.junit.jupiter.api.AfterEach)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4