TopologyMgmtResourceImpl { public void startTopology(String topologyName) throws Exception { Optional<Topology> tdop = TopologyMgmtResourceHelper.findById(dao.listTopologies(), topologyName); Topology topologyDef; if (tdop.isPresent()) { topologyDef = tdop.get(); } else { topologyDef = new Topology(); topologyDef.setName(topologyName); } StormSubmitter.submitTopology(topologyName, getStormConf(null, topologyDef.getClusterName()), createTopology(topologyDef)); }  void startTopology(String topologyName); void stopTopology(String topologyName); List<TopologyStatus> getTopologies();  }
@Ignore @Test public void testStartTopology() throws Exception { topologyManager.startTopology(topologyName); Thread.sleep(10000); }
@Test public void testStartTopology1() throws Exception { IMetadataDao dao = MetadataDaoFactory.getInstance().getMetadataDao(); TopologyMgmtResourceImpl service = new TopologyMgmtResourceImpl(); Field daoField = TopologyMgmtResourceImpl.class.getDeclaredField("dao"); daoField.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(daoField, daoField.getModifiers() & ~Modifier.FINAL); daoField.set(null, dao); Topology topology = new Topology("test", 1, 1); StreamingCluster cluster =new StreamingCluster(); dao.clear(); dao.addTopology(topology); dao.addCluster(cluster); PowerMockito.mockStatic(StormSubmitter.class); PowerMockito.doNothing().when(StormSubmitter.class, "submitTopology",Mockito.eq("test"), Mockito.anyMap(), Mockito.any(StormTopology.class)); TopologyMgmtResourceImpl spy = PowerMockito.spy(service); PowerMockito.doReturn(null).when(spy,"createTopology", Mockito.any(Topology.class)); spy.startTopology("test"); }