ManagementWsDelegate { public List<Application> listApplications( String exactName ) throws ManagementWsException { if( exactName != null ) this.logger.finer( "List/finding the application named " + exactName + "." ); else this.logger.finer( "Listing all the applications." ); WebResource path = this.resource.path( UrlConstants.APPLICATIONS ); if( exactName != null ) path = path.queryParam( "name", exactName ); List<Application> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Application>> () {}); if( result != null ) this.logger.finer( result.size() + " applications were found on the DM." ); else this.logger.finer( "No application was found on the DM." ); return result != null ? result : new ArrayList<Application> (); } 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 testListApplications() throws Exception { List<Application> apps = this.client.getManagementDelegate().listApplications(); Assert.assertNotNull( apps ); Assert.assertEquals( 0, apps.size()); TestApplication app = new TestApplication(); app.setDirectory( this.folder.newFolder()); this.managerWrapper.addManagedApplication( new ManagedApplication( app )); apps = this.client.getManagementDelegate().listApplications(); Assert.assertNotNull( apps ); Assert.assertEquals( 1, apps.size()); Application receivedApp = apps.get( 0 ); Assert.assertEquals( app.getName(), receivedApp.getName()); Assert.assertEquals( app.getDescription(), receivedApp.getDescription()); apps = this.client.getManagementDelegate().listApplications( "filter" ); Assert.assertNotNull( apps ); Assert.assertEquals( 0, apps.size()); apps = this.client.getManagementDelegate().listApplications( app.getName()); Assert.assertNotNull( apps ); Assert.assertEquals( 1, apps.size()); receivedApp = apps.get( 0 ); Assert.assertEquals( app.getName(), receivedApp.getName()); Assert.assertEquals( app.getDescription(), receivedApp.getDescription()); apps = this.client.getManagementDelegate().listApplications( app.getName() + "0" ); Assert.assertNotNull( apps ); Assert.assertEquals( 0, apps.size()); this.client.setSessionId( "whatever, filtering is not enabled during these tests" ); apps = this.client.getManagementDelegate().listApplications(); Assert.assertNotNull( apps ); Assert.assertEquals( 1, apps.size()); }