@Test public void testListChildrenInstances() throws Exception { List<Instance> instances = this.resource.listChildrenInstances( this.app.getName(), "/bip/bip", false ); Assert.assertEquals( 0, instances.size()); instances = this.resource.listChildrenInstances( this.app.getName(), "/bip/bip", true ); Assert.assertEquals( 0, instances.size()); instances = this.resource.listChildrenInstances( "inexisting", "/bip/bip", false ); Assert.assertEquals( 0, instances.size()); instances = this.resource.listChildrenInstances( this.app.getName(), null, false ); Assert.assertEquals( this.app.getRootInstances().size(), instances.size()); instances = this.resource.listChildrenInstances( this.app.getName(), null, true ); Assert.assertEquals( InstanceHelpers.getAllInstances( this.app ).size(), instances.size()); instances = this.resource.listChildrenInstances( this.app.getName(), InstanceHelpers.computeInstancePath( this.app.getTomcatVm()), false ); Assert.assertEquals( 1, instances.size()); instances = this.resource.listChildrenInstances( this.app.getName(), InstanceHelpers.computeInstancePath( this.app.getTomcatVm()), true ); Assert.assertEquals( 2, instances.size()); }
@Override public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ) { List<Instance> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( instancePath == null ) this.logger.fine( "Request: list " + (allChildren ? "all" : "root") + " instances for " + applicationName + "." ); else this.logger.fine( "Request: list " + (allChildren ? "all" : "direct") + " children instances for " + instancePath + " in " + applicationName + "." ); Instance inst; if( app != null ) { if( instancePath == null ) { if( allChildren ) result.addAll( InstanceHelpers.getAllInstances( app )); else result.addAll( app.getRootInstances()); } else if(( inst = InstanceHelpers.findInstanceByPath( app, instancePath )) != null ) { if( allChildren ) { result.addAll( InstanceHelpers.buildHierarchicalList( inst )); result.remove( inst ); } else { result.addAll( inst.getChildren()); } } } Collections.sort( result, new InstanceComparator()); return result; }
ApplicationResource implements IApplicationResource { @Override public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ) { List<Instance> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( instancePath == null ) this.logger.fine( "Request: list " + (allChildren ? "all" : "root") + " instances for " + applicationName + "." ); else this.logger.fine( "Request: list " + (allChildren ? "all" : "direct") + " children instances for " + instancePath + " in " + applicationName + "." ); Instance inst; if( app != null ) { if( instancePath == null ) { if( allChildren ) result.addAll( InstanceHelpers.getAllInstances( app )); else result.addAll( app.getRootInstances()); } else if(( inst = InstanceHelpers.findInstanceByPath( app, instancePath )) != null ) { if( allChildren ) { result.addAll( InstanceHelpers.buildHierarchicalList( inst )); result.remove( inst ); } else { result.addAll( inst.getChildren()); } } } Collections.sort( result, new InstanceComparator()); return result; } }
ApplicationResource implements IApplicationResource { @Override public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ) { List<Instance> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( instancePath == null ) this.logger.fine( "Request: list " + (allChildren ? "all" : "root") + " instances for " + applicationName + "." ); else this.logger.fine( "Request: list " + (allChildren ? "all" : "direct") + " children instances for " + instancePath + " in " + applicationName + "." ); Instance inst; if( app != null ) { if( instancePath == null ) { if( allChildren ) result.addAll( InstanceHelpers.getAllInstances( app )); else result.addAll( app.getRootInstances()); } else if(( inst = InstanceHelpers.findInstanceByPath( app, instancePath )) != null ) { if( allChildren ) { result.addAll( InstanceHelpers.buildHierarchicalList( inst )); result.remove( inst ); } else { result.addAll( inst.getChildren()); } } } Collections.sort( result, new InstanceComparator()); return result; } ApplicationResource( Manager manager ); }
ApplicationResource implements IApplicationResource { @Override public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ) { List<Instance> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( instancePath == null ) this.logger.fine( "Request: list " + (allChildren ? "all" : "root") + " instances for " + applicationName + "." ); else this.logger.fine( "Request: list " + (allChildren ? "all" : "direct") + " children instances for " + instancePath + " in " + applicationName + "." ); Instance inst; if( app != null ) { if( instancePath == null ) { if( allChildren ) result.addAll( InstanceHelpers.getAllInstances( app )); else result.addAll( app.getRootInstances()); } else if(( inst = InstanceHelpers.findInstanceByPath( app, instancePath )) != null ) { if( allChildren ) { result.addAll( InstanceHelpers.buildHierarchicalList( inst )); result.remove( inst ); } else { result.addAll( inst.getChildren()); } } } Collections.sort( result, new InstanceComparator()); return result; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags ); }
ApplicationResource implements IApplicationResource { @Override public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ) { List<Instance> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( instancePath == null ) this.logger.fine( "Request: list " + (allChildren ? "all" : "root") + " instances for " + applicationName + "." ); else this.logger.fine( "Request: list " + (allChildren ? "all" : "direct") + " children instances for " + instancePath + " in " + applicationName + "." ); Instance inst; if( app != null ) { if( instancePath == null ) { if( allChildren ) result.addAll( InstanceHelpers.getAllInstances( app )); else result.addAll( app.getRootInstances()); } else if(( inst = InstanceHelpers.findInstanceByPath( app, instancePath )) != null ) { if( allChildren ) { result.addAll( InstanceHelpers.buildHierarchicalList( inst )); result.remove( inst ); } else { result.addAll( inst.getChildren()); } } } Collections.sort( result, new InstanceComparator()); return result; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags );  }