DefaultJRestlessContainerRequest implements JRestlessContainerRequest { @Override public Map<String, List<String>> getHeaders() { return headers; } DefaultJRestlessContainerRequest(@Nonnull RequestAndBaseUri requestAndBaseUri, @Nonnull String httpMethod,
			@Nonnull InputStream entityStream, @Nonnull Map<String, List<String>> headers);  DefaultJRestlessContainerRequest(@Nullable URI baseUri, @Nonnull URI requestUri, @Nonnull String httpMethod,
			@Nonnull InputStream entityStream, @Nonnull Map<String, List<String>> headers); @Override URI getBaseUri(); @Override URI getRequestUri(); @Override String getHttpMethod(); @Override InputStream getEntityStream(); @Override Map<String, List<String>> getHeaders(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString();  }
@Test public void testHeadersNotSame() throws IOException { Map<String, List<String>> headers = ImmutableMap.of("a", ImmutableList.of("a0", "a1")); JRestlessContainerRequest request = new DefaultJRestlessContainerRequest(URI.create("/123"), URI.create("/456"), "DELETE", new ByteArrayInputStream("123".getBytes()), headers); assertNotSame(headers, request.getHeaders()); }
@Test public void testHeadersCopied() throws IOException { Map<String, List<String>> headers = new HashMap<>(); JRestlessContainerRequest request = new DefaultJRestlessContainerRequest(URI.create("/123"), URI.create("/456"), "DELETE", new ByteArrayInputStream("123".getBytes()), headers); headers.put("0", ImmutableList.of("0")); assertTrue(request.getHeaders().isEmpty()); }
@Test public void testHeadersImmutable() throws IOException { JRestlessContainerRequest request = new DefaultJRestlessContainerRequest(URI.create("/123"), URI.create("/456"), "DELETE", new ByteArrayInputStream("123".getBytes()), new HashMap<>()); assertThrows(UnsupportedOperationException.class, () -> request.getHeaders().put("0", ImmutableList.of())); }
@Test public void testHeaderValuesImmutable() throws IOException { JRestlessContainerRequest request = new DefaultJRestlessContainerRequest(URI.create("/123"), URI.create("/456"), "DELETE", new ByteArrayInputStream("123".getBytes()), ImmutableMap.of("a", ImmutableList.of("a0", "a1"))); assertThrows(UnsupportedOperationException.class, () -> request.getHeaders().get("a").add("123")); }
@Test public void testNullHeaderValuesFiltered() throws IOException { Map<String, List<String>> headers = new HashMap<>(); List<String> bVal = new ArrayList<>(); bVal.add(null); bVal.add("b_0"); headers.put("a", null); headers.put("b", bVal); JRestlessContainerRequest request = new DefaultJRestlessContainerRequest(URI.create("/123"), URI.create("/456"), "DELETE", new ByteArrayInputStream("123".getBytes()), headers); assertNull(request.getHeaders().get("a")); assertNull(request.getHeaders().get("b").get(0)); assertEquals("b_0", request.getHeaders().get("b").get(1)); assertEquals(1, request.getHeaders().size()); }