use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceCallRemoteTest method test_remote_async_greeting_return_GreetingResponse.
@Test
public void test_remote_async_greeting_return_GreetingResponse() {
// When
Publisher<ServiceMessage> result = gateway.call().requestOne(GREETING_REQUEST_REQ, GreetingResponse.class);
// Then
GreetingResponse greeting = Mono.from(result).block(TIMEOUT).data();
assertEquals(" hello to: joe", greeting.getResult());
}
use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceLocalTest method test_local_greeting_message.
@Test
void test_local_greeting_message() {
GreetingService service = createProxy(microservices);
ServiceMessage request = ServiceMessage.builder().data(new GreetingRequest("joe")).build();
// using proxy
StepVerifier.create(service.greetingMessage(request)).assertNext(message -> {
assertEquals(GreetingResponse.class, message.data().getClass());
GreetingResponse resp = message.data();
assertEquals("1", resp.sender());
assertEquals("hello to: joe", resp.getResult());
}).expectComplete().verify(timeout);
StepVerifier.create(service.greetingMessage2(request)).assertNext(resp -> {
assertEquals("1", resp.sender());
assertEquals("hello to: joe", resp.getResult());
}).expectComplete().verify(timeout);
// using serviceCall directly
ServiceCall serviceCall = microservices.call();
StepVerifier.create(serviceCall.requestOne(ServiceMessage.from(request).qualifier("v1/greetings/greetingMessage").build(), GreetingResponse.class)).assertNext(message -> {
assertEquals(GreetingResponse.class, message.data().getClass());
GreetingResponse resp = message.data();
assertEquals("1", resp.sender());
assertEquals("hello to: joe", resp.getResult());
}).expectComplete().verify(timeout);
StepVerifier.create(serviceCall.requestOne(ServiceMessage.from(request).qualifier("v1/greetings/greetingMessage2").build(), GreetingResponse.class)).assertNext(message -> {
assertEquals(GreetingResponse.class, message.data().getClass());
GreetingResponse resp = message.data();
assertEquals("1", resp.sender());
assertEquals("hello to: joe", resp.getResult());
}).expectComplete().verify(timeout);
}
use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceLocalTest method test_local_bidi_greeting_expect_GreetingResponse.
@Test
public void test_local_bidi_greeting_expect_GreetingResponse() {
// get a proxy to the service api.
GreetingService service = createProxy(microservices);
Sinks.Many<GreetingRequest> requests = Sinks.many().multicast().onBackpressureBuffer();
// call the service.
requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST);
requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST);
requests.emitComplete(FAIL_FAST);
// call the service.
Flux<GreetingResponse> responses = service.bidiGreeting(requests.asFlux().onBackpressureBuffer());
StepVerifier.create(responses).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-1")).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-2")).expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-3")).expectComplete().verify(Duration.ofSeconds(3));
}
Aggregations