@Test public void testListChildrenInstances() throws Exception { List<Instance> instances = this.client.getApplicationDelegate().listChildrenInstances( this.app.getName(), "/bip/bip", false ); Assert.assertEquals( 0, instances.size()); instances = this.client.getApplicationDelegate().listChildrenInstances( this.app.getName(), null, false ); Assert.assertEquals( this.app.getRootInstances().size(), instances.size()); instances = this.client.getApplicationDelegate().listChildrenInstances( this.app.getName(), null, true ); Assert.assertEquals( InstanceHelpers.getAllInstances( this.app ).size(), instances.size()); instances = this.client.getApplicationDelegate().listChildrenInstances( this.app.getName(), InstanceHelpers.computeInstancePath( this.app.getTomcatVm()), false ); Assert.assertEquals( 1, instances.size()); instances = this.client.getApplicationDelegate().listChildrenInstances( this.app.getName(), InstanceHelpers.computeInstancePath( this.app.getTomcatVm()), true ); Assert.assertEquals( 2, instances.size()); }
public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; }
ApplicationWsDelegate { public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; } }
ApplicationWsDelegate { public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); }
ApplicationWsDelegate { public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ); void setDescription( String applicationName, String newDesc ); void deployAndStartAll( String applicationName, String instancePath ); void stopAll( String applicationName, String instancePath ); void undeployAll( String applicationName, String instancePath ); List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ); void addInstance( String applicationName, String parentInstancePath, Instance instance ); void removeInstance( String applicationName, String instancePath ); void resynchronize( String applicationName ); List<Component> listAllComponents( String applicationName ); List<Component> findComponentChildren( String applicationName, String componentName ); List<Component> findComponentAncestors( String applicationName, String componentName ); void bindApplication( String applicationName, String boundTplName, String boundApp ); List<String> listAllCommands( String applicationName ); }
ApplicationWsDelegate { public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ); void setDescription( String applicationName, String newDesc ); void deployAndStartAll( String applicationName, String instancePath ); void stopAll( String applicationName, String instancePath ); void undeployAll( String applicationName, String instancePath ); List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ); void addInstance( String applicationName, String parentInstancePath, Instance instance ); void removeInstance( String applicationName, String instancePath ); void resynchronize( String applicationName ); List<Component> listAllComponents( String applicationName ); List<Component> findComponentChildren( String applicationName, String componentName ); List<Component> findComponentAncestors( String applicationName, String componentName ); void bindApplication( String applicationName, String boundTplName, String boundApp ); List<String> listAllCommands( String applicationName );  }