@Test public void test_stopIsPropagatedToChildren_notDeployed() throws Exception { IAgentClient messagingClient = Mockito.mock( IAgentClient.class ); WaitingForAncestor wfa = new WaitingForAncestor( "app", messagingClient ); TestApplication app = new TestApplication(); app.getTomcatVm().setStatus( InstanceStatus.DEPLOYED_STARTED ); app.getTomcat().setStatus( InstanceStatus.WAITING_FOR_ANCESTOR ); wfa.changeInstanceState( app.getTomcat(), null, InstanceStatus.DEPLOYED_STOPPED, null ); Mockito.verifyZeroInteractions( messagingClient ); Assert.assertEquals( InstanceStatus.DEPLOYED_STARTED, app.getTomcatVm().getStatus()); Assert.assertEquals( InstanceStatus.DEPLOYED_STOPPED, app.getTomcat().getStatus()); Assert.assertEquals( InstanceStatus.NOT_DEPLOYED, app.getWar().getStatus()); }
@Override public void changeInstanceState( Instance instance, PluginInterface plugin, InstanceStatus newStatus, Map<String,byte[]> fileNameToFileContent ) throws IOException, PluginException { if( newStatus == InstanceStatus.NOT_DEPLOYED ) undeploy( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STARTED ) start( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STOPPED ) { instance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); List<Instance> childrenInstances = InstanceHelpers.buildHierarchicalList( instance ); childrenInstances.remove( instance ); for( Instance childInstance : childrenInstances ) { if( childInstance.getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) childInstance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); } } }
WaitingForAncestor extends AbstractLifeCycleManager { @Override public void changeInstanceState( Instance instance, PluginInterface plugin, InstanceStatus newStatus, Map<String,byte[]> fileNameToFileContent ) throws IOException, PluginException { if( newStatus == InstanceStatus.NOT_DEPLOYED ) undeploy( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STARTED ) start( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STOPPED ) { instance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); List<Instance> childrenInstances = InstanceHelpers.buildHierarchicalList( instance ); childrenInstances.remove( instance ); for( Instance childInstance : childrenInstances ) { if( childInstance.getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) childInstance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); } } } }
WaitingForAncestor extends AbstractLifeCycleManager { @Override public void changeInstanceState( Instance instance, PluginInterface plugin, InstanceStatus newStatus, Map<String,byte[]> fileNameToFileContent ) throws IOException, PluginException { if( newStatus == InstanceStatus.NOT_DEPLOYED ) undeploy( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STARTED ) start( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STOPPED ) { instance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); List<Instance> childrenInstances = InstanceHelpers.buildHierarchicalList( instance ); childrenInstances.remove( instance ); for( Instance childInstance : childrenInstances ) { if( childInstance.getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) childInstance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); } } } WaitingForAncestor( String appName, IAgentClient messagingClient ); }
WaitingForAncestor extends AbstractLifeCycleManager { @Override public void changeInstanceState( Instance instance, PluginInterface plugin, InstanceStatus newStatus, Map<String,byte[]> fileNameToFileContent ) throws IOException, PluginException { if( newStatus == InstanceStatus.NOT_DEPLOYED ) undeploy( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STARTED ) start( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STOPPED ) { instance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); List<Instance> childrenInstances = InstanceHelpers.buildHierarchicalList( instance ); childrenInstances.remove( instance ); for( Instance childInstance : childrenInstances ) { if( childInstance.getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) childInstance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); } } } WaitingForAncestor( String appName, IAgentClient messagingClient ); @Override void changeInstanceState(
			Instance instance,
			PluginInterface plugin,
			InstanceStatus newStatus,
			Map<String,byte[]> fileNameToFileContent ); }
WaitingForAncestor extends AbstractLifeCycleManager { @Override public void changeInstanceState( Instance instance, PluginInterface plugin, InstanceStatus newStatus, Map<String,byte[]> fileNameToFileContent ) throws IOException, PluginException { if( newStatus == InstanceStatus.NOT_DEPLOYED ) undeploy( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STARTED ) start( instance, plugin ); else if( newStatus == InstanceStatus.DEPLOYED_STOPPED ) { instance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); List<Instance> childrenInstances = InstanceHelpers.buildHierarchicalList( instance ); childrenInstances.remove( instance ); for( Instance childInstance : childrenInstances ) { if( childInstance.getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) childInstance.setStatus( InstanceStatus.DEPLOYED_STOPPED ); } } } WaitingForAncestor( String appName, IAgentClient messagingClient ); @Override void changeInstanceState(
			Instance instance,
			PluginInterface plugin,
			InstanceStatus newStatus,
			Map<String,byte[]> fileNameToFileContent );  }