use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class StreamingServiceTest method test_just_one_message.
@Test
public void test_just_one_message() {
ServiceCall service = gateway.call();
ServiceMessage justOne = ServiceMessage.builder().qualifier(QuoteService.NAME, "justOne").build();
ServiceMessage message = service.requestOne(justOne, String.class).timeout(Duration.ofSeconds(3)).block();
assertNotNull(message);
assertEquals("1", message.<String>data());
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceRemoteTest method test_remote_bidi_greeting_message_expect_NotAuthorized.
@Test
public void test_remote_bidi_greeting_message_expect_NotAuthorized() {
// get a proxy to the service api.
GreetingService service = createProxy();
Sinks.Many<GreetingRequest> requests = Sinks.many().multicast().directBestEffort();
// call the service.
Flux<GreetingResponse> responses = service.bidiGreetingNotAuthorizedMessage(requests.asFlux().onBackpressureBuffer().map(request -> ServiceMessage.builder().data(request).build())).map(ServiceMessage::data);
StepVerifier.create(responses).then(() -> requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST)).expectErrorMessage("Not authorized").verify(Duration.ofSeconds(3));
}
use of io.scalecube.services.api.ServiceMessage 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));
}
use of io.scalecube.services.api.ServiceMessage 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());
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceCallRemoteTest method test_remote_async_greeting_no_params.
@Test
public void test_remote_async_greeting_no_params() {
ServiceCall serviceCall = gateway.call();
// call the service.
Publisher<ServiceMessage> future = serviceCall.requestOne(GREETING_NO_PARAMS_REQUEST, GreetingResponse.class);
ServiceMessage message = Mono.from(future).block(TIMEOUT);
assertEquals("hello unknown", ((GreetingResponse) message.data()).getResult());
}
Aggregations