@Test public void test_get_host_by_route_id_should_fail() throws CloudFoundryException { Routes routes = mock(Routes.class); when(cfClient.routes()).thenReturn(routes); Domains domains = mock(Domains.class); when(cfClient.domains()).thenReturn(domains); when(routes.get(any(GetRouteRequest.class))) .thenThrow(new RuntimeException()); verifyThrown(() -> cloudFoundryApi.getHost("route-id"), CloudFoundryException.class); }
@Override public String getHost(String routeId) throws CloudFoundryException { try { log.debug("getHost"); GetRouteResponse response = cfClient.routes() .get(GetRouteRequest.builder() .routeId(routeId) .build()) .block(Config.CF_API_TIMEOUT); RouteEntity routeEntity = Optional.ofNullable(response).get().getEntity(); String route = routeEntity.getHost() + routeEntity.getPath(); log.debug("route = {}", route); String domainId = routeEntity.getDomainId(); String domain = getDeprecatedDomain(domainId); return route + "." + domain; } catch (RuntimeException r) { throw new CloudFoundryException(r); } }
CloudFoundryApi implements CloudFoundryApiService { @Override public String getHost(String routeId) throws CloudFoundryException { try { log.debug("getHost"); GetRouteResponse response = cfClient.routes() .get(GetRouteRequest.builder() .routeId(routeId) .build()) .block(Config.CF_API_TIMEOUT); RouteEntity routeEntity = Optional.ofNullable(response).get().getEntity(); String route = routeEntity.getHost() + routeEntity.getPath(); log.debug("route = {}", route); String domainId = routeEntity.getDomainId(); String domain = getDeprecatedDomain(domainId); return route + "." + domain; } catch (RuntimeException r) { throw new CloudFoundryException(r); } } }
CloudFoundryApi implements CloudFoundryApiService { @Override public String getHost(String routeId) throws CloudFoundryException { try { log.debug("getHost"); GetRouteResponse response = cfClient.routes() .get(GetRouteRequest.builder() .routeId(routeId) .build()) .block(Config.CF_API_TIMEOUT); RouteEntity routeEntity = Optional.ofNullable(response).get().getEntity(); String route = routeEntity.getHost() + routeEntity.getPath(); log.debug("route = {}", route); String domainId = routeEntity.getDomainId(); String domain = getDeprecatedDomain(domainId); return route + "." + domain; } catch (RuntimeException r) { throw new CloudFoundryException(r); } }  }
CloudFoundryApi implements CloudFoundryApiService { @Override public String getHost(String routeId) throws CloudFoundryException { try { log.debug("getHost"); GetRouteResponse response = cfClient.routes() .get(GetRouteRequest.builder() .routeId(routeId) .build()) .block(Config.CF_API_TIMEOUT); RouteEntity routeEntity = Optional.ofNullable(response).get().getEntity(); String route = routeEntity.getHost() + routeEntity.getPath(); log.debug("route = {}", route); String domainId = routeEntity.getDomainId(); String domain = getDeprecatedDomain(domainId); return route + "." + domain; } 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 String getHost(String routeId) throws CloudFoundryException { try { log.debug("getHost"); GetRouteResponse response = cfClient.routes() .get(GetRouteRequest.builder() .routeId(routeId) .build()) .block(Config.CF_API_TIMEOUT); RouteEntity routeEntity = Optional.ofNullable(response).get().getEntity(); String route = routeEntity.getHost() + routeEntity.getPath(); log.debug("route = {}", route); String domainId = routeEntity.getDomainId(); String domain = getDeprecatedDomain(domainId); return route + "." + domain; } 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);  }