### Question:
SanitizingProxyUriManager implements ProxyUriManager { public List<Uri> make(List<ProxyUri> ctx, Integer forcedRefresh) { for (ProxyUri proxyUri : ctx) { proxyUri.setSanitizeContent(true); if (expectedMime != null) { proxyUri.setRewriteMimeType(expectedMime); } } return wrapped.make(ctx, forcedRefresh); } SanitizingProxyUriManager(ProxyUriManager wrapped, String expectedMime); ProxyUri process(Uri uri); List<Uri> make(List<ProxyUri> ctx, Integer forcedRefresh);  }### Answer:
@Test public void makeSingleNoMime() throws Exception { Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>(); Capture<Integer> intCapture = new Capture<Integer>(); List<ProxyUri> input = Lists.newArrayList(proxyUri); List<Uri> output = Lists.newArrayList(uri); Integer refresh = new Integer(0); expect(uriManager.make(capture(uriCapture), capture(intCapture))) .andReturn(output).once(); replay(uriManager); expect(proxyUri.setSanitizeContent(true)).andReturn(proxyUri).once(); replay(proxyUri); SanitizingProxyUriManager rewriter = makeRewriter(null); List<Uri> returned = rewriter.make(input, refresh); verify(uriManager); assertSame(uriCapture.getValue(), input); assertSame(intCapture.getValue(), refresh); assertEquals(1, returned.size()); verify(proxyUri); }
@Test public void makeSingleExpectedMime() throws Exception { Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>(); Capture<Integer> intCapture = new Capture<Integer>(); List<ProxyUri> input = Lists.newArrayList(proxyUri); List<Uri> output = Lists.newArrayList(uri); Integer refresh = new Integer(0); String mime = "my/mime"; expect(uriManager.make(capture(uriCapture), capture(intCapture))) .andReturn(output).once(); replay(uriManager); expect(proxyUri.setSanitizeContent(true)).andReturn(proxyUri).once(); expect(proxyUri.setRewriteMimeType(mime)).andReturn(proxyUri).once(); replay(proxyUri); SanitizingProxyUriManager rewriter = makeRewriter(mime); List<Uri> returned = rewriter.make(input, refresh); verify(uriManager); assertSame(uriCapture.getValue(), input); assertSame(intCapture.getValue(), refresh); assertEquals(1, returned.size()); verify(proxyUri); }
@Test public void makeList() throws Exception { Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>(); Capture<Integer> intCapture = new Capture<Integer>(); ProxyUri proxyUri2 = createMock(ProxyUri.class); List<ProxyUri> input = Lists.newArrayList(proxyUri, proxyUri2); Uri uri2 = new UriBuilder().toUri(); List<Uri> output = Lists.newArrayList(uri, uri2); Integer refresh = new Integer(0); String mime = "my/mime"; expect(uriManager.make(capture(uriCapture), capture(intCapture))) .andReturn(output).once(); replay(uriManager); expect(proxyUri.setSanitizeContent(true)).andReturn(proxyUri).once(); expect(proxyUri.setRewriteMimeType(mime)).andReturn(proxyUri).once(); expect(proxyUri2.setSanitizeContent(true)).andReturn(proxyUri2).once(); expect(proxyUri2.setRewriteMimeType(mime)).andReturn(proxyUri2).once(); replay(proxyUri, proxyUri2); SanitizingProxyUriManager rewriter = makeRewriter(mime); List<Uri> returned = rewriter.make(input, refresh); verify(uriManager); assertSame(uriCapture.getValue(), input); assertSame(intCapture.getValue(), refresh); assertEquals(2, returned.size()); verify(proxyUri, proxyUri2); }