@Test
 public void listFilterByName() {
   this.applicationId
       .then(
           applicationId ->
               this.cloudFoundryClient
                   .applicationsV2()
                   .list(ListApplicationsRequest.builder().name(TEST_APPLICATION_NAME).build())
                   .map(ResourceUtils::getResources))
       .subscribe(testSubscriber().assertCount(1));
 }
 @Test
 public void listFilterByDiego() {
   this.applicationId
       .then(
           applicationId ->
               this.cloudFoundryClient
                   .applicationsV2()
                   .list(ListApplicationsRequest.builder().diego(true).build())
                   .map(ResourceUtils::getResources))
       .subscribe(testSubscriber().assertCount(1));
 }
 @Test
 public void copy() {
   Mono.when(this.applicationId, this.spaceId)
       .then(
           function(
               (sourceId, spaceId) ->
                   this.cloudFoundryClient
                       .applicationsV2()
                       .create(
                           CreateApplicationRequest.builder()
                               .name("copy-application")
                               .spaceId(spaceId)
                               .build())
                       .map(ResourceUtils::getId)
                       .and(Mono.just(sourceId))))
       .then(
           function(
               (targetId, sourceId) ->
                   this.cloudFoundryClient
                       .applicationsV2()
                       .copy(
                           CopyApplicationRequest.builder()
                               .applicationId(targetId)
                               .sourceApplicationId(sourceId)
                               .build())
                       .map(ResourceUtils::getId)))
       .flatMap(
           applicationCopyId ->
               Stream.from(
                       this.cloudFoundryClient
                           .applicationsV2()
                           .list(ListApplicationsRequest.builder().build()))
                   .flatMap(ResourceUtils::getResources)
                   .filter(
                       r -> {
                         String name = ResourceUtils.getEntity(r).getName();
                         return TEST_APPLICATION_NAME.equals(name)
                             || "copy-application".equals(name);
                       }))
       .subscribe(testSubscriber().assertCount(2));
 }