Skip to content

Commit 6476909

Browse files
committed
Merge branch 'fix-ci' into 2.x
2 parents d9063a3 + 11268ef commit 6476909

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
@@ -1274,6 +1274,7 @@ public void listServices() {
12741274
.map(response -> response.getEntity().getLabel())
12751275
.as(StepVerifier::create)
12761276
.expectNext(this.serviceName)
1277+
.expectNext(this.serviceName + "-shareable")
12771278
.expectComplete()
12781279
.verify(Duration.ofMinutes(5));
12791280
}
@@ -1286,6 +1287,7 @@ public void listServicesFilterByActive() {
12861287
.map(response -> response.getEntity().getLabel())
12871288
.as(StepVerifier::create)
12881289
.expectNext(this.serviceName)
1290+
.expectNext(this.serviceName + "-shareable")
12891291
.expectComplete()
12901292
.verify(Duration.ofMinutes(5));
12911293
}
@@ -1309,6 +1311,7 @@ public void listServicesFilterByServiceBrokerId() {
13091311
.map(response -> response.getEntity().getLabel())
13101312
.as(StepVerifier::create)
13111313
.expectNext(this.serviceName)
1314+
.expectNext(this.serviceName + "-shareable")
13121315
.expectComplete()
13131316
.verify(Duration.ofMinutes(5));
13141317
}

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

Lines changed: 42 additions & 40 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

@@ -61,7 +64,7 @@ public void create() {
6164
String serviceKeyName = this.nameFactory.getServiceKeyName();
6265

6366
Mono.when(this.serviceBrokerId, this.spaceId)
64-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
67+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
6568
.then(serviceInstanceId -> this.cloudFoundryClient.serviceKeys()
6669
.create(CreateServiceKeyRequest.builder()
6770
.parameter("test-key", "test-value")
@@ -83,7 +86,7 @@ public void delete() {
8386
String serviceKeyName = this.nameFactory.getServiceKeyName();
8487

8588
Mono.when(this.serviceBrokerId, this.spaceId)
86-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
89+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
8790
.then(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
8891
.then(serviceKeyId -> this.cloudFoundryClient.serviceKeys()
8992
.delete(DeleteServiceKeyRequest.builder()
@@ -102,7 +105,7 @@ public void get() {
102105
String serviceKeyName = this.nameFactory.getServiceKeyName();
103106

104107
Mono.when(this.serviceBrokerId, this.spaceId)
105-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
108+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
106109
.then(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
107110
.then(serviceKeyId -> this.cloudFoundryClient.serviceKeys()
108111
.get(GetServiceKeyRequest.builder()
@@ -121,7 +124,7 @@ public void list() {
121124
String serviceKeyName = this.nameFactory.getServiceKeyName();
122125

123126
Mono.when(this.serviceBrokerId, this.spaceId)
124-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
127+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
125128
.then(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
126129
.thenMany(PaginationUtils
127130
.requestClientV2Resources(page -> this.cloudFoundryClient.serviceKeys()
@@ -142,7 +145,7 @@ public void listFilterByName() {
142145
String serviceKeyName = this.nameFactory.getServiceKeyName();
143146

144147
Mono.when(this.serviceBrokerId, this.spaceId)
145-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
148+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
146149
.then(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName))
147150
.thenMany(PaginationUtils
148151
.requestClientV2Resources(page -> this.cloudFoundryClient.serviceKeys()
@@ -163,7 +166,7 @@ public void listFilterByServiceInstanceId() {
163166
String serviceKeyName = this.nameFactory.getServiceKeyName();
164167

165168
Mono.when(this.serviceBrokerId, this.spaceId)
166-
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, spaceId)))
169+
.then(function((serviceBrokerId, spaceId) -> createServiceInstanceId(this.cloudFoundryClient, serviceBrokerId, serviceInstanceName, this.serviceName, spaceId)))
167170
.then(serviceInstanceId -> createServiceKeyId(this.cloudFoundryClient, serviceInstanceId, serviceKeyName)
168171
.then(Mono.just(serviceInstanceId)))
169172
.flatMapMany(serviceInstanceId -> PaginationUtils
@@ -179,8 +182,8 @@ public void listFilterByServiceInstanceId() {
179182
.verify(Duration.ofMinutes(5));
180183
}
181184

182-
private static Mono<String> createServiceInstanceId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceInstanceName, String spaceId) {
183-
return getPlanId(cloudFoundryClient, serviceBrokerId)
185+
private static Mono<String> createServiceInstanceId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceInstanceName, String serviceName, String spaceId) {
186+
return getPlanId(cloudFoundryClient, serviceBrokerId, serviceName)
184187
.then(planId -> requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName, spaceId))
185188
.map(ResourceUtils::getId);
186189
}
@@ -190,8 +193,8 @@ private static Mono<String> createServiceKeyId(CloudFoundryClient cloudFoundryCl
190193
.map(ResourceUtils::getId);
191194
}
192195

193-
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
194-
return requestListServices(cloudFoundryClient, serviceBrokerId)
196+
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
197+
return requestListServices(cloudFoundryClient, serviceBrokerId, serviceName)
195198
.single()
196199
.map(ResourceUtils::getId)
197200
.flatMapMany(serviceId -> requestListServicePlans(cloudFoundryClient, serviceId))
@@ -239,11 +242,12 @@ private static Flux<ServicePlanResource> requestListServicePlans(CloudFoundryCli
239242
.build()));
240243
}
241244

242-
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
245+
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
243246
return PaginationUtils
244247
.requestClientV2Resources(page -> cloudFoundryClient.services()
245248
.list(ListServicesRequest.builder()
246249
.page(page)
250+
.label(serviceName)
247251
.serviceBrokerId(serviceBrokerId)
248252
.build()));
249253
}

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
@@ -400,6 +400,7 @@ private static Mono<String> createSpaceId(CloudFoundryClient cloudFoundryClient,
400400

401401
private static Mono<String> getServicePlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
402402
return requestListServicePlans(cloudFoundryClient, serviceBrokerId)
403+
.filter(resource -> "test-plan-description".equals(ResourceUtils.getEntity(resource).getDescription()))
403404
.map(ResourceUtils::getId)
404405
.single();
405406
}

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
@@ -188,8 +188,9 @@ public void listFilterByServiceBrokerId() {
188188
.serviceBrokerId(serviceBrokerId)
189189
.build())))
190190
.map(response -> ResourceUtils.getEntity(response).getName())
191+
.filter(planName -> this.planName.equals(planName))
191192
.as(StepVerifier::create)
192-
.expectNext(this.planName)
193+
.expectNextCount(1)
193194
.expectComplete()
194195
.verify(Duration.ofMinutes(5));
195196
}
@@ -450,6 +451,7 @@ private static Mono<String> getServiceId(CloudFoundryClient cloudFoundryClient,
450451

451452
private static Mono<String> getServicePlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
452453
return requestListServicePlans(cloudFoundryClient, serviceBrokerId)
454+
.filter(resource -> "test-plan-description".equals(ResourceUtils.getEntity(resource).getDescription()))
453455
.map(ResourceUtils::getId)
454456
.single();
455457
}

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,13 +49,16 @@ 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.when(this.serviceBrokerId, this.spaceId)
59-
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
61+
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
6062
.then(getFirstEvent(this.cloudFoundryClient))
6163
.then(resource -> Mono.when(
6264
Mono.just(resource)
@@ -76,7 +78,7 @@ public void get() {
7678
@Test
7779
public void list() {
7880
Mono.when(this.serviceBrokerId, this.spaceId)
79-
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
81+
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
8082
.then(getFirstEvent(this.cloudFoundryClient))
8183
.then(resource -> Mono.when(
8284
Mono.just(resource),
@@ -95,7 +97,7 @@ public void list() {
9597
@Test
9698
public void listAfterServiceUsageEventId() {
9799
Mono.when(this.serviceBrokerId, this.spaceId)
98-
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
100+
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
99101
.then(getFirstEvent(this.cloudFoundryClient))
100102
.then(resource -> Mono.when(
101103
getSecondEvent(this.cloudFoundryClient),
@@ -115,7 +117,7 @@ public void listAfterServiceUsageEventId() {
115117
@Test
116118
public void listFilterByServiceId() {
117119
Mono.when(this.serviceBrokerId, this.spaceId)
118-
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
120+
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
119121
.then(getFirstEventWithServiceId(this.cloudFoundryClient))
120122
.then(resource -> Mono.when(
121123
Mono.just(resource),
@@ -135,7 +137,7 @@ public void listFilterByServiceId() {
135137
@Test
136138
public void listFilterByServiceInstanceType() {
137139
Mono.when(this.serviceBrokerId, this.spaceId)
138-
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, spaceId)))
140+
.then(function((serviceBrokerId, spaceId) -> seedEvents(this.cloudFoundryClient, this.nameFactory, serviceBrokerId, this.serviceName, spaceId)))
139141
.then(getFirstEvent(this.cloudFoundryClient))
140142
.then(resource -> Mono.when(
141143
Mono.just(resource),
@@ -185,8 +187,8 @@ private static Mono<ServiceUsageEventResource> getFirstEventWithServiceId(CloudF
185187
.next();
186188
}
187189

188-
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
189-
return requestListServices(cloudFoundryClient, serviceBrokerId)
190+
private static Mono<String> getPlanId(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
191+
return requestListServices(cloudFoundryClient, serviceBrokerId, serviceName)
190192
.single()
191193
.map(ResourceUtils::getId)
192194
.flatMapMany(serviceId -> requestListServicePlans(cloudFoundryClient, serviceId))
@@ -226,20 +228,21 @@ private static Flux<ServicePlanResource> requestListServicePlans(CloudFoundryCli
226228
.build()));
227229
}
228230

229-
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId) {
231+
private static Flux<ServiceResource> requestListServices(CloudFoundryClient cloudFoundryClient, String serviceBrokerId, String serviceName) {
230232
return PaginationUtils
231233
.requestClientV2Resources(page -> cloudFoundryClient.services()
232234
.list(ListServicesRequest.builder()
235+
.label(serviceName)
233236
.page(page)
234237
.serviceBrokerId(serviceBrokerId)
235238
.build()));
236239
}
237240

238-
private static Mono<Void> seedEvents(CloudFoundryClient cloudFoundryClient, NameFactory nameFactory, String serviceBrokerId, String spaceId) {
241+
private static Mono<Void> seedEvents(CloudFoundryClient cloudFoundryClient, NameFactory nameFactory, String serviceBrokerId, String serviceName, String spaceId) {
239242
String serviceInstanceName1 = nameFactory.getServiceInstanceName();
240243
String serviceInstanceName2 = nameFactory.getServiceInstanceName();
241244

242-
return getPlanId(cloudFoundryClient, serviceBrokerId)
245+
return getPlanId(cloudFoundryClient, serviceBrokerId, serviceName)
243246
.then(planId -> requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName1, spaceId)
244247
.then(requestCreateServiceInstance(cloudFoundryClient, planId, serviceInstanceName2, spaceId)))
245248
.then();

0 commit comments

Comments
 (0)