@Test public void testListApplicationTemplates() throws Exception { List<ApplicationTemplate> templates = this.resource.listApplicationTemplates(); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); TestApplicationTemplate tpl = new TestApplicationTemplate(); this.managerWrapper.getApplicationTemplates().put( tpl, Boolean.TRUE ); Logger logger = Logger.getLogger( ManagementResource.class.getName()); LogManager.getLogManager().addLogger( logger ); logger.setLevel( Level.FINEST ); templates = this.resource.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.resource.listApplicationTemplates( "filter", null, null ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); templates = this.resource.listApplicationTemplates( tpl.getName(), null, 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.resource.listApplicationTemplates( tpl.getName(), tpl.getVersion(), 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.resource.listApplicationTemplates( null, tpl.getVersion(), 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.resource.listApplicationTemplates( null, tpl.getVersion() + "2", null ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); templates = this.resource.listApplicationTemplates( tpl.getName() + "1", null, null ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); final String tag = "cool"; tpl.addTag( tag ); templates = this.resource.listApplicationTemplates( null, tpl.getVersion(), tag ); 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.resource.listApplicationTemplates( null, tpl.getVersion() + "2", "invalid tag" ); Assert.assertNotNull( templates ); Assert.assertEquals( 0, templates.size()); }
@Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find 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.fine( sb.toString()); } } List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; }
ManagementResource implements IManagementResource { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find 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.fine( sb.toString()); } } List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } }
ManagementResource implements IManagementResource { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find 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.fine( sb.toString()); } } List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } ManagementResource( Manager manager ); }
ManagementResource implements IManagementResource { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find 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.fine( sb.toString()); } } List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } ManagementResource( Manager manager ); void setMavenResolver( MavenResolver mavenResolver ); @Override Response loadUploadedZippedApplicationTemplate( InputStream uploadedInputStream, FormDataContentDisposition fileDetail ); @Override Response loadZippedApplicationTemplate( String url ); @Override Response loadUnzippedApplicationTemplate( String localFilePath ); @Override List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ); @Override List<ApplicationTemplate> listApplicationTemplates(); @Override Response deleteApplicationTemplate( String tplName, String tplVersion ); @Override Response createApplication( Application app ); @Override List<Application> listApplications( String exactName ); @Override List<Application> listApplications(); @Override Response deleteApplication( String applicationName ); @Override Response shutdownApplication( String applicationName ); @Override Response setImage(
			final String name,
			final String qualifier,
			final InputStream image,
			final FormDataContentDisposition fileDetail); }
ManagementResource implements IManagementResource { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find 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.fine( sb.toString()); } } List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } ManagementResource( Manager manager ); void setMavenResolver( MavenResolver mavenResolver ); @Override Response loadUploadedZippedApplicationTemplate( InputStream uploadedInputStream, FormDataContentDisposition fileDetail ); @Override Response loadZippedApplicationTemplate( String url ); @Override Response loadUnzippedApplicationTemplate( String localFilePath ); @Override List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ); @Override List<ApplicationTemplate> listApplicationTemplates(); @Override Response deleteApplicationTemplate( String tplName, String tplVersion ); @Override Response createApplication( Application app ); @Override List<Application> listApplications( String exactName ); @Override List<Application> listApplications(); @Override Response deleteApplication( String applicationName ); @Override Response shutdownApplication( String applicationName ); @Override Response setImage(
			final String name,
			final String qualifier,
			final InputStream image,
			final FormDataContentDisposition fileDetail); static final long MAX_IMAGE_SIZE; }