28
28
import org .cloudfoundry .client .v3 .deployments .DeploymentRelationships ;
29
29
import org .cloudfoundry .client .v3 .deployments .DeploymentResource ;
30
30
import org .cloudfoundry .client .v3 .deployments .DeploymentState ;
31
+ import org .cloudfoundry .client .v3 .deployments .DeploymentStatusReason ;
31
32
import org .cloudfoundry .client .v3 .deployments .DeploymentStatusValue ;
32
33
import org .cloudfoundry .client .v3 .deployments .GetDeploymentRequest ;
33
34
import org .cloudfoundry .client .v3 .deployments .ListDeploymentsRequest ;
@@ -60,8 +61,35 @@ public final class DeploymentsTest extends AbstractIntegrationTest {
60
61
@ Autowired
61
62
private CloudFoundryOperations cloudFoundryOperations ;
62
63
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
+
63
90
@ SuppressWarnings ("deprecation" )
64
91
@ Test
92
+ @ IfCloudFoundryVersion (lessThanOrEqualTo = CloudFoundryVersion .PCF_2_10 )
65
93
public void cancel () throws Exception {
66
94
String name = this .nameFactory .getApplicationName ();
67
95
Path path = new ClassPathResource ("test-application.zip" ).getFile ().toPath ();
@@ -81,9 +109,8 @@ public void cancel() throws Exception {
81
109
.build ())
82
110
.then (Mono .just (applicationId ))))
83
111
.flatMapMany (applicationId -> requestListDeployments (this .cloudFoundryClient , applicationId ))
84
- .map (DeploymentResource ::getState )
85
112
.as (StepVerifier ::create )
86
- .consumeNextWith (isCancel ( ))
113
+ .consumeNextWith (deploymentResource -> assertThat ( deploymentResource . getState ()). isIn ( DeploymentState . CANCELING , DeploymentState . CANCELED ))
87
114
.expectComplete ()
88
115
.verify (Duration .ofMinutes (5 ));
89
116
}
@@ -255,10 +282,6 @@ private static Mono<String> getDropletId(CloudFoundryClient cloudFoundryClient,
255
282
.map (GetApplicationCurrentDropletResponse ::getId );
256
283
}
257
284
258
- private static Consumer <DeploymentState > isCancel () {
259
- return state -> assertThat (state ).isIn (DeploymentState .CANCELING , DeploymentState .CANCELED );
260
- }
261
-
262
285
private static Mono <Void > requestCreateApplication (CloudFoundryOperations cloudFoundryOperations , String name , Path path ) {
263
286
return cloudFoundryOperations .applications ()
264
287
.push (PushApplicationRequest .builder ()
0 commit comments