use of com.tvd12.ezyhttp.client.concurrent.RequestFutureTask in project ezyhttp by youngmonkeys.
the class HttpClientProxy method execute.
public void execute(Request request, RequestCallback<ResponseEntity> callback) {
EzyFuture future = new RequestFutureTask(callback);
futures.addFuture(request, future);
try {
addRequest(request);
} catch (Exception e) {
futures.removeFuture(request);
throw e;
}
}
use of com.tvd12.ezyhttp.client.concurrent.RequestFutureTask in project ezyhttp by youngmonkeys.
the class RequestFutureTaskTest method setResultNotNull.
@Test
public void setResultNotNull() throws Exception {
// given
RequestFutureTask sut = new RequestFutureTask();
Object result = new Object();
// when
sut.setResult(result);
// then
Asserts.assertEquals(result, sut.get());
}
use of com.tvd12.ezyhttp.client.concurrent.RequestFutureTask in project ezyhttp by youngmonkeys.
the class RequestFutureTaskTest method setExceptionNull.
@Test
public void setExceptionNull() {
// given
RequestFutureTask sut = new RequestFutureTask();
// when
Throwable e = Asserts.assertThrows(() -> sut.setException(null));
// then
Asserts.assertThat(e).isEqualsType(NullPointerException.class);
}
use of com.tvd12.ezyhttp.client.concurrent.RequestFutureTask in project ezyhttp by youngmonkeys.
the class RequestFutureTaskTest method setResultNull.
@Test
public void setResultNull() {
// given
RequestFutureTask sut = new RequestFutureTask();
// when
Throwable e = Asserts.assertThrows(() -> sut.setResult(null));
// then
Asserts.assertThat(e).isEqualsType(NullPointerException.class);
}
use of com.tvd12.ezyhttp.client.concurrent.RequestFutureTask in project ezyhttp by youngmonkeys.
the class RequestFutureTaskTest method setExceptionNotNull.
@Test
public void setExceptionNotNull() {
// given
RequestFutureTask sut = new RequestFutureTask();
Exception exception = new Exception("just test");
// when
sut.setException(exception);
// then
Throwable e = Asserts.assertThrows(sut::get);
Asserts.assertThat(e).isEqualsTo(exception);
}
Aggregations