### Question:
ResumableAsyncHandler implements AsyncHandler<Response> { @Override public State onHeadersReceived(HttpHeaders headers) throws Exception { responseBuilder.accumulate(headers); String contentLengthHeader = headers.get(CONTENT_LENGTH); if (contentLengthHeader != null) { if (Long.parseLong(contentLengthHeader) == -1L) { return AsyncHandler.State.ABORT; } } if (decoratedAsyncHandler != null) { return decoratedAsyncHandler.onHeadersReceived(headers); } return State.CONTINUE; } private  ResumableAsyncHandler(long byteTransferred, ResumableProcessor resumableProcessor,
                                AsyncHandler<Response> decoratedAsyncHandler, boolean accumulateBody);  ResumableAsyncHandler(long byteTransferred);  ResumableAsyncHandler(boolean accumulateBody);  ResumableAsyncHandler();  ResumableAsyncHandler(AsyncHandler<Response> decoratedAsyncHandler);  ResumableAsyncHandler(long byteTransferred, AsyncHandler<Response> decoratedAsyncHandler);  ResumableAsyncHandler(ResumableProcessor resumableProcessor);  ResumableAsyncHandler(ResumableProcessor resumableProcessor, boolean accumulateBody); @Override State onStatusReceived(final HttpResponseStatus status); @Override void onThrowable(Throwable t); @Override State onBodyPartReceived(HttpResponseBodyPart bodyPart); @Override Response onCompleted(); @Override State onHeadersReceived(HttpHeaders headers); @Override State onTrailingHeadersReceived(HttpHeaders headers); Request adjustRequestRange(Request request); ResumableAsyncHandler setResumableListener(ResumableListener resumableListener);  }### Answer:
@Test public void testOnHeadersReceived() throws Exception { ResumableAsyncHandler handler = new ResumableAsyncHandler(); HttpHeaders responseHeaders = new DefaultHttpHeaders(); State status = handler.onHeadersReceived(responseHeaders); assertEquals(status, AsyncHandler.State.CONTINUE, "State should be CONTINUE for a successful onHeadersReceived"); }
@Test public void testOnHeadersReceivedWithDecoratedAsyncHandler() throws Exception { HttpHeaders responseHeaders = new DefaultHttpHeaders(); @SuppressWarnings("unchecked") AsyncHandler<Response> decoratedAsyncHandler = mock(AsyncHandler.class); when(decoratedAsyncHandler.onHeadersReceived(responseHeaders)).thenReturn(State.CONTINUE); ResumableAsyncHandler handler = new ResumableAsyncHandler(decoratedAsyncHandler); State status = handler.onHeadersReceived(responseHeaders); assertEquals(status, State.CONTINUE, "State should be equal to the state returned from decoratedAsyncHandler"); }
@Test public void testOnHeadersReceivedContentLengthMinus() throws Exception { ResumableAsyncHandler handler = new ResumableAsyncHandler(); HttpHeaders responseHeaders = new DefaultHttpHeaders(); responseHeaders.add(CONTENT_LENGTH, -1); State status = handler.onHeadersReceived(responseHeaders); assertEquals(status, AsyncHandler.State.ABORT, "State should be ABORT for content length -1"); }