*/
public class Constants {
- public static final String BASE_URL = "/aai/v15";
+ public static final String BASE_URL = "/aai/v{version:\\d+}";
public static final String NODES_URL = BASE_URL + "/nodes";
*/
package org.onap.so.aaisimulator.utils;
-import static org.onap.so.aaisimulator.utils.Constants.BASE_URL;
import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.springframework.http.MediaType.APPLICATION_XML;
import java.net.URI;
import java.util.Arrays;
import java.util.Enumeration;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
*/
public class HttpServiceUtils {
+ private static final String START_WITH_FORWARD_SLASH = "(^/.*?)";
+ private static final String ALPHANUMERIC = "((?:v+[a-z0-9]*)/)";
+ private static final String REGEX = START_WITH_FORWARD_SLASH + ALPHANUMERIC;
+ private static final Pattern PATTERN = Pattern.compile(REGEX, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
+
private HttpServiceUtils() {}
public static URI getBaseUrl(final HttpServletRequest request) {
final StringBuffer url = request.getRequestURL();
final String uri = request.getRequestURI();
- return UriComponentsBuilder.fromHttpUrl(url.substring(0, url.indexOf(uri))).path(BASE_URL).build().toUri();
+ return UriComponentsBuilder.fromHttpUrl(url.substring(0, url.indexOf(uri))).path(getBaseUrl(uri)).build()
+ .toUri();
+ }
+
+ private static String getBaseUrl(final String uri) {
+ final Matcher matcher = PATTERN.matcher(uri);
+ if (matcher.find()) {
+ final StringBuilder builder = new StringBuilder();
+ for (int index = 0; index < matcher.groupCount() - 1; index++) {
+ builder.append(matcher.group(index));
+ }
+ return builder.toString();
+ }
+ return uri;
}
public static URI getBaseUrl(final StringBuffer requestUrl, final String requestUri) {
return getHeaders(request, APPLICATION_XML);
}
- public static HttpHeaders getHeaders(final HttpServletRequest request, MediaType mediaType) {
+ public static HttpHeaders getHeaders(final HttpServletRequest request, final MediaType mediaType) {
final HttpHeaders headers = new HttpHeaders();
for (final Enumeration<String> enumeration = request.getHeaderNames(); enumeration.hasMoreElements();) {
final String headerName = enumeration.nextElement();
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
}
private String getBaseUrl() {
- return "https://localhost:" + port + Constants.BASE_URL;
+ return "https://localhost:" + port + TestConstants.BASE_URL_V17;
}
}
@Test
public void test_putCloudRegion_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
@Test
public void test_getCloudRegionWithDepthValue_shouldReturnMatchedCloudRegion() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
@Test
public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- final String relationShipUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
+ final String relationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
@Test
public void test_putTenant_successfullyAddedToCache() throws Exception {
- final String cloudRegionUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
- final String tenantUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
+ final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
addTenantAndAssertResponse(tenantUrl);
final ResponseEntity<Tenant> response = testRestTemplateService.invokeHttpGet(tenantUrl, Tenant.class);
addCustomerServiceAndGenericVnf();
- final String cloudRegionUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
- final String tenantUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, TENANTS_TENANT + TENANT_ID);
+ final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
+ TENANTS_TENANT + TENANT_ID);
addTenantAndAssertResponse(tenantUrl);
- final String tenantRelationShipUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
- TENANTS_TENANT + TENANT_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
+ final String tenantRelationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME, TENANTS_TENANT + TENANT_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> tenantRelationShipResponse = testRestTemplateService
.invokeHttpPut(tenantRelationShipUrl, TestUtils.getGenericVnfRelatedLink(), Void.class);
@Test
public void test_putEsrSystemInfo_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- final String esrSystemInfoListUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, ESR_SYSTEM_INFO_LIST_URL);
+ final String esrSystemInfoListUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME, ESR_SYSTEM_INFO_LIST_URL);
final String esrSystemInfoUrl = esrSystemInfoListUrl + "/esr-system-info/" + ESR_SYSTEM_INFO_ID;
final ResponseEntity<Void> esrSystemInfoResponse =
@Test
public void test_putVServer_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
addCustomerServiceAndGenericVnf();
@Test
public void test_deleteVServer_successfullyRemoveFromCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
addCustomerServiceAndGenericVnf();
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_PASSWORD;
import org.onap.so.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
addEsrVnfmAndAssertResponse(esrVnfmUrl);
- final String esrVnfmListUrl = getUrl(EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL);
+ final String esrVnfmListUrl = getUrl(TestConstants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL);
final ResponseEntity<EsrVnfmList> response =
testRestTemplateService.invokeHttpGet(esrVnfmListUrl, EsrVnfmList.class);
import org.onap.so.aaisimulator.service.providers.LinesOfBusinessCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.PlatformCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
public void test_putGenericVnfRelationToPlatform_successfullyAddedToCache() throws Exception {
addCustomerServiceAndGenericVnf();
- final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final String platformUrl = getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME);
final ResponseEntity<Void> platformResponse =
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
assertEquals(Constants.USES, relationship.getRelationshipLabel());
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
- assertEquals(Constants.PLATFORMS_URL + PLATFORM_NAME, relationship.getRelatedLink());
+ assertEquals(TestConstants.PLATFORMS_URL + PLATFORM_NAME, relationship.getRelatedLink());
final List<RelationshipData> relationshipData = relationship.getRelationshipData();
public void test_putGenericVnfRelationToLineOfBusiness_successfullyAddedToCache() throws Exception {
addCustomerServiceAndGenericVnf();
- final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final String url = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
final ResponseEntity<Void> responseEntity =
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
final Relationship relationship = relationshipList.getRelationship().get(0);
assertEquals(Constants.USES, relationship.getRelationshipLabel());
- assertEquals(Constants.LINES_OF_BUSINESS_URL + LINE_OF_BUSINESS_NAME, relationship.getRelatedLink());
+ assertEquals(TestConstants.LINES_OF_BUSINESS_URL + LINE_OF_BUSINESS_NAME, relationship.getRelatedLink());
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
public void test_putGenericVnfRelationToCloudRegion_successfullyAddedToCache() throws Exception {
addCustomerServiceAndGenericVnf();
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
final ResponseEntity<Void> responseEntity =
testRestTemplateService.invokeHttpPut(url, TestUtils.getCloudRegion(), Void.class);
final Relationship relationship = relationshipList.getRelationship().get(0);
assertEquals(Constants.LOCATED_IN, relationship.getRelationshipLabel());
- assertEquals(Constants.CLOUD_REGIONS + CLOUD_OWNER_NAME + "/" + CLOUD_REGION_NAME,
+ assertEquals(TestConstants.CLOUD_REGIONS + CLOUD_OWNER_NAME + "/" + CLOUD_REGION_NAME,
relationship.getRelatedLink());
assertFalse(relationship.getRelationshipData().isEmpty());
addCustomerServiceAndGenericVnf();
final String selfLink = "http://localhost:9921/generic-vnf/" + VNF_ID;
- final String url = getUrl(Constants.GENERIC_VNFS_URL) + "?selflink=" + selfLink;
+ final String url = getUrl(TestConstants.GENERIC_VNFS_URL_1) + "?selflink=" + selfLink;
final ResponseEntity<GenericVnfs> response = testRestTemplateService.invokeHttpGet(url, GenericVnfs.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
@Test
public void test_putLineOfBusiness_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final String url = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
final ResponseEntity<Void> lineOfBusinessResponse =
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, lineOfBusinessResponse.getStatusCode());
@Test
public void test_getLineOfBusinessWithFormatCount() throws Exception {
- final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final String url = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
final ResponseEntity<Void> lineOfBusinessResponse =
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, lineOfBusinessResponse.getStatusCode());
@Test
public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final String url = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
final ResponseEntity<Void> response =
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final String relationShipUrl =
- getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
+ final String relationShipUrl = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME,
+ BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
TestUtils.getGenericVnfRelationShip(), Relationship.class);
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.so.aaisimulator.utils.Constants.NODES_URL;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_LINK;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_TYPE;
import static org.onap.so.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
-import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
invokeCustomerandServiceInstanceUrls();
final ResponseEntity<ServiceInstance> actual = testRestTemplateService
- .invokeHttpGet(getUrl(Constants.NODES_URL, SERVICE_INSTANCE_URL), ServiceInstance.class);
+ .invokeHttpGet(getUrl(TestConstants.NODES_URL, SERVICE_INSTANCE_URL), ServiceInstance.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
invokeCustomerandServiceInstanceUrls();
final ResponseEntity<Results> actual = testRestTemplateService.invokeHttpGet(
- getUrl(Constants.NODES_URL, SERVICE_INSTANCE_URL) + "?format=" + Format.PATHED.getValue(),
+ getUrl(TestConstants.NODES_URL, SERVICE_INSTANCE_URL) + "?format=" + Format.PATHED.getValue(),
Results.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
- final String nodeGenericVnfsUrl = getUrl(NODES_URL, GENERIC_VNFS_URL) + "?vnf-name=" + GENERIC_VNF_NAME;
+ final String nodeGenericVnfsUrl =
+ getUrl(TestConstants.NODES_URL, GENERIC_VNFS_URL) + "?vnf-name=" + GENERIC_VNF_NAME;
final ResponseEntity<GenericVnfs> actual =
testRestTemplateService.invokeHttpGet(nodeGenericVnfsUrl, GenericVnfs.class);
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@Test
public void test_putOwningEntity_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
+ final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
@Test
public void test_getOwningEntityCount_correctResult() throws Exception {
- final String url = getUrl(Constants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
+ final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
public void test_putOwningEntityRelationShip_successfullyAddedToCache() throws Exception {
addCustomerAndServiceInstance();
- final String url = getUrl(Constants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
+ final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
assertEquals(1, serviceRelationshipList.size());
final Relationship relationship = serviceRelationshipList.get(0);
assertEquals(Constants.BELONGS_TO, relationship.getRelationshipLabel());
- assertEquals(Constants.OWNING_ENTITY_URL + OWN_ENTITY_ID_VALUE, relationship.getRelatedLink());
+ assertEquals(TestConstants.OWNING_ENTITY_URL + OWN_ENTITY_ID_VALUE, relationship.getRelatedLink());
final List<RelationshipData> serviceRelationshipDataList = serviceRelationshipList.get(0).getRelationshipData();
assertFalse(serviceRelationshipDataList.isEmpty());
@Test
public void test_putPlatform_successfullyAddedToCache() throws Exception {
- final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final String platformUrl = getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME);
final ResponseEntity<Void> platformResponse =
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
@Test
public void test_getPlatformWithFormatCount() throws Exception {
- final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final String platformUrl = getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME);
final ResponseEntity<Void> platformResponse =
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
@Test
public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
- final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final String platformUrl = getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME);
final ResponseEntity<Void> platformResponse =
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
final String platformRelationShipUrl =
- getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
+ getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService
.invokeHttpPut(platformRelationShipUrl, TestUtils.getGenericVnfRelationShip(), Relationship.class);
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestRestTemplateService;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@Test
public void test_putProject_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE);
+ final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
public void test_putProjectRelationShip_successfullyAddedToCache() throws Exception {
addCustomerAndServiceInstance();
- final String url = getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE);
+ final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
final String projectRelationshipUrl =
- getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE, RELATIONSHIP_LIST_RELATIONSHIP_URL);
+ getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> putResponse = testRestTemplateService.invokeHttpPut(projectRelationshipUrl,
TestUtils.getBusinessProjectRelationship(), Void.class);
assertEquals(1, serviceRelationshipList.size());
final Relationship relationship = serviceRelationshipList.get(0);
assertEquals(Constants.USES, relationship.getRelationshipLabel());
- assertEquals(Constants.PROJECT_URL + PROJECT_NAME_VALUE, relationship.getRelatedLink());
+ assertEquals(TestConstants.PROJECT_URL + PROJECT_NAME_VALUE, relationship.getRelatedLink());
final List<RelationshipData> serviceRelationshipDataList = serviceRelationshipList.get(0).getRelationshipData();
@Test
public void test_getProjectCount_correctResult() throws Exception {
- final String url = getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE);
+ final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
*/
package org.onap.so.aaisimulator.utils;
-import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
-import org.onap.so.aaisimulator.utils.Constants;
-
/**
* @author waqas.ikram@ericsson.com
*
*/
public class TestConstants {
+ public static final String BASE_URL_V17 = "/aai/v17";
+
public static final String SERVICE_INSTANCES_URL = "/service-instances";
public static final String SERVICE_NAME = "ServiceTest";
public static final String GLOBAL_CUSTOMER_ID = "DemoCustomer";
- public static final String CUSTOMERS_URL = Constants.CUSTOMER_URL + GLOBAL_CUSTOMER_ID;
+ public static final String CUSTOMERS_URL = BASE_URL_V17 + "/business/customers/customer/" + GLOBAL_CUSTOMER_ID;
public static final String VNF_ID = "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701";
public static final String GENERIC_VNF_NAME = "EsyVnfInstantiationTest2";
- public static final String GENERIC_VNF_URL = Constants.GENERIC_VNFS_URL + "/generic-vnf/";
+ public static final String GENERIC_VNF_URL = BASE_URL_V17 + "/network/generic-vnfs/generic-vnf/";
public static final String GENERIC_VNFS_URL = "/generic-vnfs";
public static final String TENANTS_TENANT = "/tenants/tenant/";
- public static final String ESR_VNFM_URL = EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL + "/esr-vnfm/";
+ public static final String ESR_VNFM_URL = BASE_URL_V17 + "/external-system/esr-vnfm-list/esr-vnfm/";
+
+ public static final String EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL = BASE_URL_V17 + "/external-system/esr-vnfm-list";
public static final String ESR_VNFM_ID = "c5e99cee-1996-4606-b697-838d51d4e1a3";
public static final String VSERVER_ID = "f84fdb9b-ad7c-49db-a08f-e443b4cbd033";
+ public static final String OWNING_ENTITY_URL = BASE_URL_V17 + "/business/owning-entities/owning-entity/";
+
+ public static final String LINES_OF_BUSINESS_URL = BASE_URL_V17 + "/business/lines-of-business/line-of-business/";
+
+ public static final String PLATFORMS_URL = BASE_URL_V17 + "/business/platforms/platform/";
+
+ public static final String CLOUD_REGIONS = BASE_URL_V17 + "/cloud-infrastructure/cloud-regions/cloud-region/";
+
+ public static final String GENERIC_VNFS_URL_1 = BASE_URL_V17 + "/network/generic-vnfs";
+
+ public static final String NODES_URL = BASE_URL_V17 + "/nodes";
+
+ public static final String PROJECT_URL = BASE_URL_V17 + "/business/projects/project/";
+
private TestConstants() {}
}
{
"related-to": "generic-vnf",
"relationship-label": "org.onap.relationships.inventory.Uses",
- "related-link": "/aai/v15/network/generic-vnfs/generic-vnf/dfd02fb5-d7fb-4aac-b3c4-cd6b60058701",
+ "related-link": "/aai/v17/network/generic-vnfs/generic-vnf/dfd02fb5-d7fb-4aac-b3c4-cd6b60058701",
"relationship-data": [{
"relationship-key": "generic-vnf.vnf-id",
"relationship-value": "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701"
${service_instantiation_request}= Post Request api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances data=${data} headers=${headers}
Run Keyword If '${service_instantiation_request.status_code}' == '200' log to console \nexecuted with expected result
log to console ${service_instantiation_request.content}
- ${service_instantiation_json_response}= Evaluate json.loads("""${service_instantiation_request.content}""", strict=False) json
+ ${service_instantiation_json_response}= Evaluate json.loads(r"""${service_instantiation_request.content}""", strict=False) json
${request_ID}= Set Variable ${service_instantiation_json_response}[requestReferences][requestId]
${service_instance_Id}= Set Variable ${service_instantiation_json_response}[requestReferences][instanceId]
SET GLOBAL VARIABLE ${service_instance_Id}
\ ${orchestration_status_request}= Get Request api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
\ Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
\ log to console ${orchestration_status_request.content}
- \ ${orchestration_json_response}= Evaluate json.loads("""${orchestration_status_request.content}""", strict=False) json
+ \ ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""", strict=False) json
\ ${actual_request_state}= SET VARIABLE ${orchestration_json_response}[request][requestStatus][requestState]
\ Log To Console Received actual repsonse status:${actual_request_state}
\ RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
Create Session api_handler_session http://${REPO_IP}:8080
${data}= Get Binary File ${CURDIR}${/}data${/}vnfInstantiationRequest.json
- ${vnf_instantiate_request_json}= evaluate json.loads('''${data}''', strict=False) json
+ ${vnf_instantiate_request_json}= evaluate json.loads(r'''${data}''', strict=False) json
set to dictionary ${vnf_instantiate_request_json}[requestDetails][relatedInstanceList][0][relatedInstance] instanceId=${service_instance_Id}
${vnf_instantiate_request_string}= evaluate json.dumps(${vnf_instantiate_request_json}) json
&{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json
${vnf_instantiate_request}= Post Request api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id}/vnfs data=${vnf_instantiate_request_string} headers=${headers}
Run Keyword If '${vnf_instantiate_request.status_code}' == '200' log to console \nexecuted with expected result
- ${vnf_instantiate_json_response}= Evaluate json.loads("""${vnf_instantiate_request.content}""") json
+ ${vnf_instantiate_json_response}= Evaluate json.loads(r"""${vnf_instantiate_request.content}""") json
${request_ID}= Set Variable ${vnf_instantiate_json_response}[requestReferences][requestId]
${actual_request_state}= SET VARIABLE ""
${vnf_instance_Id}= Set Variable ${vnf_instantiate_json_response}[requestReferences][instanceId]
\ ${orchestration_status_request}= Get Request api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
\ Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
\ Log To Console ${orchestration_status_request.content}
- \ ${orchestration_json_response}= Evaluate json.loads("""${orchestration_status_request.content}""", strict=False) json
+ \ ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""", strict=False) json
\ ${actual_request_state}= SET VARIABLE ${orchestration_json_response}[request][requestStatus][requestState]
\ RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
\ Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
${data}= Get Binary File ${CURDIR}${/}data${/}vnfDeleteRequest.json
&{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json
${vnf_delete_request}= Delete Request api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id}/vnfs/${vnf_instance_Id} data=${data} headers=${headers}
- ${vnf_delete_json_response}= Evaluate json.loads("""${vnf_delete_request.content}""") json
+ ${vnf_delete_json_response}= Evaluate json.loads(r"""${vnf_delete_request.content}""") json
Log to Console ${vnf_delete_json_response}
${request_ID}= Set Variable ${vnf_delete_json_response}[requestReferences][requestId]
${actual_request_state}= Set Variable ""
\ ${orchestration_status_request}= Get Request api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
\ Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
\ Log To Console ${orchestration_status_request.content}
- \ ${orchestration_json_response}= Evaluate json.loads("""${orchestration_status_request.content}""") json
+ \ ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""") json
\ ${actual_request_state}= SET VARIABLE ${orchestration_json_response}[request][requestStatus][requestState]
\ RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
\ Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds
${data}= Get Binary File ${CURDIR}${/}data${/}serviceDeleteRequest.json
&{headers}= Create Dictionary Authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== Content-Type=application/json Accept=application/json
${service_delete_request}= Delete Request api_handler_session /onap/so/infra/serviceInstantiation/v7/serviceInstances/${service_instance_Id} data=${data} headers=${headers}
- ${service_delete_json_response}= Evaluate json.loads("""${service_delete_request.content}""") json
+ ${service_delete_json_response}= Evaluate json.loads(r"""${service_delete_request.content}""") json
Log to Console ${service_delete_json_response}
${request_ID}= Set Variable ${service_delete_json_response}[requestReferences][requestId]
${actual_request_state}= Set Variable ""
\ ${orchestration_status_request}= Get Request api_handler_session /onap/so/infra/orchestrationRequests/v7/${request_ID}
\ Run Keyword If '${orchestration_status_request.status_code}' == '200' log to console \nexecuted with expected result
\ Log To Console ${orchestration_status_request.content}
- \ ${orchestration_json_response}= Evaluate json.loads("""${orchestration_status_request.content}""") json
+ \ ${orchestration_json_response}= Evaluate json.loads(r"""${orchestration_status_request.content}""") json
\ ${actual_request_state}= SET VARIABLE ${orchestration_json_response}[request][requestStatus][requestState]
\ RUN KEYWORD IF '${actual_request_state}' == 'COMPLETE' or '${actual_request_state}' == 'FAILED' Exit For Loop
\ Log To Console Will try again after ${SLEEP_INTERVAL_SEC} seconds