Search in sources :

Example 6 with UnknownRemoteException

use of com.palantir.conjure.java.api.errors.UnknownRemoteException in project dialogue by palantir.

the class MyServiceIntegrationTest method testGetGreetingAsyncUnknownRemoteException.

@Test
public void testGetGreetingAsyncUnknownRemoteException() {
    String errorBody = "Error";
    undertowHandler = exchange -> {
        exchange.assertMethod(HttpMethod.GET);
        exchange.assertPath("/greeting");
        exchange.assertAccept().isEqualTo("text/csv");
        exchange.assertContentType().isNull();
        exchange.assertNoBody();
        exchange.exchange.setStatusCode(500);
        exchange.setContentType("text/plain");
        exchange.writeStringBody(errorBody);
    };
    assertThatThrownBy(() -> myServiceDialogue.getGreetingAsync().get()).isExactlyInstanceOf(ExecutionException.class).hasCauseExactlyInstanceOf(UnknownRemoteException.class).satisfies(executionException -> assertThat(((UnknownRemoteException) executionException.getCause()).getBody()).isEqualTo(errorBody));
}
Also used : UnknownRemoteException(com.palantir.conjure.java.api.errors.UnknownRemoteException) HttpString(io.undertow.util.HttpString) Test(org.junit.jupiter.api.Test)

Aggregations

UnknownRemoteException (com.palantir.conjure.java.api.errors.UnknownRemoteException)6 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 RemoteException (com.palantir.conjure.java.api.errors.RemoteException)2 SafeIoException (com.palantir.logsafe.exceptions.SafeIoException)2 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 Call (okhttp3.Call)2 Callback (okhttp3.Callback)2 Response (okhttp3.Response)2 Test (org.junit.jupiter.api.Test)2 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)1 LocalPaxosServices (com.palantir.atlasdb.factory.Leaders.LocalPaxosServices)1 QosException (com.palantir.conjure.java.api.errors.QosException)1 PingableLeader (com.palantir.leader.PingableLeader)1 LeadershipCoordinator (com.palantir.leader.proxy.LeadershipCoordinator)1 LockService (com.palantir.lock.LockService)1 NamespaceAgnosticLockRpcClient (com.palantir.lock.NamespaceAgnosticLockRpcClient)1 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)1 RemoteLockServiceAdapter (com.palantir.lock.client.RemoteLockServiceAdapter)1 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)1