Skip to content

Commit 0900583

Browse files
author
David O'Sullivan
committed
Bumps Supported API version, handles removal of Deployment 'state' in 2_11+
1 parent 84238d5 commit 0900583

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

Diff for: cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public interface CloudFoundryClient {
7979
/**
8080
* The currently supported Cloud Controller API version
8181
*/
82-
String SUPPORTED_API_VERSION = "2.150.0";
82+
String SUPPORTED_API_VERSION = "2.171.0";
8383

8484
/**
8585
* Main entry point to the Cloud Foundry Application Usage Events Client API

Diff for: integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public enum CloudFoundryVersion {
5252

5353
PCF_2_11(Version.forIntegers(2, 164, 0)),
5454

55+
PCF_2_12(Version.forIntegers(2, 171, 0)),
56+
5557
UNSPECIFIED(Version.forIntegers(0));
5658

5759
private final Version version;

Diff for: integration-test/src/test/java/org/cloudfoundry/client/v3/DeploymentsTest.java

+29-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.cloudfoundry.client.v3.deployments.DeploymentRelationships;
2929
import org.cloudfoundry.client.v3.deployments.DeploymentResource;
3030
import org.cloudfoundry.client.v3.deployments.DeploymentState;
31+
import org.cloudfoundry.client.v3.deployments.DeploymentStatusReason;
3132
import org.cloudfoundry.client.v3.deployments.DeploymentStatusValue;
3233
import org.cloudfoundry.client.v3.deployments.GetDeploymentRequest;
3334
import org.cloudfoundry.client.v3.deployments.ListDeploymentsRequest;
@@ -60,8 +61,35 @@ public final class DeploymentsTest extends AbstractIntegrationTest {
6061
@Autowired
6162
private CloudFoundryOperations cloudFoundryOperations;
6263

64+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_11)
65+
public void cancel_2_11() throws Exception {
66+
String name = this.nameFactory.getApplicationName();
67+
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
68+
69+
createApplicationId(this.cloudFoundryOperations, name, path)
70+
.flatMap(applicationId -> Mono.zip(
71+
Mono.just(applicationId),
72+
getDropletId(this.cloudFoundryClient, applicationId)
73+
))
74+
.flatMap(function((applicationId, dropletId) -> Mono.zip(
75+
Mono.just(applicationId),
76+
createDeploymentId(this.cloudFoundryClient, applicationId, dropletId)
77+
)))
78+
.flatMap(function((applicationId, deploymentId) -> this.cloudFoundryClient.deploymentsV3()
79+
.cancel(CancelDeploymentRequest.builder()
80+
.deploymentId(deploymentId)
81+
.build())
82+
.then(Mono.just(applicationId))))
83+
.flatMapMany(applicationId -> requestListDeployments(this.cloudFoundryClient, applicationId))
84+
.as(StepVerifier::create)
85+
.consumeNextWith(deploymentResource -> assertThat(deploymentResource.getStatus().getReason()).isIn(DeploymentStatusReason.CANCELED, DeploymentStatusReason.CANCELING))
86+
.expectComplete()
87+
.verify(Duration.ofMinutes(5));
88+
}
89+
6390
@SuppressWarnings("deprecation")
6491
@Test
92+
@IfCloudFoundryVersion(lessThanOrEqualTo = CloudFoundryVersion.PCF_2_10)
6593
public void cancel() throws Exception {
6694
String name = this.nameFactory.getApplicationName();
6795
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
@@ -81,9 +109,8 @@ public void cancel() throws Exception {
81109
.build())
82110
.then(Mono.just(applicationId))))
83111
.flatMapMany(applicationId -> requestListDeployments(this.cloudFoundryClient, applicationId))
84-
.map(DeploymentResource::getState)
85112
.as(StepVerifier::create)
86-
.consumeNextWith(isCancel())
113+
.consumeNextWith(deploymentResource -> assertThat(deploymentResource.getState()).isIn(DeploymentState.CANCELING, DeploymentState.CANCELED))
87114
.expectComplete()
88115
.verify(Duration.ofMinutes(5));
89116
}
@@ -255,10 +282,6 @@ private static Mono<String> getDropletId(CloudFoundryClient cloudFoundryClient,
255282
.map(GetApplicationCurrentDropletResponse::getId);
256283
}
257284

258-
private static Consumer<DeploymentState> isCancel() {
259-
return state -> assertThat(state).isIn(DeploymentState.CANCELING, DeploymentState.CANCELED);
260-
}
261-
262285
private static Mono<Void> requestCreateApplication(CloudFoundryOperations cloudFoundryOperations, String name, Path path) {
263286
return cloudFoundryOperations.applications()
264287
.push(PushApplicationRequest.builder()

0 commit comments

Comments
 (0)