@@ -116,7 +116,7 @@ public void listAfterServiceUsageEventId() {
116116 public void listFilterByServiceId () {
117117 Mono .when (this .serviceBrokerId , this .spaceId )
118118 .then (function ((serviceBrokerId , spaceId ) -> seedEvents (this .cloudFoundryClient , this .nameFactory , serviceBrokerId , spaceId )))
119- .then (getFirstEvent (this .cloudFoundryClient ))
119+ .then (getFirstEventWithServiceId (this .cloudFoundryClient ))
120120 .then (resource -> Mono .when (
121121 Mono .just (resource ),
122122 this .cloudFoundryClient .serviceUsageEvents ()
@@ -179,6 +179,12 @@ private static Mono<ServiceUsageEventResource> getFirstEvent(CloudFoundryClient
179179 .next ();
180180 }
181181
182+ private static Mono <ServiceUsageEventResource > getFirstEventWithServiceId (CloudFoundryClient cloudFoundryClient ) {
183+ return listServiceUsageEvents (cloudFoundryClient )
184+ .filter (resource -> ResourceUtils .getEntity (resource ).getServiceId () != null )
185+ .next ();
186+ }
187+
182188 private static Mono <String > getPlanId (CloudFoundryClient cloudFoundryClient , String serviceBrokerId ) {
183189 return requestListServices (cloudFoundryClient , serviceBrokerId )
184190 .single ()
@@ -198,8 +204,7 @@ private static Flux<ServiceUsageEventResource> listServiceUsageEvents(CloudFound
198204 return cloudFoundryClient .serviceUsageEvents ()
199205 .list (ListServiceUsageEventsRequest .builder ()
200206 .build ())
201- .flatMapMany (ResourceUtils ::getResources )
202- .filter (resource -> ResourceUtils .getEntity (resource ).getServiceId () != null );
207+ .flatMapMany (ResourceUtils ::getResources );
203208 }
204209
205210 private static Mono <CreateServiceInstanceResponse > requestCreateServiceInstance (CloudFoundryClient cloudFoundryClient , String planId , String serviceInstanceName , String spaceId ) {
@@ -235,11 +240,8 @@ private static Mono<Void> seedEvents(CloudFoundryClient cloudFoundryClient, Name
235240 String serviceInstanceName2 = nameFactory .getServiceInstanceName ();
236241
237242 return getPlanId (cloudFoundryClient , serviceBrokerId )
238- .then (planId -> Mono
239- .when (
240- requestCreateServiceInstance (cloudFoundryClient , planId , serviceInstanceName1 , spaceId ),
241- requestCreateServiceInstance (cloudFoundryClient , planId , serviceInstanceName2 , spaceId )
242- ))
243+ .then (planId -> requestCreateServiceInstance (cloudFoundryClient , planId , serviceInstanceName1 , spaceId )
244+ .then (requestCreateServiceInstance (cloudFoundryClient , planId , serviceInstanceName2 , spaceId )))
243245 .then ();
244246 }
245247
0 commit comments