Skip to content

Commit fcc8e8f

Browse files
committed
Merge branch '2.x'
2 parents c656f6a + 6476909 commit fcc8e8f

File tree

14 files changed

+179
-104
lines changed

14 files changed

+179
-104
lines changed

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v2/serviceinstances/_ServiceInstance.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.AllowNulls;
2122
import org.cloudfoundry.Nullable;
2223
import org.immutables.value.Value;
2324

@@ -77,13 +78,14 @@ abstract class _ServiceInstance {
7778
*/
7879
@JsonProperty("shared_from")
7980
@Nullable
80-
abstract String getSharedFrom();
81+
abstract Share getSharedFrom();
8182

8283
/**
8384
* The shared to
8485
*/
86+
@AllowNulls
8587
@JsonProperty("shared_to")
8688
@Nullable
87-
abstract List<String> getSharedTo();
89+
abstract List<Share> getSharedTo();
8890

8991
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2013-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.client.v2.serviceinstances;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.Nullable;
22+
import org.immutables.value.Value;
23+
24+
/**
25+
* The payload for shared (to or from) services
26+
*/
27+
@JsonDeserialize
28+
@Value.Immutable
29+
abstract class _Share {
30+
31+
/**
32+
* The organization name
33+
*/
34+
@JsonProperty("organization_name")
35+
@Nullable
36+
abstract String getOrganizationName();
37+
38+
/**
39+
* The space id
40+
*/
41+
@JsonProperty("space_guid")
42+
@Nullable
43+
abstract String getSpaceId();
44+
45+
/**
46+
* The space name
47+
*/
48+
@JsonProperty("space_name")
49+
@Nullable
50+
abstract String getSpaceName();
51+
52+
}

integration-test/src/test/java/org/cloudfoundry/client/v2/OrganizationsTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ public void listServices() {
13021302
.map(response -> response.getEntity().getLabel())
13031303
.as(StepVerifier::create)
13041304
.expectNext(this.serviceName)
1305+
.expectNext(this.serviceName + "-shareable")
13051306
.expectComplete()
13061307
.verify(Duration.ofMinutes(5));
13071308
}
@@ -1315,6 +1316,7 @@ public void listServicesFilterByActive() {
13151316
.map(response -> response.getEntity().getLabel())
13161317
.as(StepVerifier::create)
13171318
.expectNext(this.serviceName)
1319+
.expectNext(this.serviceName + "-shareable")
13181320
.expectComplete()
13191321
.verify(Duration.ofMinutes(5));
13201322
}
@@ -1340,6 +1342,7 @@ public void listServicesFilterByServiceBrokerId() {
13401342
.map(response -> response.getEntity().getLabel())
13411343
.as(StepVerifier::create)
13421344
.expectNext(this.serviceName)
1345+
.expectNext(this.serviceName + "-shareable")
13431346
.expectComplete()
13441347
.verify(Duration.ofMinutes(5));
13451348
}

integration-test/src/test/java/org/cloudfoundry/client/v2/ServiceInstancesTest.java

Lines changed: 42 additions & 39 deletions
Large diffs are not rendered by default.

integration-test/src/test/java/org/cloudfoundry/client/v2/ServiceKeysTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public final class ServiceKeysTest extends AbstractIntegrationTest {
5151
@Autowired
5252
private Mono<String> serviceBrokerId;
5353

54+
@Autowired
55+
private String serviceName;
56+
5457
@Autowired
5558
private Mono<String> spaceId;
5659

@@ -62,7 +65,7 @@ public void create() {
6265

6366
Mono
6467
.zip(this.serviceBrokerId, this.spaceId)
65-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
68+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
6669
.flatMap(serviceInstanceId -> this.cloudFoundryClient.serviceKeys()
6770
.create(CreateServiceKeyRequest.builder()
6871
.parameter("test-key", "test-value")
@@ -85,7 +88,7 @@ public void delete() {
8588

8689
Mono
8790
.zip(this.serviceBrokerId, this.spaceId)
88-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
91+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
8992
.flatMap(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
9093
.flatMap(serviceKeyId -> this.cloudFoundryClient.serviceKeys()
9194
.delete(DeleteServiceKeyRequest.builder()
@@ -105,7 +108,7 @@ public void get() {
105108

106109
Mono
107110
.zip(this.serviceBrokerId, this.spaceId)
108-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
111+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
109112
.flatMap(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
110113
.flatMap(serviceKeyId -> this.cloudFoundryClient.serviceKeys()
111114
.get(GetServiceKeyRequest.builder()
@@ -125,7 +128,7 @@ public void list() {
125128

126129
Mono
127130
.zip(this.serviceBrokerId, this.spaceId)
128-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
131+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
129132
.flatMap(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
130133
.thenMany(PaginationUtils
131134
.requestClientV2Resources(page -> this.cloudFoundryClient.serviceKeys()
@@ -147,7 +150,7 @@ public void listFilterByName() {
147150

148151
Mono
149152
.zip(this.serviceBrokerId, this.spaceId)
150-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
153+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
151154
.flatMap(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
152155
.thenMany(PaginationUtils
153156
.requestClientV2Resources(page -> this.cloudFoundryClient.serviceKeys()
@@ -169,7 +172,7 @@ public void listFilterByServiceInstanceId() {
169172

170173
Mono
171174
.zip(this.serviceBrokerId, this.spaceId)
172-
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
175+
.flatMap(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
173176
.delayUntil(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
174177
.flatMapMany(serviceInstanceId -> PaginationUtils
175178
.requestClientV2Resources(page -> this.cloudFoundryClient.serviceKeys()
@@ -184,8 +187,8 @@ public void listFilterByServiceInstanceId() {
184187
.verify(Duration.ofMinutes(5));
185188
}
186189

187-
private static Mono<String> createServiceInstanceId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceInstanceName, String spaceId) {
188-
return getPlanId(cloudFoundryClient, serviceBrokerId)
190+
private static Mono<String> createServiceInstanceId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceInstanceName, String serviceName, String spaceId) {
191+
return getPlanId(cloudFoundryClient, serviceBrokerId, serviceName)
189192
.flatMap(planId -> requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName, spaceId))
190193
.map(ResourceUtils::getId);
191194
}
@@ -195,8 +198,8 @@ private static Mono<String> createServiceKeyId(CloudFoundryClient cloudFoundryCl
195198
.map(ResourceUtils::getId);
196199
}
197200

198-
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
199-
return requestListServices(cloudFoundryClient, serviceBrokerId)
201+
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
202+
return requestListServices(cloudFoundryClient, serviceBrokerId, serviceName)
200203
.single()
201204
.map(ResourceUtils::getId)
202205
.flatMapMany(serviceId -> requestListServicePlans(cloudFoundryClient, serviceId))
@@ -244,11 +247,12 @@ private static Flux<ServicePlanResource> requestListServicePlans(CloudFoundryCli
244247
.build()));
245248
}
246249

247-
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
250+
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
248251
return PaginationUtils
249252
.requestClientV2Resources(page -> cloudFoundryClient.services()
250253
.list(ListServicesRequest.builder()
251254
.page(page)
255+
.label(serviceName)
252256
.serviceBrokerId(serviceBrokerId)
253257
.build()));
254258
}

integration-test/src/test/java/org/cloudfoundry/client/v2/ServicePlanVisibilitiesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ private static Mono<String> createSpaceId(CloudFoundryClient cloudFoundryClient,
387387

388388
private static Mono<String> getServicePlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
389389
return requestListServicePlans(cloudFoundryClient, serviceBrokerId)
390+
.filter(resource -> "test-plan-description".equals(ResourceUtils.getEntity(resource).getDescription()))
390391
.map(ResourceUtils::getId)
391392
.single();
392393
}

integration-test/src/test/java/org/cloudfoundry/client/v2/ServicePlansTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ public void listFilterByServiceBrokerId() {
187187
.serviceBrokerId(serviceBrokerId)
188188
.build())))
189189
.map(response -> ResourceUtils.getEntity(response).getName())
190+
.filter(planName -> this.planName.equals(planName))
190191
.as(StepVerifier::create)
191-
.expectNext(this.planName)
192+
.expectNextCount(1)
192193
.expectComplete()
193194
.verify(Duration.ofMinutes(5));
194195
}
@@ -438,6 +439,7 @@ private static Mono<String> getServiceId(CloudFoundryClient cloudFoundryClient,
438439

439440
private static Mono<String> getServicePlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
440441
return requestListServicePlans(cloudFoundryClient, serviceBrokerId)
442+
.filter(resource -> "test-plan-description".equals(ResourceUtils.getEntity(resource).getDescription()))
441443
.map(ResourceUtils::getId)
442444
.single();
443445
}

integration-test/src/test/java/org/cloudfoundry/client/v2/ServiceUsageEventsTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import reactor.test.StepVerifier;
3939

4040
import java.time.Duration;
41-
import java.util.concurrent.TimeoutException;
4241

4342
import static org.cloudfoundry.util.tuple.TupleUtils.function;
4443

@@ -50,14 +49,17 @@ public final class ServiceUsageEventsTest extends AbstractIntegrationTest {
5049
@Autowired
5150
private Mono<String> serviceBrokerId;
5251

52+
@Autowired
53+
private String serviceName;
54+
5355
@Autowired
5456
private Mono<String> spaceId;
5557

5658
@Test
5759
public void get() {
5860
Mono
5961
.zip(this.serviceBrokerId, this.spaceId)
60-
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
62+
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
6163
.then(getFirstEvent(this.cloudFoundryClient))
6264
.flatMap(resource -> Mono.zip(
6365
Mono.just(resource)
@@ -78,7 +80,7 @@ public void get() {
7880
public void list() {
7981
Mono
8082
.zip(this.serviceBrokerId, this.spaceId)
81-
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
83+
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
8284
.then(getFirstEvent(this.cloudFoundryClient))
8385
.flatMap(resource -> Mono.zip(
8486
Mono.just(resource),
@@ -98,7 +100,7 @@ public void list() {
98100
public void listAfterServiceUsageEventId() {
99101
Mono
100102
.zip(this.serviceBrokerId, this.spaceId)
101-
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
103+
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
102104
.then(getFirstEvent(this.cloudFoundryClient))
103105
.flatMap(resource -> Mono.zip(
104106
getSecondEvent(this.cloudFoundryClient),
@@ -119,7 +121,7 @@ public void listAfterServiceUsageEventId() {
119121
public void listFilterByServiceId() {
120122
Mono
121123
.zip(this.serviceBrokerId, this.spaceId)
122-
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
124+
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
123125
.then(getFirstEventWithServiceId(this.cloudFoundryClient))
124126
.flatMap(resource -> Mono.zip(
125127
Mono.just(resource),
@@ -140,7 +142,7 @@ public void listFilterByServiceId() {
140142
public void listFilterByServiceInstanceType() {
141143
Mono
142144
.zip(this.serviceBrokerId, this.spaceId)
143-
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
145+
.flatMap(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
144146
.then(getFirstEvent(this.cloudFoundryClient))
145147
.flatMap(resource -> Mono.zip(
146148
Mono.just(resource),
@@ -190,8 +192,8 @@ private static Mono<ServiceUsageEventResource> getFirstEventWithServiceId(CloudF
190192
.next();
191193
}
192194

193-
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
194-
return requestListServices(cloudFoundryClient, serviceBrokerId)
195+
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
196+
return requestListServices(cloudFoundryClient, serviceBrokerId, serviceName)
195197
.single()
196198
.map(ResourceUtils::getId)
197199
.flatMapMany(serviceId -> requestListServicePlans(cloudFoundryClient, serviceId))
@@ -231,20 +233,21 @@ private static Flux<ServicePlanResource> requestListServicePlans(CloudFoundryCli
231233
.build()));
232234
}
233235

234-
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
236+
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
235237
return PaginationUtils
236238
.requestClientV2Resources(page -> cloudFoundryClient.services()
237239
.list(ListServicesRequest.builder()
240+
.label(serviceName)
238241
.page(page)
239242
.serviceBrokerId(serviceBrokerId)
240243
.build()));
241244
}
242245

243-
private static Mono<Void> seedEvents(CloudFoundryClient cloudFoundryClient, NameFactory nameFactory, String serviceBrokerId, String spaceId) {
246+
private static Mono<Void> seedEvents(CloudFoundryClient cloudFoundryClient, NameFactory nameFactory, String serviceBrokerId, String serviceName, String spaceId) {
244247
String serviceInstanceName1 = nameFactory.getServiceInstanceName();
245248
String serviceInstanceName2 = nameFactory.getServiceInstanceName();
246249

247-
return getPlanId(cloudFoundryClient, serviceBrokerId)
250+
return getPlanId(cloudFoundryClient, serviceBrokerId, serviceName)
248251
.flatMap(planId -> requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName1, spaceId)
249252
.then(requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName2, spaceId)))
250253
.then();

0 commit comments

Comments
 (0)