use of com.palantir.dialogue.example.AliasOfOptional in project dialogue by palantir.
the class IntegrationTest method alias_of_optional.
@Test
public void alias_of_optional() {
set204Response();
AliasOfOptional myAlias = blocking.getMyAlias();
Optional<String> maybeString = myAlias.get();
assertThat(maybeString).isNotPresent();
}
use of com.palantir.dialogue.example.AliasOfOptional in project dialogue by palantir.
the class IntegrationTest method when_thread_is_interrupted_no_requests_are_made.
@Test
public void when_thread_is_interrupted_no_requests_are_made() {
AtomicInteger served = new AtomicInteger();
undertowHandler = exchange -> {
served.getAndIncrement();
exchange.setStatusCode(204);
};
Thread.currentThread().interrupt();
assertThatThrownBy(blocking::getMyAlias).satisfies(throwable -> assertThat(throwable.getClass().getSimpleName()).isEqualTo("DialogueException")).hasCauseInstanceOf(InterruptedException.class);
ListenableFuture<AliasOfOptional> future = async.getMyAlias();
assertThat(future).isDone();
assertThat(future).isNotCancelled();
assertThatThrownBy(future::get).isInstanceOf(InterruptedException.class);
assertThat(served).hasValue(0);
}
use of com.palantir.dialogue.example.AliasOfOptional in project dialogue by palantir.
the class IntegrationTest method testClosedConnectionIsRetried.
@Test
public void testClosedConnectionIsRetried() {
AtomicInteger requests = new AtomicInteger();
undertowHandler = exchange -> {
if (requests.getAndIncrement() == 0) {
exchange.getConnection().close();
} else {
exchange.setStatusCode(204);
}
};
AliasOfOptional myAlias = blocking.getMyAlias();
Optional<String> maybeString = myAlias.get();
assertThat(maybeString).isNotPresent();
assertThat(requests).hasValue(2);
}
Aggregations