JRestlessHandlerContainer implements Container { @Nonnull protected ContainerRequest createContainerRequest(@Nonnull RequestT request, @Nonnull ContainerResponseWriter containerResponseWriter, @Nonnull SecurityContext securityContext) { requireNonNull(request, "request may not be null"); URI baseUri = request.getBaseUri(); URI requestUri = requireNonNull(request.getRequestUri(), "request.getRequestUri() may not be null"); String httpMethod = requireNonNull(request.getHttpMethod(), "request.getHttpMethod() may not be null"); InputStream entityStream = requireNonNull(request.getEntityStream(), "request.getEntityStream() may not be null"); Map<String, List<String>> headers = requireNonNull(request.getHeaders(), "request.getHeaderParams() may not be null"); requireNonNull(containerResponseWriter, "containerResponseWriter may not be null"); requireNonNull(securityContext, "securityContext may not be null"); ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, httpMethod, securityContext, new MapPropertiesDelegate()); requestContext.setEntityStream(entityStream); requestContext.getHeaders().putAll(headers); requestContext.setWriter(containerResponseWriter); return requestContext; } JRestlessHandlerContainer(@Nonnull Application application);  JRestlessHandlerContainer(@Nonnull Application application, @Nullable Binder binder);  JRestlessHandlerContainer(@Nonnull Application application, @Nullable Binder customBinder,
			@Nullable Object parentManager); protected  JRestlessHandlerContainer(@Nonnull ApplicationHandler applicationHandler); void handleRequest(@Nonnull RequestT request, @Nonnull JRestlessResponseWriter responseWriter,
			@Nonnull SecurityContext securityContext); void handleRequest(@Nonnull RequestT request, @Nonnull JRestlessResponseWriter responseWriter,
			@Nonnull SecurityContext securityContext, @Nonnull Consumer<ContainerRequest> containerRequestEnhancer); @Override ResourceConfig getConfiguration(); @Override ApplicationHandler getApplicationHandler(); @Override void reload(); @Override void reload(ResourceConfig configuration); void onStartup(); void onShutdown();  }
@Test public void createContainerRequest_NoRequestGiven_ShouldThrowNpe() { assertThrows(NullPointerException.class, () -> container.createContainerRequest(null, mock(ContainerResponseWriter.class), mock(SecurityContext.class))); }
@Test public void createContainerRequest_NoContainerResponseWriterGiven_ShouldThrowNpe() { assertThrows(NullPointerException.class, () -> container.createContainerRequest(createAnyRequest(), null, mock(SecurityContext.class))); }
@Test public void createContainerRequest_NoSecurityContext_ShouldThrowNpe() { assertThrows(NullPointerException.class, () -> container.createContainerRequest(createAnyRequest(), mock(ContainerResponseWriter.class), null)); }
@Test public void createContainerRequest_NoRequestRequestUriGiven_ShouldThrowNpe() { JRestlessContainerRequest request = createAnyRequest(); when(request.getRequestUri()).thenReturn(null); assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class))); }
@Test public void createContainerRequest_NoRequestHttpMethodGiven_ShouldThrowNpe() { JRestlessContainerRequest request = createAnyRequest(); when(request.getHttpMethod()).thenReturn(null); assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class))); }
@Test public void createContainerRequest_NoRequestEntityStreamGiven_ShouldThrowNpe() { JRestlessContainerRequest request = createAnyRequest(); when(request.getEntityStream()).thenReturn(null); assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class))); }
@Test public void createContainerRequest_NoRequestHeadersGiven_ShouldThrowNpe() { JRestlessContainerRequest request = createAnyRequest(); when(request.getHeaders()).thenReturn(null); assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class))); }
@Test public void createContainerRequest_RequestAndContainerResponseWriterAndSecurityContextGiven_ShouldCreateContainerRequestUsingValues() { URI baseUri = URI.create("/"); URI requestUri = URI.create("/entity"); String httpMethod = "POST"; ByteArrayInputStream entityStream = new ByteArrayInputStream(new byte[0]); MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.add("hk0", "hv0_0"); headers.add("hk0", "hv0_1"); headers.add("hk1", "hv1_0"); JRestlessContainerRequest request = createRequest(baseUri, requestUri, httpMethod, entityStream, headers); ContainerResponseWriter containerResponseWriter = mock(ContainerResponseWriter.class); SecurityContext securityContext = mock(SecurityContext.class); ContainerRequest containerRequest = container.createContainerRequest(request, containerResponseWriter, securityContext); assertEquals(baseUri, containerRequest.getBaseUri()); assertEquals(requestUri, containerRequest.getRequestUri()); assertEquals(httpMethod, containerRequest.getMethod()); assertSame(entityStream, containerRequest.getEntityStream()); assertEquals(headers, containerRequest.getHeaders()); assertSame(containerResponseWriter, containerRequest.getResponseWriter()); assertSame(securityContext, containerRequest.getSecurityContext()); }