1616
1717package org .cloudfoundry .reactor .client .v3 .quotas .spaces ;
1818
19- import static io .netty .handler .codec .http .HttpMethod .DELETE ;
20- import static io .netty .handler .codec .http .HttpMethod .GET ;
21- import static io .netty .handler .codec .http .HttpMethod .PATCH ;
22- import static io .netty .handler .codec .http .HttpMethod .POST ;
23- import static io .netty .handler .codec .http .HttpResponseStatus .ACCEPTED ;
24- import static io .netty .handler .codec .http .HttpResponseStatus .OK ;
19+ import static io .netty .handler .codec .http .HttpMethod .*;
20+ import static io .netty .handler .codec .http .HttpResponseStatus .*;
2521
2622import java .time .Duration ;
2723import java .util .Collections ;
28- import org .cloudfoundry .client .v3 .Link ;
29- import org .cloudfoundry .client .v3 .Pagination ;
30- import org .cloudfoundry .client .v3 .Relationship ;
31- import org .cloudfoundry .client .v3 .ToManyRelationship ;
32- import org .cloudfoundry .client .v3 .ToOneRelationship ;
33- import org .cloudfoundry .client .v3 .quotas .*;
24+ import java .util .Map ;
25+ import org .cloudfoundry .client .v3 .*;
26+ import org .cloudfoundry .client .v3 .quotas .Apps ;
27+ import org .cloudfoundry .client .v3 .quotas .Routes ;
28+ import org .cloudfoundry .client .v3 .quotas .Services ;
3429import org .cloudfoundry .client .v3 .quotas .spaces .*;
3530import org .cloudfoundry .reactor .InteractionContext ;
3631import org .cloudfoundry .reactor .TestRequest ;
@@ -57,13 +52,13 @@ void create() {
5752 .method (POST )
5853 .path ("/space_quotas" )
5954 .payload (
60- "fixtures/client/v3/space_quotas /POST_request.json" )
55+ "fixtures/client/v3/quotas/spaces /POST_request.json" )
6156 .build ())
6257 .response (
6358 TestResponse .builder ()
6459 .status (OK )
6560 .payload (
66- "fixtures/client/v3/space_quotas /POST_response.json" )
61+ "fixtures/client/v3/quotas/spaces /POST_response.json" )
6762 .build ())
6863 .build ());
6964
@@ -143,7 +138,7 @@ void get() {
143138 TestResponse .builder ()
144139 .status (OK )
145140 .payload (
146- "fixtures/client/v3/space_quotas /GET_{id}_response.json" )
141+ "fixtures/client/v3/quotas/spaces /GET_{id}_response.json" )
147142 .build ())
148143 .build ());
149144
@@ -165,7 +160,7 @@ void list() {
165160 TestResponse .builder ()
166161 .status (OK )
167162 .payload (
168- "fixtures/client/v3/space_quotas /GET_response.json" )
163+ "fixtures/client/v3/quotas/spaces /GET_response.json" )
169164 .build ())
170165 .build ());
171166
@@ -211,13 +206,13 @@ void update() {
211206 .method (PATCH )
212207 .path ("/space_quotas/" + EXPECTED_SPACE_QUOTA_ID_1 )
213208 .payload (
214- "fixtures/client/v3/space_quotas /PATCH_{id}_request.json" )
209+ "fixtures/client/v3/quotas/spaces /PATCH_{id}_request.json" )
215210 .build ())
216211 .response (
217212 TestResponse .builder ()
218213 .status (OK )
219214 .payload (
220- "fixtures/client/v3/space_quotas /PATCH_{id}_response.json" )
215+ "fixtures/client/v3/quotas/spaces /PATCH_{id}_response.json" )
221216 .build ())
222217 .build ());
223218
@@ -235,6 +230,71 @@ void update() {
235230 .verify (Duration .ofSeconds (5 ));
236231 }
237232
233+ @ Test
234+ void apply () {
235+ mockRequest (
236+ InteractionContext .builder ()
237+ .request (
238+ TestRequest .builder ()
239+ .method (POST )
240+ .path (
241+ "/space_quotas/24637893-3b77-489d-bb79-8466f0d88b52/relationships/spaces" )
242+ .payload (
243+ "fixtures/client/v3/quotas/spaces/relationships/POST_{id}_request.json" )
244+ .build ())
245+ .response (
246+ TestResponse .builder ()
247+ .status (OK )
248+ .payload (
249+ "fixtures/client/v3/quotas/spaces/relationships/POST_{id}_response.json" )
250+ .build ())
251+ .build ());
252+
253+ Relationship space1 = Relationship .builder ().id ("space-guid1" ).build ();
254+ Relationship space2 = Relationship .builder ().id ("space-guid2" ).build ();
255+
256+ ToManyRelationship organizationRelationships =
257+ ToManyRelationship .builder ().data (space1 , space2 ).build ();
258+
259+ this .spaceQuotasV3
260+ .apply (
261+ ApplySpaceQuotaRequest .builder ()
262+ .spaceQuotaId ("24637893-3b77-489d-bb79-8466f0d88b52" )
263+ .spaceRelationships (organizationRelationships )
264+ .build ())
265+ .as (StepVerifier ::create )
266+ .expectNext (
267+ ApplySpaceQuotaResponse .builder ()
268+ .from (expectedApplySpaceQuotaResponse ())
269+ .build ())
270+ .expectComplete ()
271+ .verify (Duration .ofSeconds (5 ));
272+ }
273+
274+ @ Test
275+ void remove () {
276+ mockRequest (
277+ InteractionContext .builder ()
278+ .request (
279+ TestRequest .builder ()
280+ .method (DELETE )
281+ .path (
282+ "/space_quotas/test-space-quota-id/relationships/spaces/test-space-guid" )
283+ .build ())
284+ .response (TestResponse .builder ().status (NO_CONTENT ).build ())
285+ .build ());
286+
287+ this .spaceQuotasV3
288+ .remove (
289+ RemoveSpaceQuotaRequest .builder ()
290+ .spaceQuotaId ("test-space-quota-id" )
291+ .spaceId ("test-space-guid" )
292+ .build ())
293+ .as (StepVerifier ::create )
294+ .expectComplete ()
295+ .verify (Duration .ofSeconds (5 ));
296+ }
297+
238298 @ NotNull
239299 private static SpaceQuotaResource expectedSpaceQuotaResource1 () {
240300 return buildSpaceQuotaResource (
@@ -252,6 +312,28 @@ private static SpaceQuotaResource expectedSpaceQuotaResource2() {
252312 null );
253313 }
254314
315+ @ NotNull
316+ private static ApplySpaceQuotaResponse expectedApplySpaceQuotaResponse () {
317+
318+ Relationship space1 = Relationship .builder ().id ("space-guid1" ).build ();
319+ Relationship space2 = Relationship .builder ().id ("space-guid2" ).build ();
320+ Relationship existingSpace = Relationship .builder ().id ("previous-space-guid" ).build ();
321+
322+ ToManyRelationship spaceRelationships =
323+ ToManyRelationship .builder ().data (space1 , space2 , existingSpace ).build ();
324+ Link selfLink =
325+ Link .builder ()
326+ .href (
327+ "https://api.example.org/v3/space_quotas/24637893-3b77-489d-bb79-8466f0d88b52/relationships/spaces" )
328+ .build ();
329+ Map <String , Link > links = Collections .singletonMap ("self" , selfLink );
330+
331+ return ApplySpaceQuotaResponse .builder ()
332+ .spaceRelationships (spaceRelationships )
333+ .links (links )
334+ .build ();
335+ }
336+
255337 @ NotNull
256338 private static SpaceQuotaResource buildSpaceQuotaResource (
257339 String id , String name , String relatedOrganizationId , String relatedSpaceId ) {
0 commit comments