16
16
17
17
package org .cloudfoundry .client .v3 ;
18
18
19
+ import static org .assertj .core .api .Assertions .assertThat ;
20
+
21
+ import java .time .Duration ;
19
22
import org .cloudfoundry .AbstractIntegrationTest ;
20
23
import org .cloudfoundry .CloudFoundryVersion ;
21
24
import org .cloudfoundry .IfCloudFoundryVersion ;
39
42
import reactor .core .publisher .Mono ;
40
43
import reactor .test .StepVerifier ;
41
44
42
- import java .time .Duration ;
43
-
44
- import static org .assertj .core .api .Assertions .assertThat ;
45
-
46
45
@ IfCloudFoundryVersion (greaterThanOrEqualTo = CloudFoundryVersion .PCF_2_8 )
47
46
public final class OrganizationQuotaDefinitionsTest extends AbstractIntegrationTest {
48
47
49
- @ Autowired
50
- private CloudFoundryClient cloudFoundryClient ;
48
+ @ Autowired private CloudFoundryClient cloudFoundryClient ;
51
49
52
50
@ Test
53
51
public void create () {
54
52
String organizationQuotaName = this .nameFactory .getOrganizationQuotaName ();
55
53
this .cloudFoundryClient
56
54
.organizationQuotaDefinitionsV3 ()
57
- .create (CreateOrganizationQuotaDefinitionRequest .builder ().name (organizationQuotaName ).build ())
58
- .thenMany (requestListOrganizationQuotas (this .cloudFoundryClient , organizationQuotaName ))
55
+ .create (
56
+ CreateOrganizationQuotaDefinitionRequest .builder ()
57
+ .name (organizationQuotaName )
58
+ .build ())
59
+ .thenMany (
60
+ requestListOrganizationQuotas (
61
+ this .cloudFoundryClient , organizationQuotaName ))
59
62
.single ()
60
63
.as (StepVerifier ::create )
61
64
.expectNextCount (1 )
@@ -76,15 +79,18 @@ public void delete() {
76
79
.organizationQuotaDefinitionsV3 ()
77
80
.delete (
78
81
DeleteOrganizationQuotaDefinitionRequest .builder ()
79
- .organizationQuotaDefinitionId (organizationId )
82
+ .organizationQuotaDefinitionId (
83
+ organizationId )
80
84
.build ())
81
85
.flatMap (
82
86
job ->
83
87
JobUtils .waitForCompletion (
84
88
this .cloudFoundryClient ,
85
89
Duration .ofMinutes (5 ),
86
90
job )))
87
- .thenMany (requestListOrganizationQuotas (this .cloudFoundryClient , organizationQuotaName ))
91
+ .thenMany (
92
+ requestListOrganizationQuotas (
93
+ this .cloudFoundryClient , organizationQuotaName ))
88
94
.as (StepVerifier ::create )
89
95
.expectComplete ()
90
96
.verify (Duration .ofMinutes (5 ));
@@ -101,7 +107,8 @@ public void get() {
101
107
.organizationQuotaDefinitionsV3 ()
102
108
.get (
103
109
GetOrganizationQuotaDefinitionRequest .builder ()
104
- .organizationQuotaDefinitionId (organizationQuotaId )
110
+ .organizationQuotaDefinitionId (
111
+ organizationQuotaId )
105
112
.build ()))
106
113
.map (GetOrganizationQuotaDefinitionResponse ::getName )
107
114
.as (StepVerifier ::create )
@@ -123,7 +130,8 @@ public void list() {
123
130
this .cloudFoundryClient
124
131
.organizationQuotaDefinitionsV3 ()
125
132
.list (
126
- ListOrganizationQuotaDefinitionsRequest .builder ()
133
+ ListOrganizationQuotaDefinitionsRequest
134
+ .builder ()
127
135
.page (page )
128
136
.build ())))
129
137
.filter (resource -> organizationQuotaName .equals (resource .getName ()))
@@ -138,7 +146,7 @@ public void list() {
138
146
@ Test
139
147
public void update () {
140
148
String organizationQuotaName = this .nameFactory .getOrganizationQuotaName ();
141
- int totalMemoryLimit = 64 * 1024 ; // 64 GB
149
+ int totalMemoryLimit = 64 * 1024 ; // 64 GB
142
150
143
151
createOrganizationQuotaId (this .cloudFoundryClient , organizationQuotaName )
144
152
.flatMap (
@@ -147,18 +155,44 @@ public void update() {
147
155
.organizationQuotaDefinitionsV3 ()
148
156
.update (
149
157
UpdateOrganizationQuotaDefinitionRequest .builder ()
150
- .organizationQuotaDefinitionId (organizationQuotaId )
151
- .apps (Apps .builder ().totalMemoryInMb (totalMemoryLimit ).build ())
152
- .routes (Routes .builder ().totalRoutes (100 ).build ())
153
- .services (Services .builder ().isPaidServicesAllowed (true ).totalServiceInstances (100 ).build ())
158
+ .organizationQuotaDefinitionId (
159
+ organizationQuotaId )
160
+ .apps (
161
+ Apps .builder ()
162
+ .totalMemoryInMb (
163
+ totalMemoryLimit )
164
+ .build ())
165
+ .routes (
166
+ Routes .builder ()
167
+ .totalRoutes (100 )
168
+ .build ())
169
+ .services (
170
+ Services .builder ()
171
+ .isPaidServicesAllowed (true )
172
+ .totalServiceInstances (100 )
173
+ .build ())
154
174
.build ()))
155
- .thenMany (requestListOrganizationQuotas (this .cloudFoundryClient , organizationQuotaName ))
175
+ .thenMany (
176
+ requestListOrganizationQuotas (
177
+ this .cloudFoundryClient , organizationQuotaName ))
156
178
.as (StepVerifier ::create )
157
179
.consumeNextWith (
158
180
organizationQuotaDefinitionResource -> {
159
- assertThat (organizationQuotaDefinitionResource .getApps ().getTotalMemoryInMb ()).isEqualTo (totalMemoryLimit );
160
- assertThat (organizationQuotaDefinitionResource .getRoutes ().getTotalRoutes ()).isEqualTo (100 );
161
- assertThat (organizationQuotaDefinitionResource .getServices ().getTotalServiceInstances ()).isEqualTo (100 );
181
+ assertThat (
182
+ organizationQuotaDefinitionResource
183
+ .getApps ()
184
+ .getTotalMemoryInMb ())
185
+ .isEqualTo (totalMemoryLimit );
186
+ assertThat (
187
+ organizationQuotaDefinitionResource
188
+ .getRoutes ()
189
+ .getTotalRoutes ())
190
+ .isEqualTo (100 );
191
+ assertThat (
192
+ organizationQuotaDefinitionResource
193
+ .getServices ()
194
+ .getTotalServiceInstances ())
195
+ .isEqualTo (100 );
162
196
})
163
197
.expectComplete ()
164
198
.verify (Duration .ofMinutes (5 ));
@@ -175,7 +209,10 @@ private static Mono<String> createOrganizationQuotaId(
175
209
private static Mono <String > getOrganizationQuotaId (
176
210
CloudFoundryClient cloudFoundryClient , String organizationQuotaName ) {
177
211
return requestListOrganizationQuotas (cloudFoundryClient , organizationQuotaName )
178
- .filter (organizationQuotaDefinitionResource -> organizationQuotaName .equals (organizationQuotaDefinitionResource .getName ()))
212
+ .filter (
213
+ organizationQuotaDefinitionResource ->
214
+ organizationQuotaName .equals (
215
+ organizationQuotaDefinitionResource .getName ()))
179
216
.single ()
180
217
.map (OrganizationQuotaDefinitionResource ::getId );
181
218
}
@@ -184,7 +221,10 @@ private static Mono<CreateOrganizationQuotaDefinitionResponse> requestCreateOrga
184
221
CloudFoundryClient cloudFoundryClient , String organizationQuotaName ) {
185
222
return cloudFoundryClient
186
223
.organizationQuotaDefinitionsV3 ()
187
- .create (CreateOrganizationQuotaDefinitionRequest .builder ().name (organizationQuotaName ).build ());
224
+ .create (
225
+ CreateOrganizationQuotaDefinitionRequest .builder ()
226
+ .name (organizationQuotaName )
227
+ .build ());
188
228
}
189
229
190
230
private static Flux <OrganizationQuotaDefinitionResource > requestListOrganizationQuotas (
@@ -200,7 +240,8 @@ private static Flux<OrganizationQuotaDefinitionResource> requestListOrganization
200
240
.build ()));
201
241
}
202
242
203
- private static void deleteOrganizationQuotaId (CloudFoundryClient cloudFoundryClient , String organizationQuotaName ) {
243
+ private static void deleteOrganizationQuotaId (
244
+ CloudFoundryClient cloudFoundryClient , String organizationQuotaName ) {
204
245
205
246
getOrganizationQuotaId (cloudFoundryClient , organizationQuotaName )
206
247
.flatMap (
@@ -209,7 +250,8 @@ private static void deleteOrganizationQuotaId(CloudFoundryClient cloudFoundryCli
209
250
.organizationQuotaDefinitionsV3 ()
210
251
.delete (
211
252
DeleteOrganizationQuotaDefinitionRequest .builder ()
212
- .organizationQuotaDefinitionId (organizationId )
253
+ .organizationQuotaDefinitionId (
254
+ organizationId )
213
255
.build ())
214
256
.flatMap (
215
257
job ->
0 commit comments