### Question:
ConditionalRequestBuilder { public T buildUnconditionalRequest(final T request) { final T newRequest = messageCopier.copy(request); newRequest.addHeader(HeaderConstants.CACHE_CONTROL,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.addHeader(HeaderConstants.PRAGMA,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.removeHeaders(HeaderConstants.IF_RANGE); newRequest.removeHeaders(HeaderConstants.IF_MATCH); newRequest.removeHeaders(HeaderConstants.IF_NONE_MATCH); newRequest.removeHeaders(HeaderConstants.IF_UNMODIFIED_SINCE); newRequest.removeHeaders(HeaderConstants.IF_MODIFIED_SINCE); return newRequest; } ConditionalRequestBuilder(final MessageCopier<T> messageCopier); T buildConditionalRequest(final T request, final HttpCacheEntry cacheEntry); T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants); T buildUnconditionalRequest(final T request);  }### Answer:
@Test public void testBuildUnconditionalRequestUsesGETMethod() throws Exception { final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertEquals("GET", result.getMethod()); }
@Test public void testBuildUnconditionalRequestUsesRequestUri() throws Exception { final String uri = "/theURI"; request = new BasicHttpRequest("GET", uri); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertEquals(uri, result.getRequestUri()); }
@Test public void testBuildUnconditionalRequestAddsCacheControlNoCache() throws Exception { final HttpRequest result = impl.buildUnconditionalRequest(request); boolean ccNoCacheFound = false; final Iterator<HeaderElement> it = MessageSupport.iterate(result, HeaderConstants.CACHE_CONTROL); while (it.hasNext()) { final HeaderElement elt = it.next(); if ("no-cache".equals(elt.getName())) { ccNoCacheFound = true; } } Assert.assertTrue(ccNoCacheFound); }
@Test public void testBuildUnconditionalRequestAddsPragmaNoCache() throws Exception { final HttpRequest result = impl.buildUnconditionalRequest(request); boolean ccNoCacheFound = false; final Iterator<HeaderElement> it = MessageSupport.iterate(result, HeaderConstants.PRAGMA); while (it.hasNext()) { final HeaderElement elt = it.next(); if ("no-cache".equals(elt.getName())) { ccNoCacheFound = true; } } Assert.assertTrue(ccNoCacheFound); }
@Test public void testBuildUnconditionalRequestDoesNotUseIfRange() throws Exception { request.addHeader("If-Range","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertNull(result.getFirstHeader("If-Range")); }
@Test public void testBuildUnconditionalRequestDoesNotUseIfMatch() throws Exception { request.addHeader("If-Match","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertNull(result.getFirstHeader("If-Match")); }
@Test public void testBuildUnconditionalRequestDoesNotUseIfNoneMatch() throws Exception { request.addHeader("If-None-Match","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertNull(result.getFirstHeader("If-None-Match")); }
@Test public void testBuildUnconditionalRequestDoesNotUseIfUnmodifiedSince() throws Exception { request.addHeader("If-Unmodified-Since", DateUtils.formatDate(new Date())); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertNull(result.getFirstHeader("If-Unmodified-Since")); }
@Test public void testBuildUnconditionalRequestDoesNotUseIfModifiedSince() throws Exception { request.addHeader("If-Modified-Since", DateUtils.formatDate(new Date())); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertNull(result.getFirstHeader("If-Modified-Since")); }
@Test public void testBuildUnconditionalRequestCarriesOtherRequestHeaders() throws Exception { request.addHeader("User-Agent","MyBrowser/1.0"); final HttpRequest result = impl.buildUnconditionalRequest(request); Assert.assertEquals("MyBrowser/1.0", result.getFirstHeader("User-Agent").getValue()); }