PropertiesHandler implements ResponsibleHandler { private void getStages(HttpRequest request, HttpResponse response, HttpContext context) { logger.trace("handleGetStages()"); String group = RESTTools.getParam(request, GroupStarter.GROUP_PARAM); Pipeline p = reader.getPipeline(); if(!p.hasGroup(group)) { p = reader.getDebugPipeline(); } if(p.hasGroup(group)) { HttpResponseWriter.printJson(response, p.getGroup(group).getStageNames()); return; } response.setStatusCode(HttpStatus.SC_NOT_FOUND); response.setEntity(new NStringEntity("", HttpResponseWriter.CONTENT_TYPE)); } PropertiesHandler(PipelineReader reader); @Override void handle(HttpRequest request, HttpResponse response, HttpContext context); @Override boolean supports(HttpRequest request); @Override String[] getSupportedUrls();  }
@Test public void testGetStages() throws Exception { Pipeline p = new Pipeline(); StageGroup g = new StageGroup("1"); g.addStage(new Stage("stage", Mockito.mock(DatabaseFile.class))); g.addStage(new Stage("stage2", Mockito.mock(DatabaseFile.class))); p.addGroup(g); Mockito.when(reader.getPipeline()).thenReturn(p); List<String> stages = GroupStarter.getStages("localhost", server.getPort(), "1"); assertTrue(stages.contains("stage")); assertTrue(stages.contains("stage2")); assertFalse(stages.contains("notingroup")); StageGroup g2 = new StageGroup("2"); g2.addStage(new Stage("debug", Mockito.mock(DatabaseFile.class))); Pipeline p2 = new Pipeline(); p2.addGroup(g2); Mockito.when(reader.getDebugPipeline()).thenReturn(p2); stages = GroupStarter.getStages("localhost", server.getPort(), "2"); assertTrue(stages.contains("debug")); assertFalse(stages.contains("stage")); }