### Question:
DefaultJsProcessorRegistry implements JsProcessorRegistry { public void process(JsRequest request, JsResponseBuilder response) throws JsException { for (JsProcessor processor : preProcessors) { if (!processor.process(request, response)){ return; } } for (JsProcessor processor : optionalProcessors) { if (!processor.process(request, response)) { break; } } for (JsProcessor processor : requiredProcessors) { processor.process(request, response); } } @Inject  DefaultJsProcessorRegistry(
      @Named("shindig.js.pre-processors") List<JsProcessor> preProcessors,
      @Named("shindig.js.optional-processors") List<JsProcessor> optionalProcessors,
      @Named("shindig.js.required-processors") List<JsProcessor> requiredProcessors); void process(JsRequest request, JsResponseBuilder response);  }### Answer:
@Test public void testProcessorModifiesResponse() throws Exception { JsProcessor preprocessor = new JsProcessor() { public boolean process(JsRequest request, JsResponseBuilder builder) { return true; } }; JsProcessor processor = new JsProcessor() { public boolean process(JsRequest request, JsResponseBuilder builder) { builder.clearJs().appendJs(JS_CODE, "js"); return true; } }; registry = new DefaultJsProcessorRegistry( ImmutableList.of(preprocessor), ImmutableList.of(processor), ImmutableList.<JsProcessor>of()); control.replay(); registry.process(request, response); assertEquals(JS_CODE, response.build().toJsString()); control.verify(); }
@Test public void testTwoProcessorsAreRunOneAfterAnother() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(true); EasyMock.expect(processor2.process(request, response)).andReturn(true); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testProcessorStopsProcessingWhenItReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(false); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testProcessorStopsProcessingWhenPreProcessorsReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(false); control.replay(); registry.process(request, response); control.verify(); }