diff --git a/.idea/misc.xml b/.idea/misc.xml index b56f5aa0e7..fc9aaf441c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -14,7 +14,7 @@ - + \ No newline at end of file diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/ServiceInstancesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/ServiceInstancesTest.java index 38508a4cb4..4a6da53251 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/ServiceInstancesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/ServiceInstancesTest.java @@ -275,7 +275,9 @@ private static Mono updateServiceInstanceByName(CloudFoundryClient cloud .build()) .map(serviceInstances -> serviceInstances.getResources().get(0)) .flatMap(serviceInstance -> updateServiceInstanceById(cloudFoundryClient, serviceInstance.getId())) - .flatMap(serviceInstance -> waitForCompletionOnUpdate(cloudFoundryClient, serviceInstance, serviceInstanceName)); + .map(response -> response.getJobId().get()) + .flatMap(jobId -> JobUtils.waitForCompletion(cloudFoundryClient, Duration.ofMinutes(5), jobId)) + .then(getServiceInstanceIdByName(cloudFoundryClient, serviceInstanceName)); } private static Mono updateServiceInstanceById(CloudFoundryClient cloudFoundryClient, String serviceInstanceId) { @@ -287,26 +289,14 @@ private static Mono updateServiceInstanceById(Clo .build()); } - - private static Mono waitForCompletionOnUpdate(CloudFoundryClient cloudFoundryClient, UpdateServiceInstanceResponse updateServiceInstanceResponse, String serviceInstanceName) { - if (updateServiceInstanceResponse.getJobId().isPresent()) { - JobUtils.waitForCompletion(cloudFoundryClient, Duration.ofMinutes(1), updateServiceInstanceResponse.getJobId().get()); - } - return getServiceInstanceIdByName(cloudFoundryClient, serviceInstanceName); - } - private static Mono createManagedServiceInstanceId(CloudFoundryClient cloudFoundryClient, Mono serviceBrokerId, String serviceInstanceName, String serviceName, String spaceId) { return serviceBrokerId .flatMap(brokerId -> getPlanId(cloudFoundryClient, brokerId, serviceName)) .flatMap(planId -> requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName, spaceId)) - .flatMap(serviceInstance -> waitForCompletionOnCreate(cloudFoundryClient, serviceInstance, serviceInstanceName)); - } - - private static Mono waitForCompletionOnCreate(CloudFoundryClient cloudFoundryClient, CreateServiceInstanceResponse createServiceInstanceResponse, String serviceInstanceName) { - if (createServiceInstanceResponse.getJobId().isPresent()) { - JobUtils.waitForCompletion(cloudFoundryClient, Duration.ofMinutes(1), createServiceInstanceResponse.getJobId().get()); - } - return getServiceInstanceIdByName(cloudFoundryClient, serviceInstanceName); + .map(response -> response.getJobId() + .get()) + .flatMap(jobId -> JobUtils.waitForCompletion(cloudFoundryClient, Duration.ofMinutes(5), jobId)) + .then(getServiceInstanceIdByName(cloudFoundryClient, serviceInstanceName)); } private static Mono getServiceInstanceIdByName(CloudFoundryClient cloudFoundryClient, String serviceInstanceName) {