ApplicationResource implements IApplicationResource { @Override public Response replaceTags( String name, String version, List<String> tags ) { this.logger.fine("Request: replace tags for template " + name + " (version " + version + ")."); Response response = Response.ok().build(); ApplicationTemplate tpl = this.manager.applicationTemplateMngr().findTemplate( name, version ); if( tpl == null ) response = Response.status( Status.NOT_FOUND ).build(); else tpl.setTags( tags ); return response; } 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 );  }
@Test public void testReplaceTags_success() throws Exception { Set<String> tags = new HashSet<> (); tags.add( "toto" ); tags.add( "titi" ); Response resp = this.resource.replaceTags( this.app.getTemplate().getName(), this.app.getTemplate().getVersion(), new ArrayList<>( tags )); Assert.assertEquals( tags, this.app.getTemplate().getTags()); Assert.assertEquals( Status.OK.getStatusCode(), resp.getStatus()); }
@Test public void testReplaceTags_notFound() throws Exception { Set<String> tags = new HashSet<> (); tags.add( "toto" ); tags.add( "titi" ); Response resp = this.resource.replaceTags( "ao", "9.0", new ArrayList<>( tags )); Assert.assertEquals( 0, this.app.getTemplate().getTags().size()); Assert.assertEquals( Status.NOT_FOUND.getStatusCode(), resp.getStatus()); }