### Question:
ContextAwareRegistry implements ResponseRewriterRegistry { List<ResponseRewriter> getResponseRewriters(String container) { RewritePath rewritePath = new RewritePath(container, rewriteFlow); Provider<List<ResponseRewriter>> rewriterListProvider = rewritePathToRewriterList.get().get(rewritePath); if (rewriterListProvider == null) { rewritePath = new RewritePath(ContainerConfig.DEFAULT_CONTAINER, rewriteFlow); rewriterListProvider = rewritePathToRewriterList.get().get(rewritePath); } return rewriterListProvider != null ? rewriterListProvider.get() : ImmutableList.<ResponseRewriter>of(); } ContextAwareRegistry(GadgetHtmlParser htmlParser,
                              RewriteFlow rewriteFlow,
                              Provider<Map<RewritePath, Provider<List<ResponseRewriter>>>>
                                  rewritePathToRewriterList); HttpResponse rewriteHttpResponse(HttpRequest req, HttpResponse resp,
          Gadget gadget);  }### Answer:
@Test public void testGetResponseRewriters() throws Exception { final Map<RewritePath, Provider<List<ResponseRewriter>>> rewritePathToList = Maps.newHashMap(); Provider<Map<RewritePath, Provider<List<ResponseRewriter>>>> mapProvider = Providers.of( rewritePathToList); List<ResponseRewriter> list = ImmutableList.<ResponseRewriter>of( new TestRewriter("helo"), new TestRewriter("buffalo")); List<ResponseRewriter> emptyList = ImmutableList.of(); List<ResponseRewriter> list2 = ImmutableList.<ResponseRewriter>of(new TestRewriter(null)); addBindingForRewritePath(ContainerConfig.DEFAULT_CONTAINER, RewriteFlow.ACCELERATE, Providers.of(list), rewritePathToList); addBindingForRewritePath(ContainerConfig.DEFAULT_CONTAINER, RewriteFlow.DEFAULT, Providers.of(emptyList), rewritePathToList); list = ImmutableList.<ResponseRewriter>of(new TestRewriter("cat"), new TestRewriter("dog")); addBindingForRewritePath(TEST_CONTAINER, RewriteFlow.ACCELERATE, Providers.of(list), rewritePathToList); addBindingForRewritePath(TEST_CONTAINER, RewriteFlow.DEFAULT, Providers.of(list2), rewritePathToList); contextAwareRegistry = new ContextAwareRegistry(null, RewriteFlow.ACCELERATE, mapProvider); list = contextAwareRegistry.getResponseRewriters(TEST_CONTAINER); assertEquals(2, list.size()); assertEquals("cat", ((TestRewriter) list.get(0)).val); assertEquals("dog", ((TestRewriter) list.get(1)).val); contextAwareRegistry = new ContextAwareRegistry(null, RewriteFlow.DUMMY_FLOW, mapProvider); list = contextAwareRegistry.getResponseRewriters(TEST_CONTAINER); assertEquals(0, list.size()); contextAwareRegistry = new ContextAwareRegistry(null, RewriteFlow.ACCELERATE, mapProvider); list = contextAwareRegistry.getResponseRewriters(DUMMY_CONTAINER); assertEquals(2, list.size()); assertEquals("helo", ((TestRewriter) list.get(0)).val); assertEquals("buffalo", ((TestRewriter) list.get(1)).val); rewritePathToList.remove(new RewritePath(ContainerConfig.DEFAULT_CONTAINER, RewriteFlow.ACCELERATE)); rewritePathToList.remove(new RewritePath(ContainerConfig.DEFAULT_CONTAINER, RewriteFlow.DEFAULT)); contextAwareRegistry = new ContextAwareRegistry(null, RewriteFlow.ACCELERATE, mapProvider); list = contextAwareRegistry.getResponseRewriters(DUMMY_CONTAINER); assertEquals(0, list.size()); }