diff options
author | Michael Lando <ml636r@att.com> | 2017-07-17 21:12:03 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-07-17 21:12:03 +0300 |
commit | 75aacbbe1acf78fa53378f07f0a8c7769449a17e (patch) | |
tree | 68a9799eb8f4704dd9a3d513401df9bb11af7739 /asdc-tests/src/main | |
parent | dec02e7cc74e1c401be51bd9d266575e1e008f5f (diff) |
[SDC] rebase 1710 code
Change-Id: I532ed68979fee7840ea8a5395e7e965b155fb9f9
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'asdc-tests/src/main')
19 files changed, 640 insertions, 90 deletions
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java index 9428a9b695..60c226136d 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java @@ -91,6 +91,7 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { protected ResourceReqDetails resourceDetailsVFC_02; protected ResourceReqDetails resourceDetailsVF_01; protected ResourceReqDetails resourceDetailsVF_02; + protected ResourceReqDetails resourceDetailsPNF_01; protected ResourceReqDetails resourceDetailsCP_01; protected ResourceReqDetails resourceDetailsCP_02; protected ResourceReqDetails resourceDetailsVL_01; @@ -119,6 +120,7 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { resourceDetailsVFC_02 = ElementFactory.getDefaultResourceByType("ciVFC200", NormativeTypesEnum.COMPUTE, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VFC.toString()); resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("ciVF100", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VF.toString()); resourceDetailsVF_02 = ElementFactory.getDefaultResourceByType("ciVF200", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VF.toString()); + resourceDetailsPNF_01 = ElementFactory.getDefaultResourceByType("ciPNF100", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.PNF.toString()); resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("ciCP100", NormativeTypesEnum.PORT, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString()); resourceDetailsCP_02 = ElementFactory.getDefaultResourceByType("ciCP200", NormativeTypesEnum.PORT, ResourceCategoryEnum.GENERIC_DATABASE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString()); resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("ciVL100", NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VL.toString()); @@ -338,9 +340,9 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { Function<? super Entry<String, List<CapabilityDefinition>>, List<CapabilityDefinition>> capabilityDefinitionMapper = e -> new ArrayList<>(e.getValue().stream().map(item -> new CapabilityDefinition(item)).collect(Collectors.toList())); Map<String, List<CapabilityDefinition>> capCopy = resourceCapabilities.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), capabilityDefinitionMapper)); - setupContainerExpectedReqCap(uniqueId, name, resourceRequirements, resourceCapabilities); + setupContainerExpectedReqCap(uniqueId, name, originComponentId, resourceRequirements, resourceCapabilities); if (component.getComponentType().equals(ComponentTypeEnum.RESOURCE) && ((Resource) component).getResourceType() != ResourceTypeEnum.VF) { - setupConstInstExpectedReqCap(uniqueId, name, reqCopy, capCopy); + setupConstInstExpectedReqCap(uniqueId, name, originComponentId, reqCopy, capCopy); } // adding entry for expected componentInstance @@ -348,12 +350,15 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { expectedContInstReqCap.put(uniqueId, compInstReqCapPair); } - private void setupContainerExpectedReqCap(String uniqueId, String name, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { + private void setupContainerExpectedReqCap(String uniqueId, String name, String componentId, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { for (Entry<String, List<RequirementDefinition>> resReq : componentRequirements.entrySet()) { List<RequirementDefinition> reqListToAdd = resReq.getValue(); for (RequirementDefinition requirementDefinition : reqListToAdd) { requirementDefinition.setOwnerId(uniqueId); requirementDefinition.setOwnerName(name); + requirementDefinition.addToPath(uniqueId); + requirementDefinition.setSource(componentId); + requirementDefinition.setLeftOccurrences(requirementDefinition.getMaxOccurrences()); } List<RequirementDefinition> expectedReqList = expectedContainerRequirements.get(resReq.getKey()); if (expectedReqList == null) { @@ -369,6 +374,9 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { for (CapabilityDefinition capDefinition : capListToAdd) { capDefinition.setOwnerId(uniqueId); capDefinition.setOwnerName(name); + capDefinition.addToPath(uniqueId); + capDefinition.setSource(componentId); + capDefinition.setLeftOccurrences(capDefinition.getMaxOccurrences()); } List<CapabilityDefinition> expectedCapList = expectedContainerCapabilities.get(resCap.getKey()); if (expectedCapList == null) { @@ -380,12 +388,15 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { } } - private void setupConstInstExpectedReqCap(String uniqueId, String name, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { + private void setupConstInstExpectedReqCap(String uniqueId, String name, String componentId, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { for (Entry<String, List<RequirementDefinition>> resReq : componentRequirements.entrySet()) { List<RequirementDefinition> reqListToAdd = resReq.getValue(); for (RequirementDefinition requirementDefinition : reqListToAdd) { requirementDefinition.setOwnerId(uniqueId); requirementDefinition.setOwnerName(name); + requirementDefinition.addToPath(uniqueId); + requirementDefinition.setSource(componentId); + requirementDefinition.setLeftOccurrences(requirementDefinition.getMaxOccurrences()); } } @@ -394,6 +405,8 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { for (CapabilityDefinition capDefinition : capListToAdd) { capDefinition.setOwnerId(uniqueId); capDefinition.setOwnerName(name); + capDefinition.addToPath(uniqueId); + capDefinition.setSource(componentId); } } } @@ -570,6 +583,31 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { return component; } + protected Component getComponentAndValidateRIsOnly(ComponentReqDetails componentDetails, int numberOfRIs, int numberOfRelations) throws IOException, Exception { + + RestResponse getResponse = null; + Component component = null; + if (componentDetails instanceof ResourceReqDetails) { + getResponse = ResourceRestUtils.getResource(sdncAdminDetails, componentDetails.getUniqueId()); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Resource.class); + } else if (componentDetails instanceof ServiceReqDetails) { + getResponse = ServiceRestUtils.getService((ServiceReqDetails) componentDetails, sdncAdminDetails); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Service.class); + } else if (componentDetails instanceof ProductReqDetails) { + getResponse = ProductRestUtils.getProduct(componentDetails.getUniqueId(), sdncAdminDetails.getUserId()); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Product.class); + } else { + Assert.fail("Unsupported type of componentDetails - " + componentDetails.getClass().getSimpleName()); + } + ResourceRestUtils.checkSuccess(getResponse); + int numberOfActualRIs = component.getComponentInstances() != null ? component.getComponentInstances().size() : 0; + int numberOfActualRelations = component.getComponentInstancesRelations() != null ? component.getComponentInstancesRelations().size() : 0; + assertEquals("Check number of RIs meet the expected number", numberOfRIs, numberOfActualRIs); + assertEquals("Check number of RI relations meet the expected number", numberOfRelations, numberOfActualRelations); + + return component; + } + protected void getComponentAndValidateRIsAfterChangeLifecycleState(String oldComponentUniqueIdToReplace, ComponentReqDetails componentDetails, int numOfRIs, int numOfRelations) throws IOException, Exception { updateExpectedReqCapAfterChangeLifecycleState(oldComponentUniqueIdToReplace, componentDetails.getUniqueId()); getComponentAndValidateRIs(componentDetails, numOfRIs, numOfRelations); @@ -612,6 +650,10 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest { ResourceRestUtils.checkCreateResponse(createVfResponse); } + protected void createPNF(ResourceReqDetails resourceDetails) throws Exception { + createVF(resourceDetails, sdncDesignerDetails); + } + protected void createService(ServiceReqDetails serviceDetails) throws Exception { createService(serviceDetails, sdncDesignerDetails); } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java index 0e1c0e4da1..3e4411b06e 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java @@ -45,6 +45,8 @@ public interface Urls { final String GET_SERVICE_lATEST_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/services/latestversion/notabstract"; + final String GET_RESOURCE_METADATA_lATEST_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/resources/latestversion/notabstract/metadata"; + // Get resource artifact list: // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts final String GET_RESOURCE_ARTIFACTS_LIST = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts"; @@ -186,35 +188,35 @@ public interface Urls { // ***********************************External API's // (AssetData)**************************************** - final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/artifacts/%s"; - final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/artifacts/%s"; - final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/artifacts"; - final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/asdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts"; + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts"; + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts"; - final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET = "http://%s:%s/asdc/v1/catalog/resources/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET = "http://%s:%s/asdc/v1/catalog/services/%s/artifacts/%s"; + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/resources/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; - final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/asdc/v1/catalog/resources/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/asdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/sdc/v1/catalog/resources/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; - final String GET_ASSET_LIST = "http://%s:%s/asdc/v1/catalog/%s"; - final String GET_FILTERED_ASSET_LIST = "http://%s:%s/asdc/v1/catalog/%s?%s"; - final String GET_TOSCA_MODEL = "http://%s:%s/asdc/v1/catalog/%s/%s/toscaModel"; - // https://{serverRoot}/asdc/v1/catalog/{assetType}/{uuid}/metadata, where + final String GET_ASSET_LIST = "http://%s:%s/sdc/v1/catalog/%s"; + final String GET_FILTERED_ASSET_LIST = "http://%s:%s/sdc/v1/catalog/%s?%s"; + final String GET_TOSCA_MODEL = "http://%s:%s/sdc/v1/catalog/%s/%s/toscaModel"; + // https://{serverRoot}/sdc/v1/catalog/{assetType}/{uuid}/metadata, where // assetType in {resources, services} - final String GET_ASSET_METADATA = "http://%s:%s/asdc/v1/catalog/%s/%s/metadata"; + final String GET_ASSET_METADATA = "http://%s:%s/sdc/v1/catalog/%s/%s/metadata"; final String POST_AUTHORIZATION = "http://%s:%s/sdc2/rest/v1/consumers"; - final String GET_DOWNLOAD_SERVICE_RI_ARTIFACT = "http://%s:%s/asdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT = "http://%s:%s/asdc/v1/catalog/services/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_RI_ARTIFACT = "http://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT = "http://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; - final String POST_EXTERNAL_API_CREATE_RESOURCE = "http://%s:%s/asdc/v1/catalog/resources"; + final String POST_EXTERNAL_API_CREATE_RESOURCE = "http://%s:%s/sdc/v1/catalog/resources"; - final String CHANGE_RESOURCE_LIFECYCLE_STATE_EXTERNAL_API = "http://%s:%s/asdc/v1/catalog/resources/%s/lifecycleState/%s"; - final String CHANGE_SERVICE_LIFECYCLE_STATE_EXTERNAL_API = "http://%s:%s/asdc/v1/catalog/services/%s/lifecycleState/%s"; + final String CHANGE_RESOURCE_LIFECYCLE_STATE_EXTERNAL_API = "http://%s:%s/sdc/v1/catalog/resources/%s/lifecycleState/%s"; + final String CHANGE_SERVICE_LIFECYCLE_STATE_EXTERNAL_API = "http://%s:%s/sdc/v1/catalog/services/%s/lifecycleState/%s"; // ***************************************************************************************************** @@ -238,8 +240,8 @@ public interface Urls { final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT = "/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s"; // "/sdc2/v1/services/<serviceName>/<0.1>/resources/{resourceName}/{resourceVersion}/artifacts/<opeartion_name>_aaa.hh" final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT = "/sdc2/rest/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; - final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL = "/asdc/v1/catalog/services/%s/%s/artifacts/%s"; - final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL = "/asdc/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; + final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/artifacts/%s"; + final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; final String DOWNLOAD_SERVICE_ARTIFACT_FULL_URL = "http://%s:%s%s"; final String DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL = "http://%s:%s%s"; // ********************************************************************************** diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java index 8456e5b35b..d8bd80115e 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java @@ -29,6 +29,7 @@ public class ResourceReqDetails extends ComponentReqDetails { List<String> derivedFrom; String vendorName; String vendorRelease; + String resourceVendorModelNumber; // Unsettable/unupdatable fields @@ -55,6 +56,7 @@ public class ResourceReqDetails extends ComponentReqDetails { this.derivedFrom = resource.getDerivedFrom(); this.vendorName = resource.getVendorName(); this.vendorRelease = resource.getVendorRelease(); + this.resourceVendorModelNumber = resource.getResourceVendorModelNumber(); this.contactId = resource.getContactId(); this.icon = resource.getIcon(); this.toscaResourceName = resource.getToscaResourceName(); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java index e33183ca94..022caecf41 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java @@ -26,6 +26,9 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.category.CategoryDefinition; public class ServiceReqDetails extends ComponentReqDetails { + + String serviceType; + String serviceRole; public ServiceReqDetails(String serviceName, String category, ArrayList<String> tags, String description, String contactId, String icon) { @@ -35,6 +38,8 @@ public class ServiceReqDetails extends ComponentReqDetails { this.description = description; this.contactId = contactId; this.icon = icon; + this.serviceType = ""; + this.serviceRole = ""; projectCode = "12345"; CategoryDefinition categoryDefinition = new CategoryDefinition(); categoryDefinition.setName(category); @@ -56,6 +61,8 @@ public class ServiceReqDetails extends ComponentReqDetails { this.uniqueId = service.getUniqueId(); this.UUID = service.getUUID(); this.version = service.getVersion(); + this.serviceType = service.getServiceType(); + this.serviceRole = service.getServiceRole(); } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java index 5ec4a86977..e4c89bee94 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java @@ -178,7 +178,7 @@ public class DownloadComponentArt extends ComponentBaseTest { expectedResourceAuditJavaObject.setDesc("OK"); expectedResourceAuditJavaObject.setCONSUMER_ID("ci"); - String resource_url = String.format("/asdc/v1/catalog/resources/%s/artifacts/%s", resourceUUID, artifactUUID); + String resource_url = String.format("/sdc/v1/catalog/resources/%s/artifacts/%s", resourceUUID, artifactUUID); expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); @@ -250,7 +250,7 @@ public class DownloadComponentArt extends ComponentBaseTest { expectedResourceAuditJavaObject.setDesc("OK"); expectedResourceAuditJavaObject.setCONSUMER_ID("ci"); - String resource_url = String.format("/asdc/v1/catalog/services/%s/artifacts/%s", resourceUUID, artifactUUID); + String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceUUID, artifactUUID); expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); @@ -313,7 +313,7 @@ public class DownloadComponentArt extends ComponentBaseTest { expectedResourceAuditJavaObject.setDesc("OK"); expectedResourceAuditJavaObject.setCONSUMER_ID("ci"); - String resource_url = String.format("/asdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceUUID, componentNormalizedName, artifactUUID); + String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceUUID, componentNormalizedName, artifactUUID); expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java index 86641eb2c7..44b781f065 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java @@ -20,26 +20,21 @@ package org.openecomp.sdc.ci.tests.execute.category; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.*; -import org.apache.log4j.lf5.util.ResourceUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.junit.Rule; import org.junit.rules.TestName; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -49,9 +44,8 @@ import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -62,6 +56,7 @@ public class CatalogDataApiTest extends ComponentBaseTest { protected Config config = Config.instance(); protected String contentTypeHeaderData = "application/json"; protected String acceptHeaderDate = "application/json"; + protected boolean isInitialized = false; @Rule public static TestName name = new TestName(); @@ -79,28 +74,36 @@ public class CatalogDataApiTest extends ComponentBaseTest { @BeforeMethod public void setUp() throws Exception { + if (isInitialized) + return; user = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); resourceDetails1 = buildResourceDetails(user, "TestResource1"); + resourceDetails1.setResourceType(ResourceTypeEnum.VFCMT.name()); resourceDetails2 = buildResourceDetails(user, "TestResource2"); svcDetails1 = buildServiceDetails("TestService1"); + // VFCMT res1 = createResource(user, resourceDetails1); AssertJUnit.assertEquals("create resorce failed", 201, res1.getErrorCode().intValue()); resourceDetails1.setUniqueId(ResponseParser.getUniqueIdFromResponse(res1)); + resourceDetails2.setVersion(ResponseParser.getVersionFromResponse(res1)); + // VFC res2 = createResource(user, resourceDetails2); AssertJUnit.assertEquals("create resorce failed", 201, res2.getErrorCode().intValue()); resourceDetails2.setUniqueId(ResponseParser.getUniqueIdFromResponse(res2)); resourceDetails2.setVersion(ResponseParser.getVersionFromResponse(res2)); + // SERVICE svc1 = createService(user, svcDetails1); AssertJUnit.assertEquals("create resorce failed", 201, svc1.getErrorCode().intValue()); svcDetails1.setUniqueId(ResponseParser.convertServiceResponseToJavaObject(svc1.getResponse()).getUniqueId()); svcDetails1.setVersion(ResponseParser.convertServiceResponseToJavaObject(svc1.getResponse()).getVersion()); + isInitialized = true; } - @AfterMethod + @AfterClass public void tearDown() throws Exception { deleteResource(resourceDetails1.getUniqueId(), user.getUserId()); deleteResource(resourceDetails2.getUniqueId(), user.getUserId()); @@ -131,6 +134,66 @@ public class CatalogDataApiTest extends ComponentBaseTest { } + @Test + public void getCatalogDataNoVFCMT() throws Exception { + + List<String> excludeTyps = Arrays.asList(OriginTypeEnum.VFCMT.name()); + RestResponse res = CatalogRestUtils.getCatalog(user.getUserId(), excludeTyps); + String json = res.getResponse(); + JSONObject jsonResp = (JSONObject) JSONValue.parse(json); + JSONArray resources = (JSONArray) jsonResp.get("resources"); + JSONArray services = (JSONArray) jsonResp.get("services"); + + // Verify all the expected resources received except of resource1 which is VFCMT + AssertJUnit.assertFalse("check resource1 is in response", + isComponentInArray(resourceDetails1.getUniqueId(), resources)); + AssertJUnit.assertTrue("check resource2 is in response", + isComponentInArray(resourceDetails2.getUniqueId(), resources)); + AssertJUnit.assertTrue("check service1 is in response", + isComponentInArray(svcDetails1.getUniqueId(), services)); + + } + + @Test + public void getCatalogDataNoVFCandVFCMT() throws Exception { + + List<String> excludeTyps = Arrays.asList(OriginTypeEnum.VFCMT.name(), OriginTypeEnum.VFC.name()); + RestResponse res = CatalogRestUtils.getCatalog(user.getUserId(), excludeTyps); + String json = res.getResponse(); + JSONObject jsonResp = (JSONObject) JSONValue.parse(json); + JSONArray resources = (JSONArray) jsonResp.get("resources"); + JSONArray services = (JSONArray) jsonResp.get("services"); + + // Verify all the expected resources received except of VFCMT & VFC + AssertJUnit.assertFalse("check resource1 is in response", + isComponentInArray(resourceDetails1.getUniqueId(), resources)); + AssertJUnit.assertFalse("check resource2 is in response", + isComponentInArray(resourceDetails2.getUniqueId(), resources)); + AssertJUnit.assertTrue("check service1 is in response", + isComponentInArray(svcDetails1.getUniqueId(), services)); + + } + + @Test + public void getCatalogDataNoServiceAndVFC() throws Exception { + + List<String> excludeTyps = Arrays.asList(OriginTypeEnum.SERVICE.name(), OriginTypeEnum.VFC.name()); + RestResponse res = CatalogRestUtils.getCatalog(user.getUserId(), excludeTyps); + String json = res.getResponse(); + JSONObject jsonResp = (JSONObject) JSONValue.parse(json); + JSONArray resources = (JSONArray) jsonResp.get("resources"); + JSONArray services = (JSONArray) jsonResp.get("services"); + + // Verify all the expected resources received except of VFC & SERVICE + AssertJUnit.assertTrue("check resource1 is in response", + isComponentInArray(resourceDetails1.getUniqueId(), resources)); + AssertJUnit.assertFalse("check resource2 is in response", + isComponentInArray(resourceDetails2.getUniqueId(), resources)); + AssertJUnit.assertFalse("check service1 is in response", + isComponentInArray(svcDetails1.getUniqueId(), services)); + + } + protected void deleteResource(String resourceUniqueId, String httpCspUserId) throws Exception { RestResponse deleteResourceResponse = ResourceRestUtils.deleteResource(resourceUniqueId, httpCspUserId); @@ -171,6 +234,7 @@ public class CatalogDataApiTest extends ComponentBaseTest { protected RestResponse createService(User user, ServiceReqDetails svcDetails) throws Exception { + deleteService(svcDetails1.getUniqueId(), user); Config config = Utils.getConfig(); Map<String, String> headersMap = getHeadersMap(user); @@ -189,7 +253,7 @@ public class CatalogDataApiTest extends ComponentBaseTest { Map<String, String> headersMap = new HashMap<String, String>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); - headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId()); + headersMap.put("USER_ID", user.getUserId()); return headersMap; } @@ -210,15 +274,8 @@ public class CatalogDataApiTest extends ComponentBaseTest { } public RestResponse deleteService(String serviceId, User user) throws Exception { - HttpRequest httpRequest = new HttpRequest(); - String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), - serviceId); - - Map<String, String> headersMap = getHeadersMap(user); - RestResponse res = httpRequest.httpSendDelete(url, headersMap); - // System.out.println("Delete service was finished with response: - // "+res.getErrorCode()); - return res; + RestResponse deleteServiceResponse = ResourceRestUtils.deleteResource(serviceId, user.getUserId()); + return deleteServiceResponse; } public class NewObject { diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/CRUDExternalAPI.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/CRUDExternalAPI.java index 7e8d5cf8cc..4a4e5a4529 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/CRUDExternalAPI.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/CRUDExternalAPI.java @@ -435,7 +435,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase()); ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts"); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts"); AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body); return restResponse; @@ -584,13 +584,13 @@ public class CRUDExternalAPI extends ComponentBaseTest { // // if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) { // expectedResourceAuditJavaObject.setResourceName(resourceDetails.getComponentInstances().get(0).getName()); -// String resource_url = String.format("/asdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID()); +// String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID()); // expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); // // AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); // } else { // expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName()); -// String resource_url = String.format("/asdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID()); +// String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID()); // expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); // } // @@ -1092,7 +1092,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString()); if(componentResourceInstanceDetails != null) { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts"); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts"); expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getComponentInstances().get(0).getNormalizedName()); } else { expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName()); @@ -1148,7 +1148,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString()); if(componentResourceInstanceDetails != null) { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts"); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts"); expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getComponentInstances().get(0).getNormalizedName()); } else { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -2354,7 +2354,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString()); if(componentInstance != null) { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getComponentInstances().get(0).getNormalizedName()); } else { expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID); @@ -2511,7 +2511,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails); // expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body); return restResponse; @@ -3151,7 +3151,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString()); if(componentInstance != null) { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + resourceDetails.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getComponentInstances().get(0).getNormalizedName()); } else { expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID); @@ -3248,7 +3248,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails); // expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body); return restResponse; @@ -3314,13 +3314,13 @@ public class CRUDExternalAPI extends ComponentBaseTest { // // if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) { // expectedResourceAuditJavaObject.setResourceName(resourceDetails.getComponentInstances().get(0).getName()); -// String resource_url = String.format("/asdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID()); +// String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID()); // expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); // // AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); // } else { // expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName()); -// String resource_url = String.format("/asdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID()); +// String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID()); // expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); // } // diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/HealthCheckAPI.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/HealthCheckAPI.java new file mode 100644 index 0000000000..cb36619f80 --- /dev/null +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/HealthCheckAPI.java @@ -0,0 +1,68 @@ +package org.openecomp.sdc.ci.tests.execute.devCI; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.junit.Rule; +import org.junit.rules.TestName; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.CommonRestUtils; +import org.openecomp.sdc.common.api.HealthCheckInfo; +import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent; +import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus; +import org.openecomp.sdc.common.api.HealthCheckWrapper; +import org.testng.annotations.Test; + +import com.google.gson.Gson; + +public class HealthCheckAPI extends ComponentBaseTest { + + @Rule + public static TestName name = new TestName(); + + private static final int STATUS_CODE_GET_SUCCESS = 200; + + public HealthCheckAPI() { + super(name, HealthCheckAPI.class.getName()); + } + + @Test + public void checkAmdocsHealthCheckAPI() throws Exception { + RestResponse healthCheckInfoResponse = CommonRestUtils.getHealthCheck(); + BaseRestUtils.checkSuccess(healthCheckInfoResponse); + + Gson gson = new Gson(); + HealthCheckWrapper healthCheckInfo = gson.fromJson(healthCheckInfoResponse.getResponse(), HealthCheckWrapper.class); + assertNotNull("Health check not contains components info", healthCheckInfo.getComponentsInfo()); + HealthCheckInfo amdocsHC = healthCheckInfo.getComponentsInfo().stream().filter(x -> x.getHealthCheckComponent() == HealthCheckInfo.HealthCheckComponent.ON_BOARDING).findFirst().orElse(null); + assertNotNull("Amdocs health check not exists in Health Check info", amdocsHC); + assertEquals("Amdocs health check is down", HealthCheckInfo.HealthCheckStatus.UP, amdocsHC.getHealthCheckStatus()); + assertNotNull("Amdocs additionalInfo not exists in health check", amdocsHC.getComponentsInfo()); + Map<HealthCheckComponent, HealthCheckStatus> amdocsHCComponents = amdocsHC.getComponentsInfo().stream().collect(Collectors.toMap(HealthCheckInfo::getHealthCheckComponent, HealthCheckInfo::getHealthCheckStatus)); + assertNotNull(amdocsHCComponents); + assertTrue("Amdocs health check ZU component is down or not exists", amdocsHCComponents.get(HealthCheckComponent.ZU) != null && amdocsHCComponents.get(HealthCheckComponent.ZU).equals(HealthCheckStatus.UP)); + assertTrue("Amdocs health check BE component is down or not exists", amdocsHCComponents.get(HealthCheckComponent.BE) != null && amdocsHCComponents.get(HealthCheckComponent.BE).equals(HealthCheckStatus.UP)); + assertTrue("Amdocs health check CAS component is down or not exists", amdocsHCComponents.get(HealthCheckComponent.CAS) != null && amdocsHCComponents.get(HealthCheckComponent.CAS).equals(HealthCheckStatus.UP)); + } + + @Test + public void checkCassandraHealthCheck() throws Exception { + RestResponse healthCheckInfoResponse = CommonRestUtils.getHealthCheck(); + BaseRestUtils.checkSuccess(healthCheckInfoResponse); + + Gson gson = new Gson(); + HealthCheckWrapper healthCheckInfo = gson.fromJson(healthCheckInfoResponse.getResponse(), HealthCheckWrapper.class); + assertNotNull("Health check not contains components info", healthCheckInfo.getComponentsInfo()); + HealthCheckInfo cassandraHC = healthCheckInfo.getComponentsInfo().stream().filter(x -> x.getHealthCheckComponent() == HealthCheckInfo.HealthCheckComponent.CASSANDRA).findFirst().orElse(null); + assertNotNull("Cassandra health check not exists in Health Check info", cassandraHC); + assertEquals("Cassandra health check is down", HealthCheckInfo.HealthCheckStatus.UP, cassandraHC.getHealthCheckStatus()); + } + +}
\ No newline at end of file diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java index bc114e22c5..c52ee470cf 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java @@ -163,13 +163,13 @@ public class BasicHttpAuthenticationTest extends ComponentBaseTest { ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(), ValidationUtils.convertToSystemName(resourceDetails.getName()), resourceDetails.getVersion(), ValidationUtils.normalizeFileName(deploymentArtifact.getArtifactName())); - expectedDownloadResourceUrl = expectedDownloadResourceUrl.substring("/asdc/".length(), + expectedDownloadResourceUrl = expectedDownloadResourceUrl.substring("/sdc/".length(), expectedDownloadResourceUrl.length()); expectedDownloadServiceUrl = String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL, ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(), ValidationUtils.normalizeFileName(deploymentArtifact.getArtifactName())); - expectedDownloadServiceUrl = expectedDownloadServiceUrl.substring("/asdc/".length(), + expectedDownloadServiceUrl = expectedDownloadServiceUrl.substring("/sdc/".length(), expectedDownloadServiceUrl.length()); sdncAdminUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java index 16d3fcb092..a58ec18840 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java @@ -43,6 +43,8 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -51,7 +53,9 @@ import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; import org.openecomp.sdc.common.util.YamlToObjectConverter; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; @@ -94,13 +98,18 @@ public class CsarUtilsTest extends ComponentBaseTest { public void createResourceCsarBasicTest() throws Exception { Resource resourceVF = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + resourceVF = (Resource) AtomicOperationUtils .changeComponentState(resourceVF, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); byte[] downloadCSAR = downloadCSAR(sdncModifierDetails, resourceVF); csarBasicValidation(resourceVF, downloadCSAR); + + validateVFCsar(resourceVF, downloadCSAR, 1, 0, 0, 0, 0, 0, 0); + + } @Test(enabled = true) @@ -138,6 +147,7 @@ public class CsarUtilsTest extends ComponentBaseTest { Resource resourceVF1 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); + AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.YANG_XML, resourceVF1, UserRoleEnum.DESIGNER, true, true); AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT_ARTIFACT, resourceVF1, UserRoleEnum.DESIGNER, true, true); @@ -157,7 +167,7 @@ public class CsarUtilsTest extends ComponentBaseTest { public void createResourceCsarInclInformationalArtTest() throws Exception { Resource resourceVF1 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); - + AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.YANG_XML, resourceVF1, UserRoleEnum.DESIGNER, false, true); AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.HEAT, resourceVF1, UserRoleEnum.DESIGNER, false, true); @@ -173,6 +183,59 @@ public class CsarUtilsTest extends ComponentBaseTest { validateVFCsar(resourceVF1, downloadCSAR, 1, 0, 0, 0, 1, 1, 0); } + @Test(enabled = true) + public void createServiceCsarNotMandatoryMetadataFieldsTest() throws Exception { + + Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + service.setServiceType("serviceTypeTest"); + service.setServiceRole("serviceRoleTest"); + ServiceRestUtils.updateService(new ServiceReqDetails(service), sdncModifierDetails); + + Resource resourceVF1 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); + Resource resourceVF2 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); + + resourceVF1 = (Resource) AtomicOperationUtils + .changeComponentState(resourceVF1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + resourceVF2 = (Resource) AtomicOperationUtils + .changeComponentState(resourceVF2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceVF1, service, UserRoleEnum.DESIGNER, true); + AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceVF2, service, UserRoleEnum.DESIGNER, true); + + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + byte[] downloadCSAR = downloadCSAR(sdncModifierDetails, service); + + csarBasicValidation(service, downloadCSAR); + + validateServiceCsar(resourceVF1, resourceVF2, service, downloadCSAR, 3, 3, 0, 0); + } + + @Test(enabled = true) + public void createResourceCsarNotMandatoryMetadataFieldsTest() throws Exception { + + Resource resourceVF = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); + User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + resourceVF.setResourceVendorModelNumber("modelNumberTest"); + ResourceRestUtils.updateResourceMetadata(new ResourceReqDetails(resourceVF), sdncModifierDetails, resourceVF.getUniqueId()); + + resourceVF = (Resource) AtomicOperationUtils + .changeComponentState(resourceVF, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + byte[] downloadCSAR = downloadCSAR(sdncModifierDetails, resourceVF); + + csarBasicValidation(resourceVF, downloadCSAR); + + validateVFCsar(resourceVF, downloadCSAR, 1, 0, 0, 0, 0, 0, 0); + + + } + + private void csarBasicValidation(Component mainComponent, byte[] downloadCSAR) { try (ByteArrayInputStream ins = new ByteArrayInputStream(downloadCSAR); ZipInputStream zip = new ZipInputStream(ins);) { @@ -234,11 +297,12 @@ public class CsarUtilsTest extends ComponentBaseTest { while ((len = zip.read(buffer)) > 0) { sb.append(new String(buffer, 0, len)); } - assertTrue(nextEntry.getName().equals("csar.meta")); - + assertTrue(nextEntry.getName().equals("csar.meta")); readNextEntry(sb, len, buffer, zip); nextEntry = zip.getNextEntry(); assertTrue(nextEntry.getName().equals("TOSCA-Metadata/TOSCA.meta")); + readNextEntry(sb, len, buffer, zip); + YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); @@ -483,15 +547,24 @@ public class CsarUtilsTest extends ComponentBaseTest { String UUID = (String) metadata.get("UUID"); assertNotNull(UUID); - assertEquals("Validate component invariantUUID", component.getUUID(), UUID); + assertEquals("Validate component UUID", component.getUUID(), UUID); String type = (String) metadata.get("type"); assertNotNull(type); if (component.getComponentType().equals(ComponentTypeEnum.SERVICE)) { assertEquals("Validate component type", component.getComponentType().getValue(), type); + String serviceType = (String) metadata.get("serviceType"); + assertNotNull(serviceType); + assertEquals("Validate service type", ((Service )component).getServiceType(), serviceType); + String serviceRole = (String) metadata.get("serviceRole"); + assertNotNull(serviceRole); + assertEquals("Validate service role", ((Service )component).getServiceRole(), serviceRole); } else { assertEquals("Validate component type", ((Resource) component).getResourceType(), ResourceTypeEnum.valueOf(type)); + String resourceVendorModelNumber = (String) metadata.get("resourceVendorModelNumber"); + assertNotNull(resourceVendorModelNumber); + assertEquals("Validate resource vendor model number", ((Resource )component).getResourceVendorModelNumber(), resourceVendorModelNumber); } } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java index 6bf0786a4b..5f0cbaf1c7 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java @@ -156,7 +156,7 @@ public class ExportToscaTest extends ComponentBaseTest { assertNotNull(vfModulesInRes); assertNotNull(groups); - assertEquals("Validate count of vf module instanses", vfModulesInRes.size(), groups.size()); + assertEquals("Validate count of vf module instances", vfModulesInRes.size(), groups.size()); vfModulesInRes.forEach(modInRes -> { validateVfModuleVsInstance(normalizedName, groups, modInRes); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetLeftPaletteTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetLeftPaletteTest.java new file mode 100644 index 0000000000..4ad008633a --- /dev/null +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetLeftPaletteTest.java @@ -0,0 +1,193 @@ +package org.openecomp.sdc.ci.tests.execute.resource; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.junit.rules.TestName; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.Arrays; + +import static org.testng.AssertJUnit.assertTrue; + +/** + * Created by chaya on 6/15/2017. + */ +public class GetLeftPaletteTest extends ComponentBaseTest { + + private static Logger logger = LoggerFactory.getLogger(GetLeftPaletteTest.class.getName()); + protected User designerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + protected ResourceReqDetails vlResourceDetails; + protected ResourceReqDetails cpResourceDetails; + protected ResourceReqDetails vfcResourceDetails; + protected ResourceReqDetails vfcmtResourceDetails; + protected ResourceReqDetails vfResourceDetails; + + + public static TestName name = new TestName(); + + public GetLeftPaletteTest() { + super(name, GetLeftPaletteTest.class.getName()); + } + + @BeforeClass + public void setUp() throws Exception { + // create VL + vlResourceDetails = createResource(vlResourceDetails, "vlRes", ResourceTypeEnum.VL); + checkInResource(vlResourceDetails); + + // create CP + cpResourceDetails = createResource(cpResourceDetails, "cpRes", ResourceTypeEnum.CP); + checkInResource(cpResourceDetails); + + // create VFC + vfcResourceDetails = createResource(vfcResourceDetails, "vfcRes", ResourceTypeEnum.VFC); + checkInResource(vfcResourceDetails); + + // create VFCMT + vfcmtResourceDetails = createResource(vfcmtResourceDetails, "vfcmtRes", ResourceTypeEnum.VFCMT); + checkInResource(vfcmtResourceDetails); + + // create VF + vfResourceDetails = createResource(vfResourceDetails, "vfRes", ResourceTypeEnum.VF); + checkInResource(vfResourceDetails); + } + + + + @Test + public void testGetLeftPaletteForPNF() throws IOException { + + RestResponse getResourceLatestVersionResponse = ResourceRestUtils.getResourceLatestVersionListMetadata(designerDetails, "PNF"); + assertTrue("response code is not 200, returned :" + getResourceLatestVersionResponse.getErrorCode(), + getResourceLatestVersionResponse.getErrorCode() == 200); + + String json = getResourceLatestVersionResponse.getResponse(); + JSONArray jsonResp = (JSONArray) JSONValue.parse(json); + + AssertJUnit.assertTrue("check vlResource is in response", + isComponentInArray(vlResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertTrue("check cpResource is in response", + isComponentInArray(cpResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfcResource is not in response", + isComponentInArray(vfcResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfResource is not in response", + isComponentInArray(vfResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfcmtResource is not in response", + isComponentInArray(vfcmtResourceDetails.getUniqueId(), jsonResp)); + + } + + @Test + public void testGetLeftPaletteForVF() throws IOException { + + RestResponse getResourceLatestVersionResponse = ResourceRestUtils.getResourceLatestVersionListMetadata(designerDetails, "VF"); + assertTrue("response code is not 200, returned :" + getResourceLatestVersionResponse.getErrorCode(), + getResourceLatestVersionResponse.getErrorCode() == 200); + + String json = getResourceLatestVersionResponse.getResponse(); + JSONArray jsonResp = (JSONArray) JSONValue.parse(json); + + AssertJUnit.assertTrue("check vlResource is in response", + isComponentInArray(vlResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertTrue("check cpResource is in response", + isComponentInArray(cpResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertTrue("check vfcResource is not in response", + isComponentInArray(vfcResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfResource is not in response", + isComponentInArray(vfResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfcmtResource is not in response", + isComponentInArray(vfcmtResourceDetails.getUniqueId(), jsonResp)); + + } + + @Test + public void testGetLeftPaletteForService() throws IOException { + + RestResponse getResourceLatestVersionResponse = ResourceRestUtils.getResourceLatestVersionListMetadata(designerDetails, "SERVICE"); + assertTrue("response code is not 200, returned :" + getResourceLatestVersionResponse.getErrorCode(), + getResourceLatestVersionResponse.getErrorCode() == 200); + + String json = getResourceLatestVersionResponse.getResponse(); + JSONArray jsonResp = (JSONArray) JSONValue.parse(json); + + AssertJUnit.assertTrue("check vlResource is in response", + isComponentInArray(vlResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertTrue("check cpResource is in response", + isComponentInArray(cpResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfcResource is not in response", + isComponentInArray(vfcResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertTrue("check vfResource is not in response", + isComponentInArray(vfResourceDetails.getUniqueId(), jsonResp)); + + AssertJUnit.assertFalse("check vfcmtResource is not in response", + isComponentInArray(vfcmtResourceDetails.getUniqueId(), jsonResp)); + + } + + private ResourceReqDetails createResource(ResourceReqDetails resDetails, String name, ResourceTypeEnum resType) throws Exception { + resDetails = new ResourceReqDetails(name, "desc",Arrays.asList(name), "Generic", Arrays.asList("tosca.nodes.Root"), "c", "1", "111", "myIcon", resType.name()); + resDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS.getCategory(), + ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS.getSubCategory()); + RestResponse response = ResourceRestUtils.createResource(resDetails, designerDetails); + assertTrue("response code is not 200, returned :" + response.getErrorCode(), + response.getErrorCode() == 201); + resDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(response)); + return resDetails; + } + + private void checkInResource(ResourceReqDetails resDetails) throws IOException { + RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resDetails, designerDetails, "0.1", + LifeCycleStatesEnum.CHECKIN); + AssertJUnit.assertEquals("check in operation failed", 200, checkInResponse.getErrorCode().intValue()); + + } + + protected boolean isComponentInArray(String id, JSONArray component) { + for (int i = 0; i < component.size(); i++) { + JSONObject jobject = (JSONObject) component.get(i); + if (jobject.get("uniqueId").toString().equals(id.toLowerCase())) { + return true; + } + } + return false; + } + + @AfterClass + public void tearDown() throws IOException { + ResourceRestUtils.deleteResource(vlResourceDetails.getUniqueId(), designerDetails.getUserId()); + ResourceRestUtils.deleteResource(cpResourceDetails.getUniqueId(), designerDetails.getUserId()); + ResourceRestUtils.deleteResource(vfcResourceDetails.getUniqueId(), designerDetails.getUserId()); + ResourceRestUtils.deleteResource(vfcmtResourceDetails.getUniqueId(), designerDetails.getUserId()); + ResourceRestUtils.deleteResource(vfResourceDetails.getUniqueId(), designerDetails.getUserId()); + } +} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java index 149febf05c..2939a8a09e 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java @@ -34,13 +34,7 @@ import org.json.JSONArray; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.CapReqDef; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; @@ -93,10 +87,13 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest createAtomicResource(resourceDetailsVFC_01); createAtomicResource(resourceDetailsVFC_02); createAtomicResource(resourceDetailsCP_01); + LifecycleRestUtils.changeResourceState(resourceDetailsCP_01, sdncAdminDetails, "0.1", + LifeCycleStatesEnum.CHECKIN); createAtomicResource(resourceDetailsVL_01); createAtomicResource(resourceDetailsVL_02); createVF(resourceDetailsVF_01); createVF(resourceDetailsVF_02); + createPNF(resourceDetailsPNF_01); createService(serviceDetails_01); certifyResource(resourceDetailsVFC_01); certifyResource(resourceDetailsVFC_02); @@ -173,6 +170,10 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest return createVFInstance(containerDetails, compInstOriginDetails, modifier); } + private RestResponse createCheckedinPNFInstance(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createCheckedinVFInstance(containerDetails, compInstOriginDetails, modifier); + } + private RestResponse createCheckedinAtomicInstanceForService(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { changeResourceLifecycleState(compInstOriginDetails, compInstOriginDetails.getCreatorUserId(), LifeCycleStatesEnum.CHECKIN); return createAtomicInstanceForService(containerDetails, compInstOriginDetails, modifier); @@ -205,6 +206,16 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest } @Test + public void createPNFInstanceSuccessfullyTest() throws Exception { + RestResponse createPNFInstResp = createCheckedinPNFInstance(serviceDetails_01, resourceDetailsPNF_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createPNFInstResp); + getComponentAndValidateRIs(serviceDetails_01, 1, 0); +// createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_02, sdncDesignerDetails); +// ResourceRestUtils.checkCreateResponse(createVFInstResp); +// getComponentAndValidateRIs(serviceDetails_01, 2, 0); + } + + @Test public void createVFAndAtomicInstanceTest() throws Exception { RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); ResourceRestUtils.checkCreateResponse(createVFInstResp); @@ -218,6 +229,56 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest } @Test + public void createPNFAndAtomicInstanceTest() throws Exception { + RestResponse createPNFInstResp = createCheckedinPNFInstance(serviceDetails_01, resourceDetailsPNF_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createPNFInstResp); + RestResponse createVLInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createVLInstResp); + getComponentAndValidateRIs(serviceDetails_01, 2, 0); + + + } + + private String createCpInstance() throws Exception { + // Create CP instance + RestResponse createAtomicResourceInstance = createAtomicInstanceForVF(resourceDetailsPNF_01, + resourceDetailsCP_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance); + getComponentAndValidateRIs(resourceDetailsPNF_01, 1, 0); + return ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance); + } + + @Test + public void createPNFAndAtomicInstanceAssociatedTest() throws Exception { + reqOwnerId = createCpInstance(); + RestResponse createPNFInstResp = createCheckedinPNFInstance(serviceDetails_01, resourceDetailsPNF_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createPNFInstResp); + String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createPNFInstResp); + RestResponse createVLInstResp = createCheckedinAtomicInstanceForService(serviceDetails_01, resourceDetailsVL_01, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createVLInstResp); + capOwnerId = ResponseParser.getUniqueIdFromResponse(createVLInstResp); + String toCompInstId = ResponseParser.getUniqueIdFromResponse(createVLInstResp); + + String capType = "tosca.capabilities.network.Linkable"; + String reqName = "link"; + + RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01); + ResourceRestUtils.checkSuccess(getResourceResponse); + CapReqDef capReqDef = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), CapReqDef.class); + List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType); + List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType); + + RequirementCapabilityRelDef requirementDef = getReqCapRelation(fromCompInstId, toCompInstId, capType, reqName, capList, reqList); + + associateComponentInstancesForService(requirementDef, serviceDetails_01, sdncDesignerDetails); + getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(sdncDesignerDetails, serviceDetails_01); + capReqDef = ResponseParser.parseToObjectUsingMapper(getResourceResponse.getResponse(), CapReqDef.class); + List<RequirementDefinition> list = capReqDef.getRequirements().get(capType); +// AssertJUnit.assertEquals("Check requirement", null, list); + getComponentAndValidateRIsOnly(serviceDetails_01, 2, 1); + } + + @Test public void deleteAtomicInstanceTest() throws Exception { RestResponse createVFInstResp = createCheckedinVFInstance(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // 1 rel diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java index 85b01e6d2b..6bfa1b8e94 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java @@ -63,7 +63,7 @@ import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; // public class DistributionUtils { - final static String serviceDistributionSuffix = "/asdc/v1/catalog/services/"; + final static String serviceDistributionSuffix = "/sdc/v1/catalog/services/"; public static ServiceDistributionStatus getLatestServiceDistributionObject(Service service) throws IOException, ParseException { ServiceDistributionStatus serviceDistributionStatus = null; @@ -124,13 +124,13 @@ import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; } private static String buildServiceDeploymentUrl(Service service, String artifactName, String artifactUUID) { -// format "/asdc/v1/catalog/services/" + service.getSystemName() + "/" + service.getVersion() + "/artifacts/AAI-" + service.getName() + "-service-1.xml" +// format "/sdc/v1/catalog/services/" + service.getSystemName() + "/" + service.getVersion() + "/artifacts/AAI-" + service.getName() + "-service-1.xml" return serviceDistributionSuffix + service.getSystemName() + "/" + service.getVersion() + "/artifacts/" + artifactName; } public static String buildResourceInstanceDeploymentUrl(Service service, String artifactName, String artifactUUID){ -// /asdc/v1/catalog/services/Servicefordistribution/1.0 /resourceInstances/nestedfrommarina2 /artifacts/FEAdd_On_Module_vProbeLauncher.yaml +// /sdc/v1/catalog/services/Servicefordistribution/1.0 /resourceInstances/nestedfrommarina2 /artifacts/FEAdd_On_Module_vProbeLauncher.yaml String resourceInstanceNormalizedName = getResourceInstanceNormalizeName(service, artifactName, artifactUUID ); return serviceDistributionSuffix + service.getSystemName() + "/" + service.getVersion() + "/resourceInstances/" + resourceInstanceNormalizedName +"/artifacts/" + artifactName; } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java index c06cb570f8..1578b6eba0 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java @@ -689,7 +689,7 @@ public class ElementFactory { ExpectedExternalAudit expectedExternalAudit = new ExpectedExternalAudit(); expectedExternalAudit.setACTION(action.getName()); expectedExternalAudit.setCONSUMER_ID("ci"); - expectedExternalAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetType.getValue() + (query == null ? "" : query)); + expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetType.getValue() + (query == null ? "" : query)); expectedExternalAudit.setSTATUS("200"); expectedExternalAudit.setDESC("OK"); return expectedExternalAudit; @@ -752,7 +752,7 @@ public class ElementFactory { expectedResourceAuditJavaObject.setResourceName(resourceName); expectedResourceAuditJavaObject.setResourceType("Resource"); expectedResourceAuditJavaObject.setCONSUMER_ID("ci"); - expectedResourceAuditJavaObject.setRESOURCE_URL("/asdc/v1/catalog/resources"); + expectedResourceAuditJavaObject.setRESOURCE_URL("/sdc/v1/catalog/resources"); expectedResourceAuditJavaObject.setMODIFIER(""); expectedResourceAuditJavaObject.setPrevVersion(""); expectedResourceAuditJavaObject.setCurrVersion("0.1"); @@ -769,7 +769,7 @@ public class ElementFactory { public static ExpectedExternalAudit getDefaultExternalArtifactAuditSuccess(AssetTypeEnum assetType, AuditingActionEnum action, ArtifactDefinition artifactDefinition, String componentUUID, String resourceInstanceName) { ExpectedExternalAudit expectedExternalArtifactAudit = getDefaultExternalArtifactAuditSuccess(assetType, action, artifactDefinition, componentUUID); - expectedExternalArtifactAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetType.getValue() + "/" + componentUUID + "/resourceInstances/" + resourceInstanceName + "/artifacts"); + expectedExternalArtifactAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetType.getValue() + "/" + componentUUID + "/resourceInstances/" + resourceInstanceName + "/artifacts"); return expectedExternalArtifactAudit; } @@ -794,7 +794,7 @@ public class ElementFactory { String resourceInstanceName) { ExpectedExternalAudit expectedExternalArtifactAudit = getDefaultExternalArtifactAuditFailure(assetType, action, artifactDefinition, componentUUID, errorInfo, variables); - expectedExternalArtifactAudit.setRESOURCE_URL("/asdc/v1/catalog/" + assetType.getValue() + "/" + componentUUID + "/resourceInstances/" + resourceInstanceName + "/artifacts"); + expectedExternalArtifactAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetType.getValue() + "/" + componentUUID + "/resourceInstances/" + resourceInstanceName + "/artifacts"); return expectedExternalArtifactAudit; } diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java index 7272e345ae..5565780dd5 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java @@ -76,10 +76,10 @@ public class AssetRestUtils extends BaseRestUtils { static final String contentTypeHeaderData = "application/json"; static final String acceptHeaderDate = "application/json"; static final String basicAuthentication = "Basic Y2k6MTIzNDU2"; - // /asdc/v1/catalog/{services/resources}/{componentUUID}/artifacts/{artifactUUID} - static final String COMPONENT_ARTIFACT_URL = "/asdc/v1/catalog/%s/%s/artifacts/%s"; - // /asdc/v1/catalog/{services/resources}/{componentUUID}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID} - static final String RESOURCE_INSTANCE_ARTIFACT_URL = "/asdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; + // /sdc/v1/catalog/{services/resources}/{componentUUID}/artifacts/{artifactUUID} + static final String COMPONENT_ARTIFACT_URL = "/sdc/v1/catalog/%s/%s/artifacts/%s"; + // /sdc/v1/catalog/{services/resources}/{componentUUID}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID} + static final String RESOURCE_INSTANCE_ARTIFACT_URL = "/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; public static HttpResponse getComponentToscaModel(AssetTypeEnum assetType, String uuid) throws IOException { Config config = Utils.getConfig(); @@ -338,7 +338,7 @@ public class AssetRestUtils extends BaseRestUtils { // assertNotNull("Expected artifact asset resourceInvariantUUID // is null", // resourceInstanceAssetStructure.getResourceInvariantUUID()); - // String expectedArtifactUrl = "/asdc/v1/catalog/" + + // String expectedArtifactUrl = "/sdc/v1/catalog/" + // assetType.getValue() + "/" + componentUuid + "/artifacts/" + // componentDeploymentArtifactValue.getArtifactUUID(); String expectedArtifactUrl = ""; diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java index a265639804..522a91f7d3 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java @@ -21,8 +21,7 @@ package org.openecomp.sdc.ci.tests.utils.rest; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; @@ -52,6 +51,15 @@ public class CatalogRestUtils extends BaseRestUtils { return sendGet(url, userId); } + public static RestResponse getCatalog(String userId, List<String> excludeList) throws IOException { + Config config = Utils.getConfig(); + String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort()); + StringBuilder sb = new StringBuilder(); + sb.append(url).append("?"); + Optional.ofNullable(excludeList).orElse(Collections.emptyList()).forEach(type -> sb.append("excludeTypes="+type+"&")); + return sendGet(sb.toString(), userId); + } + public static RestResponse getAllCategoriesTowardsCatalogBe() throws IOException { Config config = Utils.getConfig(); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CommonRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CommonRestUtils.java new file mode 100644 index 0000000000..bc807df7fa --- /dev/null +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CommonRestUtils.java @@ -0,0 +1,23 @@ +package org.openecomp.sdc.ci.tests.utils.rest; + +import org.openecomp.sdc.ci.tests.api.Urls; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; + +public class CommonRestUtils extends BaseRestUtils { + + private static Logger logger = LoggerFactory.getLogger(CommonRestUtils.class.getName()); + + public static RestResponse getHealthCheck() throws Exception { + + Config config = Utils.getConfig(); + String url = String.format(Urls.GET_HEALTH_CHECK_VIA_PROXY, config.getCatalogFeHost(), config.getCatalogFePort()); + + return sendGet(url, null); + + } +} diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java index 90371662a7..b17deb3756 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java @@ -254,6 +254,20 @@ public class ResourceRestUtils extends BaseRestUtils { return sendGet(url, sdncModifierDetails.getUserId()); } + public static RestResponse getResourceLatestVersionListMetadata(User sdncModifierDetails, String internalComponentType) throws IOException { + + Config config = Utils.getConfig(); + StringBuilder sb = new StringBuilder(); + String url = String.format(Urls.GET_RESOURCE_METADATA_lATEST_VERSION, config.getCatalogBeHost(), + config.getCatalogBePort()); + sb.append(url); + if (internalComponentType != null && !internalComponentType.isEmpty()) { + sb.append("?internalComponentType="+internalComponentType); + } + return sendGet(sb.toString(), sdncModifierDetails.getUserId()); + + } + public static RestResponse getResourceByNameAndVersion(String userId, String resourceName, String resourceVersion) throws IOException { |