StormStatusServiceImpl implements StormStatusService { @Override public TopologyStatus getTopologyStatus(String name) { TopologyStatus topologyResponse = null; String id = getTopologyId(name); if (id != null) { topologyResponse = restTemplate .getForObject(getStormUiProperty() + TOPOLOGY_URL + "/" + id, TopologyStatus.class); } return topologyResponse; } @Autowired  StormStatusServiceImpl(Environment environment, RestTemplate restTemplate, SensorParserGroupService sensorParserGroupService); @Override SupervisorSummary getSupervisorSummary(); @Override TopologySummary getTopologySummary(); @Override TopologyStatus getTopologyStatus(String name); @Override List<TopologyStatus> getAllTopologyStatus(); @Override TopologyResponse activateTopology(String name); @Override TopologyResponse deactivateTopology(String name);  }
@Test public void getTopologyStatusShouldReturnTopologyStatus() throws Exception { final TopologyStatus topologyStatus = new TopologyStatus(); topologyStatus.setStatus(TopologyStatusCode.STARTED); topologyStatus.setName("bro"); topologyStatus.setId("bro_id"); final TopologySummary topologySummary = new TopologySummary(); topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI); when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus); TopologyStatus expected = new TopologyStatus(); expected.setStatus(TopologyStatusCode.STARTED); expected.setName("bro"); expected.setId("bro_id"); TopologyStatus actual = stormStatusService.getTopologyStatus("bro"); assertEquals(expected, actual); assertEquals(expected.hashCode(), actual.hashCode()); }
@Test public void getTopologyStatusByGroupShouldReturnTopologyStatus() throws Exception { final TopologyStatus topologyStatus = new TopologyStatus(); topologyStatus.setStatus(TopologyStatusCode.STARTED); topologyStatus.setName("bro__snort"); topologyStatus.setId("bro_snort_id"); final TopologySummary topologySummary = new TopologySummary(); topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); SensorParserGroup group = new SensorParserGroup(); group.setName("group"); group.setSensors(new HashSet<String>() {{ add("bro"); add("snort"); }}); when(sensorParserGroupService.findOne("group")).thenReturn(group); when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI); when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_snort_id", TopologyStatus.class)).thenReturn(topologyStatus); TopologyStatus expected = new TopologyStatus(); expected.setStatus(TopologyStatusCode.STARTED); expected.setName("bro__snort"); expected.setId("bro_snort_id"); TopologyStatus actual = stormStatusService.getTopologyStatus("group"); assertEquals(expected, actual); assertEquals(expected.hashCode(), actual.hashCode()); }