OpenStackUtilImpl implements OpenStackUtil { public String getSubNetworkDetails(String subNetworkId, String region, String token, String vdc) throws OpenStackException { HttpUriRequest request = openOperationUtil.createQuantumGetRequest(RESOURCE_SUBNETS + "/" + subNetworkId, APPLICATION_JSON, region, token, vdc); String response; try { response = openOperationUtil.executeNovaRequest(request); } catch (OpenStackException e) { String errorMessage = "Error getting network " + subNetworkId + ": " + e; log.error(errorMessage); throw new OpenStackException(errorMessage); } catch (Exception e) { String errorMessage = "Error getting network " + subNetworkId + " from OpenStack: " + e; log.error(errorMessage); throw new OpenStackException(errorMessage); } return response; } OpenStackUtilImpl(); HttpClientConnectionManager getHttpConnectionManager(); void setHttpConnectionManager(HttpClientConnectionManager httpConnectionManager); String addInterface(String idRouter, NetworkInstance net, String region, String token, String vdc); String addInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); String addRouterInterface(String routerId, String subNetId, String region, String token, String vdc); String allocateFloatingIP(String payload, String region, String token, String vdc); String getFloatingIPs(String region, String token, String vdc, String dd); void disAllocateFloatingIP(String region, String token, String vdc, String floatingIp); String assignFloatingIP(String serverId, String floatingIP, String region, String token, String vdc); String createNetwork(String payload, String region, String token, String vdc); String createRouter(RouterInstance router, String region, String token, String vdc); String createServer(String payload, String region, String token, String vdc); String createSubNet(SubNetworkInstance subNet, String region, String token, String vdc); String deleteNetwork(String networkId, String region, String token, String vdc); String deleteRouter(String routerId, String region, String token, String vdc); String deleteServer(String serverId, String region, String token, String vdc); void deleteSubNetwork(String idSubNet, String region, String vdc, String token); String getFloatingIP(PaasManagerUser user, String region); String getNetworkDetails(String networkId, String region, String token, String vdc); String getSubNetworkDetails(String subNetworkId, String region, String token, String vdc); String getNetworks(String region, String token, String vdc); String getServer(String serverId, String region, String token, String vdc); boolean existsServerForDelete(String serverId, String region, String token, String vdc); String listServers(String region, String token, String vdc); String removeInterface(RouterInstance router, String net, String region, String token, String vdc); String getAbsoluteLimits(PaasManagerUser user, String region); String listNetworks(PaasManagerUser user, String region); String listSubNetworks(PaasManagerUser user, String region); String listPorts(PaasManagerUser user, String region); String deleteInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); OpenStackRegion getOpenStackRegion(); void setOpenStackRegion(OpenStackRegion openStackRegion); void setOpenOperationUtil(OpenOperationUtil openOperationUtil); void setOpenStackConfigUtil(OpenStackConfigUtil openStackConfigUtil); String joinNetworks(NetworkInstance networkInstance, NetworkInstance networkInstance2, String token);  }
@Test public void shouldLoadSubNetwork() throws OpenStackException, IOException { String region = "RegionOne"; SubNetworkInstance subNet = new SubNetworkInstance("SUBNET", "vdc", "region", "CIDR"); subNet.setIdSubNet("ID"); when(openOperationUtil.executeNovaRequest(any(HttpUriRequest.class))).thenReturn("ok"); String response = openStackUtil.getSubNetworkDetails(subNet.getIdSubNet(), region, "token", "vdc"); assertNotNull(response); assertEquals("ok", response); }