Search in sources :

Example 1 with GreetingService

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

the class ServiceLocalTest method test_local_async_greeting_return_Message.

@Test
public void test_local_async_greeting_return_Message() {
    // get a proxy to the service api.
    GreetingService service = createProxy(microservices);
    // call the service.
    Mono<GreetingResponse> future = Mono.from(service.greetingRequest(new GreetingRequest("joe")));
    future.doOnNext(result -> {
        assertEquals(" hello to: joe", result.getResult());
        // print the greeting.
        System.out.println("9. local_async_greeting_return_Message :" + result);
    }).doOnError(System.out::println).block(Duration.ofSeconds(1));
}
Also used : 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 2 with GreetingService

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

the class ServiceLocalTest method test_local_bidi_greeting_expect_IllegalArgumentException.

@Test
public void test_local_bidi_greeting_expect_IllegalArgumentException() {
    // get a proxy to the service api.
    GreetingService service = createProxy(microservices);
    // call the service. bidiThrowingGreeting
    Flux<GreetingResponse> responses = service.bidiGreetingIllegalArgumentException(Mono.just(new GreetingRequest("IllegalArgumentException")));
    // call the service.
    StepVerifier.create(responses).expectErrorMessage("IllegalArgumentException").verify(Duration.ofSeconds(3));
}
Also used : 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 3 with GreetingService

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

the class ServiceLocalTest method test_local_greeting_request_timeout_expires.

@Test
public void test_local_greeting_request_timeout_expires() {
    GreetingService service = createProxy(microservices);
    // call the service.
    Throwable exception = assertThrows(RuntimeException.class, () -> Mono.from(service.greetingRequestTimeout(new GreetingRequest("joe", timeout))).timeout(Duration.ofSeconds(1)).block());
    assertTrue(exception.getCause().getMessage().contains("Did not observe any item or terminal signal"));
}
Also used : GreetingRequest(io.scalecube.services.sut.GreetingRequest) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 4 with GreetingService

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

the class ServiceLocalTest method test_local_async_greeting_return_GreetingResponse.

@Test
public void test_local_async_greeting_return_GreetingResponse() {
    // get a proxy to the service api.
    GreetingService service = createProxy(microservices);
    // call the service.
    Mono<GreetingResponse> future = Mono.from(service.greetingRequest(new GreetingRequest("joe")));
    AtomicReference<GreetingResponse> result = new AtomicReference<>();
    future.doOnNext(onNext -> {
        result.set(onNext);
        System.out.println("remote_async_greeting_return_GreetingResponse :" + onNext);
    }).block(Duration.ofSeconds(1));
    assertEquals(" hello to: joe", result.get().getResult());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Sinks(reactor.core.publisher.Sinks) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) GreetingResponse(io.scalecube.services.sut.GreetingResponse) Mono(reactor.core.publisher.Mono) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) FAIL_FAST(reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GreetingService(io.scalecube.services.sut.GreetingService) Duration(java.time.Duration) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) ServiceMessage(io.scalecube.services.api.ServiceMessage) GreetingRequest(io.scalecube.services.sut.GreetingRequest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) GreetingRequest(io.scalecube.services.sut.GreetingRequest) GreetingResponse(io.scalecube.services.sut.GreetingResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Example 5 with GreetingService

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

the class ServiceLocalTest method test_local_async_greeting.

@Test
public void test_local_async_greeting() {
    // get a proxy to the service api.
    GreetingService service = createProxy(microservices);
    // call the service.
    Mono<String> future = Mono.from(service.greeting("joe"));
    future.doOnNext(onNext -> {
        assertEquals(" hello to: joe", onNext);
        // print the greeting.
        System.out.println("3. local_async_greeting :" + onNext);
    }).block(Duration.ofSeconds(1000));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Sinks(reactor.core.publisher.Sinks) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) GreetingResponse(io.scalecube.services.sut.GreetingResponse) Mono(reactor.core.publisher.Mono) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) FAIL_FAST(reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GreetingService(io.scalecube.services.sut.GreetingService) Duration(java.time.Duration) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) ServiceMessage(io.scalecube.services.api.ServiceMessage) GreetingRequest(io.scalecube.services.sut.GreetingRequest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) GreetingService(io.scalecube.services.sut.GreetingService) Test(org.junit.jupiter.api.Test)

Aggregations

GreetingService (io.scalecube.services.sut.GreetingService)39 Test (org.junit.jupiter.api.Test)38 GreetingRequest (io.scalecube.services.sut.GreetingRequest)34 GreetingResponse (io.scalecube.services.sut.GreetingResponse)25 EmptyGreetingRequest (io.scalecube.services.sut.EmptyGreetingRequest)17 ServiceMessage (io.scalecube.services.api.ServiceMessage)15 EmptyGreetingResponse (io.scalecube.services.sut.EmptyGreetingResponse)14 Sinks (reactor.core.publisher.Sinks)11 Duration (java.time.Duration)10 GreetingServiceImpl (io.scalecube.services.sut.GreetingServiceImpl)9 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)9 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)9 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)9 Mono (reactor.core.publisher.Mono)9 StepVerifier (reactor.test.StepVerifier)9 Flux (reactor.core.publisher.Flux)8 FAIL_FAST (reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 AfterEach (org.junit.jupiter.api.AfterEach)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5