2828import org .cloudfoundry .client .v3 .deployments .DeploymentRelationships ;
2929import org .cloudfoundry .client .v3 .deployments .DeploymentResource ;
3030import org .cloudfoundry .client .v3 .deployments .DeploymentState ;
31+ import org .cloudfoundry .client .v3 .deployments .DeploymentStatusReason ;
3132import org .cloudfoundry .client .v3 .deployments .DeploymentStatusValue ;
3233import org .cloudfoundry .client .v3 .deployments .GetDeploymentRequest ;
3334import 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