ManagementWsDelegate { public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier ) throws ManagementWsException { if( this.logger.isLoggable( Level.FINER )) { if( exactName == null && exactQualifier == null ) { this.logger.finer( "Listing all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Listing/finding the application templates" ); if( exactName != null ) { sb.append( " with name = " ); sb.append( exactName ); } if( exactQualifier != null ) { if( exactName != null ) sb.append( " and" ); sb.append( " qualifier = " ); sb.append( exactQualifier ); } sb.append( "." ); this.logger.finer( sb.toString()); } } WebResource path = this.resource.path( UrlConstants.APPLICATIONS ).path( "templates" ); if( exactName != null ) path = path.queryParam( "name", exactName ); if( exactQualifier != null ) path = path.queryParam( "qualifier", exactQualifier ); List<ApplicationTemplate> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<ApplicationTemplate>> () {}); if( result != null ) this.logger.finer( result.size() + " application templates were found on the DM." ); else this.logger.finer( "No application template was found on the DM." ); return result != null ? result : new ArrayList<ApplicationTemplate> (); } ManagementWsDelegate( WebResource resource, WsClient wsClient ); void uploadZippedApplicationTemplate( File applicationFile ); void loadUnzippedApplicationTemplate( String localFilePath ); void loadZippedApplicationTemplate( String url ); List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier ); List<ApplicationTemplate> listApplicationTemplates(); void deleteApplicationTemplate( String templateName, String templateQualifier ); Application createApplication( String applicationName, String templateName, String templateQualifier ); List<Application> listApplications( String exactName ); List<Application> listApplications(); void shutdownApplication( String applicationName ); void deleteApplication( String applicationName );  }
@Test public void testListApplicationTemplates() throws Exception { List<ApplicationTemplate> templates = this.client.getManagementDelegate().listApplicationTemplates(); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); TestApplicationTemplate tpl = new TestApplicationTemplate(); this.managerWrapper.getApplicationTemplates().put( tpl, Boolean.TRUE ); templates = this.client.getManagementDelegate().listApplicationTemplates(); Assert.assertNotNull( templates ); Assert.assertEquals( 1, templates.size()); ApplicationTemplate receivedTpl = templates.get( 0 ); Assert.assertEquals( tpl.getName(), receivedTpl.getName()); Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription()); Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion()); templates = this.client.getManagementDelegate().listApplicationTemplates( "filter", null ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName(), null ); Assert.assertNotNull( templates ); Assert.assertEquals( 1, templates.size()); receivedTpl = templates.get( 0 ); Assert.assertEquals( tpl.getName(), receivedTpl.getName()); Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription()); Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion()); templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName(), tpl.getVersion()); Assert.assertNotNull( templates ); Assert.assertEquals( 1, templates.size()); receivedTpl = templates.get( 0 ); Assert.assertEquals( tpl.getName(), receivedTpl.getName()); Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription()); Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion()); templates = this.client.getManagementDelegate().listApplicationTemplates( null, tpl.getVersion()); Assert.assertNotNull( templates ); Assert.assertEquals( 1, templates.size()); receivedTpl = templates.get( 0 ); Assert.assertEquals( tpl.getName(), receivedTpl.getName()); Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription()); Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion()); templates = this.client.getManagementDelegate().listApplicationTemplates( null, tpl.getVersion() + "2" ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName() + "1", null ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); }