use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceCallLocalTest method test_local_async_greeting_return_Message.
@Test
public void test_local_async_greeting_return_Message() {
ServiceMessage result = provider.call().requestOne(GREETING_REQUEST_REQ).block(timeout);
// print the greeting.
GreetingResponse responseData = result.data();
System.out.println("local_async_greeting_return_Message :" + responseData);
assertEquals(" hello to: joe", responseData.getResult());
}
use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class RoutersTest method test_tag_request_selection_logic.
@Test
public void test_tag_request_selection_logic() {
ServiceCall service = gateway.call().router((reg, msg) -> reg.listServiceReferences().stream().filter(ref -> ((GreetingRequest) msg.data()).getName().equals(ref.tags().get("ONLYFOR"))).findFirst());
// call the service.
for (int i = 0; i < 1e2; i++) {
GreetingResponse resultForFransin = service.requestOne(GREETING_REQUEST_REQ2, GreetingResponse.class).block(TIMEOUT).data();
GreetingResponse resultForJoe = service.requestOne(GREETING_REQUEST_REQ, GreetingResponse.class).block(TIMEOUT).data();
assertEquals("1", resultForJoe.sender());
assertEquals("2", resultForFransin.sender());
}
}
use of io.scalecube.services.sut.GreetingResponse 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.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceLocalTest method test_local_greeting_request_completes_before_timeout.
@Test
public void test_local_greeting_request_completes_before_timeout() {
GreetingService service = microservices.call().api(GreetingService.class);
// call the service.
GreetingResponse result = service.greetingRequestTimeout(new GreetingRequest("joe", timeout)).block(timeout.plusSeconds(1));
// print the greeting.
System.out.println("2. greeting_request_completes_before_timeout : " + result.getResult());
assertEquals(" hello to: joe", result.getResult());
}
use of io.scalecube.services.sut.GreetingResponse in project scalecube by scalecube.
the class ServiceLocalTest method test_local_no_params.
@Test
public void test_local_no_params() {
// get a proxy to the service api.
GreetingService service = createProxy(microservices);
// call the service.
Mono<String> future = Mono.from(service.greetingNoParams());
AtomicReference<String> greetingResponse = new AtomicReference<>();
future.doOnNext((onNext) -> {
// print the greeting.
System.out.println("test_local_async_no_params :" + onNext);
greetingResponse.set(onNext);
}).block(Duration.ofSeconds(1));
assertEquals("hello unknown", greetingResponse.get());
}
Aggregations