@Test public void testAddInstance_child_incompleteComponent() throws Exception { String mySqlComponentName = this.app.getMySql().getComponent().getName(); Instance newMysql = new Instance( "mysql-2" ).component( new Component( mySqlComponentName )); Assert.assertEquals( 1, this.app.getTomcatVm().getChildren().size()); Assert.assertFalse( this.app.getTomcatVm().getChildren().contains( newMysql )); this.client.getApplicationDelegate().addInstance( this.app.getName(), InstanceHelpers.computeInstancePath( this.app.getTomcatVm()), newMysql ); Assert.assertEquals( 2, this.app.getTomcatVm().getChildren().size()); List<String> paths = new ArrayList<> (); for( Instance inst : this.app.getTomcatVm().getChildren()) paths.add( InstanceHelpers.computeInstancePath( inst )); String rootPath = InstanceHelpers.computeInstancePath( this.app.getTomcatVm()); Assert.assertTrue( paths.contains( rootPath + "/" + newMysql.getName())); Assert.assertTrue( paths.contains( rootPath + "/" + this.app.getTomcat().getName())); }
public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
ApplicationWsDelegate { public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } }
ApplicationWsDelegate { public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); }
ApplicationWsDelegate { public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } 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 void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } 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 );  }