@Test public void test_list_routes_of_application_should_succeed() throws CloudFoundryException { ApplicationsV2 applications = mock(ApplicationsV2.class); when(cfClient.applicationsV2()).thenReturn(applications); when(applications.listRoutes(any(ListApplicationRoutesRequest.class))) .thenReturn(Mono.just(ListApplicationRoutesResponse.builder() .resource(RouteResource.builder() .metadata(Metadata.builder() .id("route-id-1") .build()) .entity(RouteEntity.builder().build()) .build()) .resource(RouteResource.builder() .metadata(Metadata.builder() .id("route-id-2") .build()) .entity(RouteEntity.builder().build()) .build()) .build())); List<String> routeIds = cloudFoundryApi.listApplicationRoutes("application-id"); verify(applications, times(1)).listRoutes(any(ListApplicationRoutesRequest.class)); assertNotNull(routeIds); assertEquals(2, routeIds.size()); assertEquals("route-id-1", routeIds.get(0)); assertEquals("route-id-2", routeIds.get(1)); }
@Override public List<String> listApplicationRoutes(String applicationUuid) throws CloudFoundryException { log.debug("listApplicationRoutes"); try { ListApplicationRoutesResponse response = cfClient.applicationsV2() .listRoutes( ListApplicationRoutesRequest.builder() .applicationId(applicationUuid) .build()) .block(Config.CF_API_TIMEOUT); return Optional.ofNullable(response).get().getResources().stream() .map(routeResource -> routeResource.getMetadata().getId()) .collect(Collectors.toList()); } catch (RuntimeException r) { throw new CloudFoundryException(r); } }
CloudFoundryApi implements CloudFoundryApiService { @Override public List<String> listApplicationRoutes(String applicationUuid) throws CloudFoundryException { log.debug("listApplicationRoutes"); try { ListApplicationRoutesResponse response = cfClient.applicationsV2() .listRoutes( ListApplicationRoutesRequest.builder() .applicationId(applicationUuid) .build()) .block(Config.CF_API_TIMEOUT); return Optional.ofNullable(response).get().getResources().stream() .map(routeResource -> routeResource.getMetadata().getId()) .collect(Collectors.toList()); } catch (RuntimeException r) { throw new CloudFoundryException(r); } } }
CloudFoundryApi implements CloudFoundryApiService { @Override public List<String> listApplicationRoutes(String applicationUuid) throws CloudFoundryException { log.debug("listApplicationRoutes"); try { ListApplicationRoutesResponse response = cfClient.applicationsV2() .listRoutes( ListApplicationRoutesRequest.builder() .applicationId(applicationUuid) .build()) .block(Config.CF_API_TIMEOUT); return Optional.ofNullable(response).get().getResources().stream() .map(routeResource -> routeResource.getMetadata().getId()) .collect(Collectors.toList()); } catch (RuntimeException r) { throw new CloudFoundryException(r); } }  }
CloudFoundryApi implements CloudFoundryApiService { @Override public List<String> listApplicationRoutes(String applicationUuid) throws CloudFoundryException { log.debug("listApplicationRoutes"); try { ListApplicationRoutesResponse response = cfClient.applicationsV2() .listRoutes( ListApplicationRoutesRequest.builder() .applicationId(applicationUuid) .build()) .block(Config.CF_API_TIMEOUT); return Optional.ofNullable(response).get().getResources().stream() .map(routeResource -> routeResource.getMetadata().getId()) .collect(Collectors.toList()); } catch (RuntimeException r) { throw new CloudFoundryException(r); } }  @Override void bindApplications(String serviceInstanceId, List<ApplicationIdentity> applications); void bindRoutes(String serviceInstanceId, List<String> routeIds); @Override ApplicationActivity getApplicationActivity(String appUid); Instant getInstantFromLogMessageTimestamp(Long logMessageTimestamp); @Override String getApplicationState(String applicationUuid); @Override String getHost(String routeId); @Override boolean isAppRunning(String appUid); @Override List<ApplicationIdentity> listAliveApplications(String spaceUuid, Pattern excludeNames); @Override List<String> listApplicationRoutes(String applicationUuid); @Override List<String> listRouteApplications(String routeUuid); @Override boolean startApplication(String applicationUuid); @Override boolean stopApplication(String applicationUuid); @Override void unbind(String bindingId); boolean isValidOrganization(String organizationGuid); }
CloudFoundryApi implements CloudFoundryApiService { @Override public List<String> listApplicationRoutes(String applicationUuid) throws CloudFoundryException { log.debug("listApplicationRoutes"); try { ListApplicationRoutesResponse response = cfClient.applicationsV2() .listRoutes( ListApplicationRoutesRequest.builder() .applicationId(applicationUuid) .build()) .block(Config.CF_API_TIMEOUT); return Optional.ofNullable(response).get().getResources().stream() .map(routeResource -> routeResource.getMetadata().getId()) .collect(Collectors.toList()); } catch (RuntimeException r) { throw new CloudFoundryException(r); } }  @Override void bindApplications(String serviceInstanceId, List<ApplicationIdentity> applications); void bindRoutes(String serviceInstanceId, List<String> routeIds); @Override ApplicationActivity getApplicationActivity(String appUid); Instant getInstantFromLogMessageTimestamp(Long logMessageTimestamp); @Override String getApplicationState(String applicationUuid); @Override String getHost(String routeId); @Override boolean isAppRunning(String appUid); @Override List<ApplicationIdentity> listAliveApplications(String spaceUuid, Pattern excludeNames); @Override List<String> listApplicationRoutes(String applicationUuid); @Override List<String> listRouteApplications(String routeUuid); @Override boolean startApplication(String applicationUuid); @Override boolean stopApplication(String applicationUuid); @Override void unbind(String bindingId); boolean isValidOrganization(String organizationGuid);  }