use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceCallLocalTest method test_local_async_greeting_return_GreetingResponse.
@Test
public void test_local_async_greeting_return_GreetingResponse() {
// When
Publisher<ServiceMessage> resultFuture = provider.call().requestOne(GREETING_REQUEST_REQ);
// Then
ServiceMessage result = Mono.from(resultFuture).block(Duration.ofSeconds(TIMEOUT));
assertNotNull(result);
assertEquals(GREETING_REQUEST_REQ.qualifier(), result.qualifier());
assertEquals(" hello to: joe", ((GreetingResponse) result.data()).getResult());
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceLocalTest method test_local_bidi_greeting_expect_message_GreetingResponse.
@Test
public void test_local_bidi_greeting_expect_message_GreetingResponse() {
// get a proxy to the service api.
GreetingService service = createProxy(microservices);
Sinks.Many<GreetingRequest> requests = Sinks.many().unicast().onBackpressureBuffer();
// call the service.
Flux<GreetingResponse> responses = service.bidiGreetingMessage(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)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-1")).then(() -> requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-2")).then(() -> requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-3")).then(() -> requests.emitComplete(FAIL_FAST)).expectComplete().verify(Duration.ofSeconds(3));
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceRemoteTest method test_remote_bidi_greeting_message_expect_IllegalArgumentException.
@Test
public void test_remote_bidi_greeting_message_expect_IllegalArgumentException() {
// get a proxy to the service api.
GreetingService service = createProxy();
// 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 ServiceRemoteTest method test_remote_bidi_greeting_message_expect_GreetingResponse.
@Test
public void test_remote_bidi_greeting_message_expect_GreetingResponse() {
// get a proxy to the service api.
GreetingService service = createProxy();
Sinks.Many<GreetingRequest> requests = Sinks.many().unicast().onBackpressureBuffer();
// call the service.
Flux<GreetingResponse> responses = service.bidiGreetingMessage(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)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-1")).then(() -> requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-2")).then(() -> requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST)).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-3")).then(() -> requests.emitComplete(FAIL_FAST)).expectComplete().verify(Duration.ofSeconds(3));
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceCallRemoteTest method test_service_address_lookup_occur_only_after_subscription.
@Test
public void test_service_address_lookup_occur_only_after_subscription() {
Flux<ServiceMessage> quotes = gateway.call().requestMany(ServiceMessage.builder().qualifier(QuoteService.NAME, "onlyOneAndThenNever").data(null).build());
// Add service to cluster AFTER creating a call object.
// (prove address lookup occur only after subscription)
Microservices quotesService = serviceProvider(new SimpleQuoteService());
StepVerifier.create(quotes.take(1)).expectNextCount(1).expectComplete().verify(TIMEOUT);
try {
quotesService.shutdown();
} catch (Exception ignored) {
// no-op
}
}
Aggregations