SimpleRequestHandler { public final ResponseT delegateRequest(@Nonnull RequestT request) { ResponseT containerResponse; JRestlessContainerRequest containerRequest = null; try { checkState(started, "handler has not been started"); requireNonNull(request); containerRequest = createContainerRequest(request); JRestlessContainerRequest containerRequestFinal = containerRequest; beforeHandleRequest(request, containerRequest); SimpleResponseWriter<ResponseT> responseWriter = createResponseWriter(request); container.handleRequest(containerRequest, responseWriter, createSecurityContext(request, containerRequest), cReq -> extendActualJerseyContainerRequest(cReq, containerRequestFinal, request)); containerResponse = responseWriter.getResponse(); containerResponse = onRequestSuccess(containerResponse, request, containerRequest); } catch (Exception e) { containerResponse = onRequestFailure(e, request, containerRequest); } return containerResponse; }  final void init(@Nonnull Application application); final void init(@Nonnull Application application, @Nullable Object parentManager); final void init(@Nonnull JRestlessHandlerContainer<JRestlessContainerRequest> handlerContainer); final void start(); final void stop(); final ResponseT delegateRequest(@Nonnull RequestT request);  }
@Test public void delegateRequest_NotStarted_ShouldReturnInternalServerError() { SimpleContainerResponse response = new SimpleRequestHandlerImpl().delegateRequest(mock(JRestlessContainerRequest.class)); assertEquals(500, response.getStatusType().getStatusCode()); assertTrue(response.getHeaders().isEmpty()); assertEquals(null, response.getBody()); }