OpenStackConfigUtilImpl implements OpenStackConfigUtil { public String getPublicRouterId(String response, String vdc, String publicNetworkId) throws JSONException { JSONObject lRouterString = new JSONObject(response); JSONArray jsonRouters = lRouterString.getJSONArray("routers"); for (int i = 0; i < jsonRouters.length(); i++) { JSONObject jsonNet = jsonRouters.getJSONObject(i); RouterInstance router = isPublicRouter(jsonNet, vdc, publicNetworkId); if (router != null) { log.debug(router.toString()); return router.getIdRouter(); } } return null; } OpenStackConfigUtilImpl(); HttpClientConnectionManager getHttpConnectionManager(); void setHttpConnectionManager(HttpClientConnectionManager httpConnectionManager); String getPublicAdminNetwork(PaasManagerUser user, String region); String getPublicFloatingPool(PaasManagerUser user, String region); NetworkInstance getPublicAdmin(PaasManagerUser user, String region); String getPublicRouter(PaasManagerUser user, String region, String publicNetworkId); String getPublicRouterId(String response, String vdc, String publicNetworkId); OpenStackRegion getOpenStackRegion(); void setOpenStackRegion(OpenStackRegion openStackRegion); void setOpenOperationUtil(OpenOperationUtil openOperationUtil);  }
@Test public void shouldGetPublicRouterId() throws JSONException { String response = "{\"routers\": [{\"status\": \"ACTIVE\", \"external_gateway_info\":" + " {\"network_id\": \"e8892de7-38f9-4002-90f9-eedf0e72f5fc\"}, \"name\": " + "\"router-1137229409\", \"admin_state_up\": false, " + "\"tenant_id\": \"00000000000000000000000000000017\", \"routes\": [], " + "\"id\": \"2fe38e4d-a4cb-4c0a-b1b9-e87e0d147f9c\"}, {\"status\": \"ACTIVE\", " + "\"external_gateway_info\": {\"network_id\": \"e5892de7-38f9-4002-90f9-eedf0e72f5fc\"," + " \"enable_snat\": true}, \"name\": \"ext-rt\", \"admin_state_up\": " + " true, \"tenant_id\": \"00000000000000000000000000000001\", \"routes\": [], \"id\":" + "\"35da5189-03f8-4167-868d-932637d83105\"}]}"; String routerId = openStackUtil.getPublicRouterId(response, "00000000000000000000000000000001", "e5892de7-38f9-4002-90f9-eedf0e72f5fc"); assertEquals(routerId, "35da5189-03f8-4167-868d-932637d83105"); }