ProxyAwareUriBuilderFactory { @Nonnull private String getHeader(@Nonnull final String headerName) throws HeaderMissingException { assert headerName != null; final String headerValue = httpServletRequest.getHeader(headerName); if (headerValue == null) { LOG.error("getHeader: header {} is missing from request.", headerName); throw new HeaderMissingException(headerName); } return headerValue; } ProxyAwareUriBuilderFactory();   ProxyAwareUriBuilderFactory(
            @Nonnull final HttpServletRequest httpServletRequest,
            @Nonnull final UriInfo uriInfo); @Nonnull UriBuilder newInstance();  }
@SuppressWarnings("ProhibitedExceptionDeclared") @Test public void testGetHeaderExistent() throws Throwable { LOG.info("testGetHeaderExistent"); final String testHeaderValue = "test"; when(httpServletRequest.getHeader(HEADER_TEST_NAME_X_TEST)).thenReturn(testHeaderValue); assertThat(invokeGetHeader(impl, HEADER_TEST_NAME_X_TEST), is(testHeaderValue)); }
@SuppressWarnings({"ExpectedExceptionNeverThrown", "ProhibitedExceptionDeclared"}) @Test(expected = ProxyAwareUriBuilderFactory.HeaderMissingException.class) public void testGetHeaderNonExistent() throws Throwable { LOG.info( "testGetHeaderNonExistent: IMPORTANT - the following test case should throw 1 exception"); when(httpServletRequest.getHeader(HEADER_TEST_NAME_X_TEST)).thenReturn(null); invokeGetHeader(impl, HEADER_TEST_NAME_X_TEST); }