use of com.canoo.dp.impl.platform.core.http.HttpStatus.SC_HTTP_UNAUTHORIZED in project dolphin-platform by canoo.
the class HttpClientTests method testBadResponse.
@Test
public void testBadResponse() throws Exception {
// given:
final HttpClient client = PlatformClient.getService(HttpClient.class);
final AtomicBoolean actionCalled = new AtomicBoolean(false);
final AtomicBoolean doneCalled = new AtomicBoolean(false);
final AtomicBoolean errorCalled = new AtomicBoolean(false);
// when:
final CompletableFuture<HttpResponse<Void>> future = client.get("http://localhost:" + freePort + "/error").withoutContent().withoutResult().onDone(response -> {
actionCalled.set(true);
doneCalled.set(true);
}).onError(e -> {
actionCalled.set(true);
errorCalled.set(true);
}).execute();
// then:
assertThatBadResponseException(doneCalled, errorCalled, future, SC_HTTP_UNAUTHORIZED);
assertThatErrorCalledAndDoneNotCalled(actionCalled, doneCalled, errorCalled);
}
Aggregations