|
22 | 22 | import org.cloudfoundry.client.v3.Relationship; |
23 | 23 | import org.cloudfoundry.client.v3.ToManyRelationship; |
24 | 24 | import org.cloudfoundry.client.v3.ToOneRelationship; |
| 25 | +import org.cloudfoundry.client.v3.UsageSummary; |
25 | 26 | import org.cloudfoundry.client.v3.domains.DomainRelationships; |
26 | 27 | import org.cloudfoundry.client.v3.domains.DomainResource; |
27 | 28 | import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentRequest; |
28 | 29 | import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse; |
29 | 30 | import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest; |
30 | 31 | import org.cloudfoundry.client.v3.organizations.CreateOrganizationResponse; |
| 32 | +import org.cloudfoundry.client.v3.organizations.DeleteOrganizationRequest; |
| 33 | +import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainRequest; |
| 34 | +import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainResponse; |
31 | 35 | import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentRequest; |
32 | 36 | import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentResponse; |
33 | 37 | import org.cloudfoundry.client.v3.organizations.GetOrganizationRequest; |
34 | 38 | import org.cloudfoundry.client.v3.organizations.GetOrganizationResponse; |
| 39 | +import org.cloudfoundry.client.v3.organizations.GetOrganizationUsageSummaryRequest; |
| 40 | +import org.cloudfoundry.client.v3.organizations.GetOrganizationUsageSummaryResponse; |
35 | 41 | import org.cloudfoundry.client.v3.organizations.ListOrganizationDomainsRequest; |
36 | 42 | import org.cloudfoundry.client.v3.organizations.ListOrganizationDomainsResponse; |
37 | 43 | import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest; |
|
49 | 55 | import java.time.Duration; |
50 | 56 | import java.util.Collections; |
51 | 57 |
|
| 58 | +import static io.netty.handler.codec.http.HttpMethod.DELETE; |
52 | 59 | import static io.netty.handler.codec.http.HttpMethod.GET; |
53 | 60 | import static io.netty.handler.codec.http.HttpMethod.PATCH; |
54 | 61 | import static io.netty.handler.codec.http.HttpMethod.POST; |
| 62 | +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; |
55 | 63 | import static io.netty.handler.codec.http.HttpResponseStatus.OK; |
| 64 | +import static org.cloudfoundry.client.v3.routes.Protocol.HTTP; |
56 | 65 |
|
57 | 66 | public class ReactorOrganizationsV3Test extends AbstractClientApiTest { |
58 | 67 |
|
@@ -129,6 +138,28 @@ public void create() { |
129 | 138 | .verify(Duration.ofSeconds(5)); |
130 | 139 | } |
131 | 140 |
|
| 141 | + @Test |
| 142 | + public void delete() { |
| 143 | + mockRequest(InteractionContext.builder() |
| 144 | + .request(TestRequest.builder() |
| 145 | + .method(DELETE).path("/organizations/test-organization-id") |
| 146 | + .build()) |
| 147 | + .response(TestResponse.builder() |
| 148 | + .status(ACCEPTED) |
| 149 | + .header("Location", "https://api.example.org/v3/jobs/test-job-id") |
| 150 | + .build()) |
| 151 | + .build()); |
| 152 | + |
| 153 | + this.organizations |
| 154 | + .delete(DeleteOrganizationRequest.builder() |
| 155 | + .organizationId("test-organization-id") |
| 156 | + .build()) |
| 157 | + .as(StepVerifier::create) |
| 158 | + .expectNext("test-job-id") |
| 159 | + .expectComplete() |
| 160 | + .verify(Duration.ofSeconds(5)); |
| 161 | + } |
| 162 | + |
132 | 163 | @Test |
133 | 164 | public void get() { |
134 | 165 | mockRequest(InteractionContext.builder() |
@@ -163,6 +194,66 @@ public void get() { |
163 | 194 | .verify(Duration.ofSeconds(5)); |
164 | 195 | } |
165 | 196 |
|
| 197 | + @Test |
| 198 | + public void getDefaultDomain() { |
| 199 | + mockRequest(InteractionContext.builder() |
| 200 | + .request(TestRequest.builder() |
| 201 | + .method(GET).path("/organizations/test-organization-id/domains/default") |
| 202 | + .build()) |
| 203 | + .response(TestResponse.builder() |
| 204 | + .status(OK) |
| 205 | + .payload("fixtures/client/v3/organizations/GET_{id}_domains_default_response.json") |
| 206 | + .build()) |
| 207 | + .build()); |
| 208 | + |
| 209 | + this.organizations |
| 210 | + .getDefaultDomain(GetOrganizationDefaultDomainRequest.builder() |
| 211 | + .organizationId("test-organization-id") |
| 212 | + .build()) |
| 213 | + .as(StepVerifier::create) |
| 214 | + .expectNext(GetOrganizationDefaultDomainResponse.builder() |
| 215 | + .id("3a5d3d89-3f89-4f05-8188-8a2b298c79d5") |
| 216 | + .createdAt("2019-03-08T01:06:19Z") |
| 217 | + .updatedAt("2019-03-08T01:06:19Z") |
| 218 | + .name("test-domain.com") |
| 219 | + .isInternal(false) |
| 220 | + .supportedProtocol(HTTP) |
| 221 | + .metadata(Metadata.builder() |
| 222 | + .annotations(Collections.emptyMap()) |
| 223 | + .labels(Collections.emptyMap()) |
| 224 | + .build()) |
| 225 | + .relationships(DomainRelationships.builder() |
| 226 | + .organization(ToOneRelationship.builder() |
| 227 | + .data(Relationship.builder() |
| 228 | + .id("3a3f3d89-3f89-4f05-8188-751b298c79d5") |
| 229 | + .build()) |
| 230 | + .build()) |
| 231 | + .sharedOrganizations(ToManyRelationship.builder() |
| 232 | + .data(Relationship.builder() |
| 233 | + .id("404f3d89-3f89-6z72-8188-751b298d88d5") |
| 234 | + .build()) |
| 235 | + .data(Relationship.builder() |
| 236 | + .id("416d3d89-3f89-8h67-2189-123b298d3592") |
| 237 | + .build()) |
| 238 | + .build()) |
| 239 | + .build()) |
| 240 | + .link("self", Link.builder() |
| 241 | + .href("https://api.example.org/v3/domains/3a5d3d89-3f89-4f05-8188-8a2b298c79d5") |
| 242 | + .build()) |
| 243 | + .link("organization", Link.builder() |
| 244 | + .href("https://api.example.org/v3/organizations/3a3f3d89-3f89-4f05-8188-751b298c79d5") |
| 245 | + .build()) |
| 246 | + .link("route_reservations", Link.builder() |
| 247 | + .href("https://api.example.org/v3/domains/3a5d3d89-3f89-4f05-8188-8a2b298c79d5/route_reservations") |
| 248 | + .build()) |
| 249 | + .link("shared_organizations", Link.builder() |
| 250 | + .href("https://api.example.org/v3/domains/3a5d3d89-3f89-4f05-8188-8a2b298c79d5/relationships/shared_organizations") |
| 251 | + .build()) |
| 252 | + .build()) |
| 253 | + .expectComplete() |
| 254 | + .verify(Duration.ofSeconds(5)); |
| 255 | + } |
| 256 | + |
166 | 257 | @Test |
167 | 258 | public void getDefaultIsolationSegment() { |
168 | 259 | mockRequest(InteractionContext.builder() |
@@ -195,6 +286,39 @@ public void getDefaultIsolationSegment() { |
195 | 286 | .verify(Duration.ofSeconds(5)); |
196 | 287 | } |
197 | 288 |
|
| 289 | + @Test |
| 290 | + public void getUsageSummary() { |
| 291 | + mockRequest(InteractionContext.builder() |
| 292 | + .request(TestRequest.builder() |
| 293 | + .method(GET).path("/organizations/test-organization-id/usage_summary") |
| 294 | + .build()) |
| 295 | + .response(TestResponse.builder() |
| 296 | + .status(OK) |
| 297 | + .payload("fixtures/client/v3/organizations/GET_{id}_usage_summary_response.json") |
| 298 | + .build()) |
| 299 | + .build()); |
| 300 | + |
| 301 | + this.organizations |
| 302 | + .getUsageSummary(GetOrganizationUsageSummaryRequest.builder() |
| 303 | + .organizationId("test-organization-id") |
| 304 | + .build()) |
| 305 | + .as(StepVerifier::create) |
| 306 | + .expectNext(GetOrganizationUsageSummaryResponse.builder() |
| 307 | + .usageSummary(UsageSummary.builder() |
| 308 | + .startedInstances(3) |
| 309 | + .memoryInMb(50) |
| 310 | + .build()) |
| 311 | + .link("self", Link.builder() |
| 312 | + .href("https://api.example.org/v3/organizations/d4c91047-7b29-4fda-b7f9-04033e5c9c9f/usage_summary") |
| 313 | + .build()) |
| 314 | + .link("organization", Link.builder() |
| 315 | + .href("https://api.example.org/v3/organizations/d4c91047-7b29-4fda-b7f9-04033e5c9c9f") |
| 316 | + .build()) |
| 317 | + .build()) |
| 318 | + .expectComplete() |
| 319 | + .verify(Duration.ofSeconds(5)); |
| 320 | + } |
| 321 | + |
198 | 322 | @Test |
199 | 323 | public void list() { |
200 | 324 | mockRequest(InteractionContext.builder() |
|
0 commit comments