4040import org .cloudfoundry .client .v2 .routes .RouteEntity ;
4141import org .cloudfoundry .client .v2 .routes .RouteExistsRequest ;
4242import org .cloudfoundry .client .v2 .routes .RouteResource ;
43+ import org .cloudfoundry .client .v2 .serviceinstances .GetServiceInstanceRequest ;
44+ import org .cloudfoundry .client .v2 .serviceinstances .GetServiceInstanceResponse ;
45+ import org .cloudfoundry .client .v2 .serviceinstances .ServiceInstanceResource ;
46+ import org .cloudfoundry .client .v2 .serviceinstances .UnionServiceInstanceEntity ;
47+ import org .cloudfoundry .client .v2 .serviceinstances .UnionServiceInstanceResource ;
4348import org .cloudfoundry .client .v2 .shareddomains .ListSharedDomainsRequest ;
4449import org .cloudfoundry .client .v2 .shareddomains .ListSharedDomainsResponse ;
4550import org .cloudfoundry .client .v2 .shareddomains .SharedDomainResource ;
4651import org .cloudfoundry .client .v2 .spaces .ListSpaceApplicationsRequest ;
4752import org .cloudfoundry .client .v2 .spaces .ListSpaceApplicationsResponse ;
4853import org .cloudfoundry .client .v2 .spaces .ListSpaceRoutesRequest ;
4954import org .cloudfoundry .client .v2 .spaces .ListSpaceRoutesResponse ;
55+ import org .cloudfoundry .client .v2 .spaces .ListSpaceServiceInstancesRequest ;
56+ import org .cloudfoundry .client .v2 .spaces .ListSpaceServiceInstancesResponse ;
5057import org .cloudfoundry .client .v2 .spaces .SpaceEntity ;
5158import org .cloudfoundry .client .v2 .spaces .SpaceResource ;
5259import org .cloudfoundry .operations .AbstractOperationsTest ;
@@ -444,19 +451,21 @@ public void listCurrentOrganizationNoSpace() {
444451 requestPrivateDomainsAll (this .cloudFoundryClient , TEST_ORGANIZATION_ID );
445452 requestSharedDomainsAll (this .cloudFoundryClient );
446453 requestSpacesAll (this .cloudFoundryClient , TEST_ORGANIZATION_ID );
454+ requestSpaceServiceInstances (this .cloudFoundryClient , "test-route-entity-serviceInstanceId" , "test-route-entity-spaceId" );
447455 requestApplications (this .cloudFoundryClient , "test-id" );
448456
449457 this .routes
450458 .list (ListRoutesRequest .builder ()
451459 .level (Level .ORGANIZATION )
452460 .build ())
453461 .as (StepVerifier ::create )
454- .expectNext (fill ( Route .builder () )
462+ .expectNext (Route .builder ()
455463 .application ("test-application-name" )
456464 .domain ("test-shared-domain-name" )
457465 .host ("test-route-entity-host" )
458466 .id ("test-id" )
459467 .path ("test-route-entity-path" )
468+ .service ("test-service-instance-entityname" )
460469 .space ("test-space-entity-name" )
461470 .build ())
462471 .expectComplete ()
@@ -493,7 +502,7 @@ public void listCurrentSpace() {
493502 .level (Level .SPACE )
494503 .build ())
495504 .as (StepVerifier ::create )
496- .expectNext (fill ( Route .builder () )
505+ .expectNext (Route .builder ()
497506 .application ("test-application-name" )
498507 .domain ("test-shared-domain-name" )
499508 .host ("test-route-entity-host" )
@@ -505,6 +514,30 @@ public void listCurrentSpace() {
505514 .verify (Duration .ofSeconds (5 ));
506515 }
507516
517+ @ Test
518+ public void listCurrentSpaceNoPath () {
519+ requestSpaceRoutesNoPath (this .cloudFoundryClient , TEST_SPACE_ID );
520+ requestPrivateDomainsAll (this .cloudFoundryClient , TEST_ORGANIZATION_ID );
521+ requestSharedDomainsAll (this .cloudFoundryClient );
522+ requestSpacesAll (this .cloudFoundryClient , TEST_ORGANIZATION_ID );
523+ requestApplications (this .cloudFoundryClient , "test-route-id" );
524+
525+ this .routes
526+ .list (ListRoutesRequest .builder ()
527+ .level (Level .SPACE )
528+ .build ())
529+ .as (StepVerifier ::create )
530+ .expectNext (Route .builder ()
531+ .application ("test-application-name" )
532+ .domain ("test-shared-domain-name" )
533+ .host ("test-route-entity-host" )
534+ .id ("test-route-id" )
535+ .space ("test-space-entity-name" )
536+ .build ())
537+ .expectComplete ()
538+ .verify (Duration .ofSeconds (5 ));
539+ }
540+
508541 @ Test
509542 public void mapRouteAssignedPort () {
510543 requestApplications (this .cloudFoundryClient , "test-application-name" , TEST_SPACE_ID );
@@ -1152,6 +1185,24 @@ private static void requestSpaceRoutesEmpty(CloudFoundryClient cloudFoundryClien
11521185 .build ()));
11531186 }
11541187
1188+ private static void requestSpaceRoutesNoPath (CloudFoundryClient cloudFoundryClient , String spaceId ) {
1189+ when (cloudFoundryClient .spaces ()
1190+ .listRoutes (ListSpaceRoutesRequest .builder ()
1191+ .page (1 )
1192+ .spaceId (spaceId )
1193+ .build ()))
1194+ .thenReturn (Mono
1195+ .just (fill (ListSpaceRoutesResponse .builder ())
1196+ .resource (fill (RouteResource .builder (), "route-" )
1197+ .entity (fill (RouteEntity .builder (), "route-entity-" )
1198+ .domainId ("test-domain-id" )
1199+ .path (null )
1200+ .serviceInstanceId (null )
1201+ .build ())
1202+ .build ())
1203+ .build ()));
1204+ }
1205+
11551206 private static void requestSpaceRoutesService (CloudFoundryClient cloudFoundryClient , String spaceId ) {
11561207 when (cloudFoundryClient .spaces ()
11571208 .listRoutes (ListSpaceRoutesRequest .builder ()
@@ -1169,6 +1220,26 @@ private static void requestSpaceRoutesService(CloudFoundryClient cloudFoundryCli
11691220 .build ()));
11701221 }
11711222
1223+ private static void requestSpaceServiceInstances (CloudFoundryClient cloudFoundryClient , String serviceInstanceId , String spaceId ) {
1224+ when (cloudFoundryClient .spaces ()
1225+ .listServiceInstances (ListSpaceServiceInstancesRequest .builder ()
1226+ .page (1 )
1227+ .returnUserProvidedServiceInstances (true )
1228+ .spaceId (spaceId )
1229+ .build ()))
1230+ .thenReturn (Mono
1231+ .just (fill (ListSpaceServiceInstancesResponse .builder ())
1232+ .resource (fill (UnionServiceInstanceResource .builder (), "service-instance-" )
1233+ .metadata (fill (Metadata .builder (), "service-instance-metadata-" )
1234+ .id (serviceInstanceId )
1235+ .build ())
1236+ .entity (fill (UnionServiceInstanceEntity .builder (), "service-instance-entity" )
1237+ .spaceId (spaceId )
1238+ .build ())
1239+ .build ())
1240+ .build ()));
1241+ }
1242+
11721243 private static void requestSpaces (CloudFoundryClient cloudFoundryClient , String organizationId , String space ) {
11731244 when (cloudFoundryClient .organizations ()
11741245 .listSpaces (ListOrganizationSpacesRequest .builder ()
0 commit comments