summaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general
diff options
context:
space:
mode:
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java405
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java20
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java32
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java29
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java139
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java7
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java50
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java61
10 files changed, 315 insertions, 445 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
index 36fdf06a36..8e5079db92 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,92 +20,58 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-
+import com.aventstack.extentreports.Status;
+import com.google.gson.Gson;
+import fj.data.Either;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.Product;
-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.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.ExtentTestActions;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.DistributionMonitorObject;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
-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.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
-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.*;
+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;
+import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
import org.openecomp.sdc.ci.tests.utils.CsarToscaTester;
import org.openecomp.sdc.ci.tests.utils.DistributionUtils;
+import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
-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.ci.tests.utils.rest.*;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.common.util.GeneralUtility;
import org.testng.SkipException;
-import com.aventstack.extentreports.Status;
-import com.google.gson.Gson;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public final class AtomicOperationUtils {
static final String basicAuthentication = "Basic Y2k6MTIzNDU2";
-
+
private AtomicOperationUtils() {
throw new UnsupportedOperationException();
}
@@ -113,7 +79,7 @@ public final class AtomicOperationUtils {
// *********** RESOURCE ****************
/**
* Import a vfc From tosca file
- *
+ *
* @param filePath
* @param fileName
* @return
@@ -190,7 +156,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
public static Either<Resource, RestResponse> createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum resourceType, NormativeTypesEnum normativeTypes, ResourceCategoryEnum resourceCategory, UserRoleEnum userRole, Boolean validateState)
throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
@@ -247,7 +213,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
// *********** SERVICE ****************
public static Either<Service, RestResponse> createDefaultService(UserRoleEnum userRole, Boolean validateState) throws Exception {
@@ -346,56 +312,61 @@ public final class AtomicOperationUtils {
Boolean isValidationFailed = false;
RestResponse lifeCycleStatesResponse = null;
- User defaultUser = ElementFactory.getDefaultUser(userRole);
+ User defaultUser;
- LifeCycleStatesEnum curentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
+ LifeCycleStatesEnum currentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
- if (curentCompState == targetState) {
+ if (currentCompState == targetState) {
component = getComponentObject(component, userRole);
return Pair.of(component, null);
}
-
+ String componentType = component.getComponentType().getValue();
ArrayList<String> lifeCycleStatesEnumList = new ArrayList<>();
- if (curentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
+ if (currentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+// TODO Andrey added component type condition
} else {
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFICATIONREQUEST.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.STARTCERTIFICATION.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ if (componentType.equals("Resource")) {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ } else {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFICATIONREQUEST.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.STARTCERTIFICATION.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ }
}
for (int i = 0; i < lifeCycleStatesEnumList.size(); i++) {
- if (lifeCycleStatesEnumList.get(i).equals(curentCompState.name())) {
+ if (lifeCycleStatesEnumList.get(i).equals(currentCompState.name())) {
int a;
a = (i == lifeCycleStatesEnumList.size() - 1) ? 0 : i + 1;
-
for (int n = a; n < lifeCycleStatesEnumList.size(); n++) {
- if (lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.STARTCERTIFICATION.name()) || lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.CERTIFY.name())) {
+ if ((lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.STARTCERTIFICATION.name()) || lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.CERTIFY.name())) && !componentType.equals("Resource")) {
defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- } else
+ } else {
defaultUser = ElementFactory.getDefaultUser(userRole);
-
+ }
lifeCycleStatesResponse = LifecycleRestUtils.changeComponentState(component, defaultUser, LifeCycleStatesEnum.findByState(lifeCycleStatesEnumList.get(n)));
if (lifeCycleStatesResponse.getErrorCode() != LifecycleRestUtils.STATUS_CODE_SUCCESS)
isValidationFailed = true;
- if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed == true) {
+ if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed) {
break;
}
}
}
-
}
Component componentJavaObject = getComponentObject(component, userRole);
- if (validateState == true && isValidationFailed == true) {
- assertTrue("change state failed" + lifeCycleStatesResponse.getResponse(), false);
+ if (validateState && isValidationFailed) {
+ assertTrue("change state to [" + targetState.getState() + "] failed" + lifeCycleStatesResponse.getResponse(), false);
return Pair.of(componentJavaObject, lifeCycleStatesResponse);
}
- if (isValidationFailed == true) {
+ if (isValidationFailed) {
return Pair.of(componentJavaObject, lifeCycleStatesResponse);
}
@@ -425,7 +396,7 @@ public final class AtomicOperationUtils {
return distributionService;
}
-
+
public static void toscaValidation(Component component, String vnfFile) throws Exception {
ISdcCsarHelper fdntCsarHelper;
@@ -444,7 +415,7 @@ public final class AtomicOperationUtils {
User defaultUser = ElementFactory.getDefaultUser(userRole);
ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(null, artifactType, deploymentTrue);
- if (deploymentTrue == false)
+ if (!deploymentTrue)
artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType());
RestResponse uploadArtifactResp = ArtifactRestUtils.uploadArtifact(artifactDetails, component, defaultUser);
@@ -462,7 +433,7 @@ public final class AtomicOperationUtils {
// *********** CONTAINERS *****************
/**
* Adds Component instance to Component
- *
+ *
* @param compInstParent
* @param compContainer
* @return
@@ -483,7 +454,7 @@ public final class AtomicOperationUtils {
throw new SkipException("Open bug DE262001");
}
else{
- assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
}
}
@@ -528,86 +499,79 @@ public final class AtomicOperationUtils {
public static Resource getResourceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
// User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- Resource container = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- return container;
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
}
-
+
public static Resource getResourceObject(String uniqueId) throws Exception {
RestResponse restResponse = ResourceRestUtils.getResource(uniqueId);
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- return resource;
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
}
-
+
public static Resource getResourceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String resourceName, String resourceVersion) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
RestResponse resourceResponse = ResourceRestUtils.getResourceByNameAndVersion(defaultUser.getUserId(), resourceName, resourceVersion);
- Resource container = ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
- return container;
+ return ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
}
public static Service getServiceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
-
+
public static Service getServiceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String serviceName, String serviceVersion) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
RestResponse serviceResponse = ServiceRestUtils.getServiceByNameAndVersion(defaultUser, serviceName, serviceVersion);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
-
+
public static Service getServiceObject(String uniqueId) throws Exception {
RestResponse serviceResponse = ServiceRestUtils.getService(uniqueId);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
public static Product getProductObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- Product container = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- return container;
+ return ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
}
public static Component getComponentObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- break;
- case SERVICE:
- RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- break;
- case PRODUCT:
- RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ break;
+ case SERVICE:
+ RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ break;
+ case PRODUCT:
+ RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
+ break;
+ default:
+ break;
}
return containerDetails;
}
- public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) throws Exception {
+ public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) {
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
+ break;
+ default:
+ break;
}
return containerDetails;
}
@@ -624,17 +588,17 @@ public final class AtomicOperationUtils {
if (associate2ResourceInstancesResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ default:
+ break;
}
return Either.left(containerDetails);
@@ -736,10 +700,13 @@ public final class AtomicOperationUtils {
return Either.right(addPropertyResponse);
}
- public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(List<PropertyDataDefinition> propertyObject, Resource resource, String groupId, User user, Boolean validateState) throws Exception {
+ public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(String maxVFModuleInstacesValue, Resource resource, String groupId, User user, Boolean validateState) throws Exception {
- Gson gson = new Gson();
- RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, gson.toJson(propertyObject), user);
+// Gson gson = new Gson();
+ // Json group property object
+ String propertyObjectJson = "[{\"defaultValue\":null,\"description\":\"The maximum instances of this VF-Module\",\"name\":\"max_vf_module_instances\",\"parentUniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\",\"password\":false,\"required\":false,\"schema\":{\"property\":{}},\"type\":\"integer\",\"uniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances.property.3\",\"value\":\"" + maxVFModuleInstacesValue + "\",\"definition\":false,\"getInputValues\":null,\"constraints\":null,\"valueUniqueUid\":null,\"ownerId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\"}]";
+// GroupProperty property = gson.fromJson(propertyObjectJson, GroupProperty.class);
+ RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, propertyObjectJson, user);
if (validateState) {
assertTrue("update group property to resource failed: " + updateGroupPropertyResponse.getResponseMessage(), updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
@@ -770,7 +737,7 @@ public final class AtomicOperationUtils {
/**
* Builds Resource From rest response
- *
+ *
* @param resourceResp
* @return
*/
@@ -792,10 +759,10 @@ public final class AtomicOperationUtils {
private static final long serialVersionUID = 1L;
}
-
+
/**
* Import resource from CSAR
- *
+ *
* @param resourceType
* @param userRole
* @param fileName
@@ -803,32 +770,94 @@ public final class AtomicOperationUtils {
* @return Resource
* @throws Exception
*/
- public static Resource importResourceFromCSAR(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath) throws Exception {
+ public static Resource importResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath) throws Exception {
// Get the CSARs path
String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
if (filePath != null && filePath.length > 0) {
- realFilePath = filePath.toString();
+ StringBuffer result = new StringBuffer();
+ for(String currStr: filePath){
+ result.append(currStr);
+ }
+// realFilePath = Arrays.toString(filePath);
+ realFilePath = result.toString();
}
-
+
// Create default import resource & user
+ return importResourceFromCsarFile(resourceType, userRole, fileName, realFilePath);
+ }
+
+ public static Resource importResourceFromCsarFile(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
+ RestResponse createResource = getCreateResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkCreateResponse(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+
+ public static Resource importCertifiedResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
+ RestResponse createResource = getCreateCertifiedResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkSuccess(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+ public static RestResponse getCreateResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ return createResource;
+ }
+
+ public static RestResponse getCreateCertifiedResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ BaseRestUtils.checkCreateResponse(response);
+ return LCSbaseTest.certifyResource(resourceDetails, sdncModifierDetails);
+ }
+
+ private static ImportReqDetails buildImportReqDetails(ResourceTypeEnum resourceType, String csarFileName, String csarFilePath) throws IOException {
ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
+ byte[] data = Files.readAllBytes(path);
+ String payloadName = csarFileName;
+ String payloadData = Base64.encodeBase64String(data);
+ resourceDetails.setPayloadData(payloadData);
+ resourceDetails.setCsarUUID(payloadName);
+ resourceDetails.setPayloadName(payloadName);
+ resourceDetails.setResourceType(resourceType.name());
+ return resourceDetails;
+ }
+
+ public static Resource updateResourceFromCsar(Resource resource, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
-
+
byte[] data = null;
- Path path = Paths.get(realFilePath + File.separator + fileName);
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
data = Files.readAllBytes(path);
- String payloadName = fileName;
+ String payloadName = csarFileName;
String payloadData = Base64.encodeBase64String(data);
+ ImportReqDetails resourceDetails = new ImportReqDetails(resource, payloadName, payloadData);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setCsarUUID(payloadName);
resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(resourceType.name());
-
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- };
-
+
+ String userId = sdncModifierDetails.getUserId();
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.UPDATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId());
+
+ Map<String, String> headersMap = ResourceRestUtils.prepareHeadersMap(userId);
+
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(resourceDetails);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ RestResponse updateResourceResponse = http.httpSendPut(url, userBodyJson, headersMap);
+ BaseRestUtils.checkSuccess(updateResourceResponse);
+ return ResponseParser.parseToObjectUsingMapper(updateResourceResponse.getResponse(), Resource.class);
+ }
+
public static Either<Resource, RestResponse> importResourceByFileName(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, Boolean validateState, String... filePath) throws IOException {
String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
@@ -838,7 +867,7 @@ public final class AtomicOperationUtils {
try {
User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
ImportReqDetails defaultImportResource = ElementFactory.getDefaultImportResource(defaultResource);
ImportUtils.getImportResourceDetailsByPathAndName(defaultImportResource, realFilePath, fileName);
RestResponse resourceResp = ResourceRestUtils.createResource(defaultImportResource, defaultUser);
@@ -856,7 +885,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
public static Either<String, RestResponse> getComponenetArtifactPayload(Component component, String artifactType) throws Exception {
String url;
@@ -894,14 +923,14 @@ public final class AtomicOperationUtils {
assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
}
return response;
-
+
} catch (Exception e) {
throw new AtomicOperationException(e);
}
}
-
+
public static Either <RestResponse, Map<String, List<DistributionMonitorObject>>> getSortedDistributionStatusMap(Service service, Boolean validateState) {
-
+
try {
ServiceDistributionStatus serviceDistributionObject = DistributionUtils.getLatestServiceDistributionObject(service);
RestResponse response = getDistributionStatusByDistributionId(serviceDistributionObject.getDistributionID(), true);
@@ -916,10 +945,10 @@ public final class AtomicOperationUtils {
} catch (Exception e) {
throw new AtomicOperationException(e);
}
-
+
}
-
-
+
+
/**
* @param service
* @param pollingCount
@@ -928,13 +957,13 @@ public final class AtomicOperationUtils {
* @throws Exception
*/
public static Boolean distributeAndValidateService(Service service, int pollingCount, int pollingInterval) throws Exception {
- int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
+ int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
Boolean statusFlag = true;
AtomicOperationUtils.distributeService(service, true);
TimeUnit.MILLISECONDS.sleep(firstPollingInterval);
int timeOut = pollingCount * pollingInterval;
com.clearspring.analytics.util.Pair<Boolean,Map<String,List<String>>> verifyDistributionStatus = null;
-
+
while (timeOut > 0) {
Map<String,List<DistributionMonitorObject>> sortedDistributionStatusMap = AtomicOperationUtils.getSortedDistributionStatusMap(service, true).right().value();
verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap);
@@ -945,7 +974,7 @@ public final class AtomicOperationUtils {
timeOut = 0;
}
}
-
+
if((verifyDistributionStatus.right != null && ! verifyDistributionStatus.right.isEmpty())){
for(Entry<String, List<String>> entry : verifyDistributionStatus.right.entrySet()){
if(ComponentBaseTest.getExtendTest() != null){
@@ -958,9 +987,33 @@ public final class AtomicOperationUtils {
}
return statusFlag;
}
-
+
public static Boolean distributeAndValidateService(Service service) throws Exception {
return distributeAndValidateService(service, 10, 10000);
}
+
+ /**
+ * @param resource to download csar file via API
+ * @return Tosca definition object from main yaml file
+ */
+ public static ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception {
+ File vfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar");
+ OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + vfCsarFileName));
+ return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + vfCsarFileName));
+ }
+
+
+ public static ComponentInstance getServiceComponentInstanceByName(Service service, String name, Boolean validateState){
+ List<ComponentInstance> compInstances = service.getComponentInstances();
+ for (ComponentInstance instance: compInstances){
+ String compName = instance.getName();
+ if (compName.equals(name))
+ return instance;
+ }
+ if (validateState) {
+ assertEquals("Component instance name " + name + " not found", name, null);
+ }
+ return null;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
index cbae462d80..031d2d8e72 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
@@ -20,24 +20,13 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit;
@@ -46,6 +35,13 @@ import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedUserCRUDAudit;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.api.Constants;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
+
public class Convertor {
// ***** resource *****
public static ResourceRespJavaObject constructFieldsForRespValidation(ResourceReqDetails resourceDetails,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
index d1701241fe..e303682a37 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
@@ -24,6 +24,8 @@ import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -287,26 +289,26 @@ public class ElementFactory {
// *** SERVICE ***
public static ServiceReqDetails getDefaultService() {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, "al1976");
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
}
public static ServiceReqDetails getDefaultService(String contactId) {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, contactId);
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, contactId, ServiceInstantiationType.A_LA_CARTE.getValue());
}
public static ServiceReqDetails getDefaultService(User user) {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, user.getUserId());
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, user.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
}
-
- public static ServiceReqDetails getServiceByCategory(ServiceCategoriesEnum category) {
- return getDefaultService(CI_SERVICE, category, "al1976");
- }
-
+
public static ServiceReqDetails getDefaultService(ServiceCategoriesEnum category, User user) {
- return getDefaultService(CI_SERVICE, category, user.getUserId());
+ return getDefaultService(CI_SERVICE, category, user.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ }
+
+ public static ServiceReqDetails getServiceByCategory(ServiceCategoriesEnum category) {
+ return getDefaultService(CI_SERVICE, category, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
}
- public static ServiceReqDetails getDefaultService(String serviceName, ServiceCategoriesEnum category, String contactId) {
+ public static ServiceReqDetails getDefaultService(String serviceName, ServiceCategoriesEnum category, String contactId, String instantiationType) {
serviceName = (serviceName + generateUUIDforSufix());
ArrayList<String> tags = new ArrayList<>();
tags.add("serviceTag");
@@ -315,7 +317,7 @@ public class ElementFactory {
String description = "service Description";
String icon = "defaulticon";
- ServiceReqDetails serviceDetails = new ServiceReqDetails(serviceName, category.getValue(), tags, description, contactId, icon);
+ ServiceReqDetails serviceDetails = new ServiceReqDetails(serviceName, category.getValue(), tags, description, contactId, icon, instantiationType);
return serviceDetails;
}
@@ -375,7 +377,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getDefaultComponentInstance(String name) {
String resourceUid = "resourceId";
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name, null);
return resourceInstanceDetails;
@@ -383,7 +385,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getDefaultComponentInstance(String name, ComponentReqDetails componentReqDetails) {
String resourceUid = componentReqDetails.getUniqueId();
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name, null);
return resourceInstanceDetails;
@@ -392,7 +394,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getComponentResourceInstance(ComponentReqDetails compInstOriginDetails) {
String compInstName = (compInstOriginDetails.getName() != null ? compInstOriginDetails.getName() : "resourceInstanceName");
String resourceUid = compInstOriginDetails.getUniqueId();
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName, null);
return resourceInstanceDetails;
}
@@ -400,7 +402,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getComponentInstance(Component compInstOriginDetails) {
String compInstName = (compInstOriginDetails.getName() != null ? compInstOriginDetails.getName() : "componentInstanceName");
String compInsUid = compInstOriginDetails.getUniqueId();
- ComponentInstanceReqDetails componentInstanceDetails = new ComponentInstanceReqDetails(compInsUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName);
+ ComponentInstanceReqDetails componentInstanceDetails = new ComponentInstanceReqDetails(compInsUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName, compInstOriginDetails.getComponentType() == ComponentTypeEnum.SERVICE ? OriginTypeEnum.ServiceProxy.name() : null);
return componentInstanceDetails;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
index 7af18dd3b7..72610331d9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
@@ -21,29 +21,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
import com.aventstack.extentreports.Status;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-
import org.apache.commons.io.FileUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -51,7 +28,6 @@ import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.yaml.snakeyaml.Yaml;
-import com.aventstack.extentreports.Status;
import java.io.*;
import java.nio.file.Paths;
import java.util.*;
@@ -342,9 +318,10 @@ public class FileHandling {
File dir = new File(directoryPath);
try {
FileUtils.cleanDirectory(dir);
+ } catch (IllegalArgumentException e) {
+ System.out.println("Failed to clean " + dir);
} catch (IOException e) {
- System.out.println("Failed to delete " + dir);
- ComponentBaseTest.getExtendTest().log(Status.INFO, "Failed to delete " + dir);
+ System.out.println("Failed to clean " + dir);
}
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
index f0ca9dd517..226c734c91 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
+import fj.data.Either;
+import org.openecomp.sdc.ci.tests.utils.Decoder;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -31,12 +35,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.openecomp.sdc.ci.tests.utils.Decoder;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
public class FileUtils {
static Logger logger = LoggerFactory.getLogger(Utils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
index 7e5a7d69a2..3b1dcdac1e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.utils.general;
+import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
+
import java.io.IOException;
import java.util.List;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-
public class ImportUtils {
public static ImportReqDetails getImportResourceDetailsByPathAndName(ImportReqDetails importReqDetails,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
index 5f9ec1bfc8..f9ce645fc7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
@@ -20,23 +20,8 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
import com.google.gson.Gson;
import fj.data.Either;
-
import org.apache.commons.codec.binary.Base64;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.Resource;
@@ -55,61 +40,22 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import com.clearspring.analytics.util.Pair;
-import com.google.gson.Gson;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
public class OnboardingUtillViaApis {
-// protected static Map<String, String> prepareHeadersMap(String userId) {
-// Map<String, String> headersMap = new HashMap<String, String>();
-// headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
-// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
-// headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
-// return headersMap;
-// }
-
- public static Pair<String, VendorSoftwareProductObject> createVspViaApis(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception {
-
- VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
+ public static VendorSoftwareProductObject createVspViaApis(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception {
AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user);
- Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers);
- VendorSoftwareProductObject map = createVendorSoftwareProduct.right;
- vendorSoftwareProductObject.setAttContact(map.getAttContact());
- vendorSoftwareProductObject.setCategory(map.getCategory());
- vendorSoftwareProductObject.setComponentId(map.getComponentId());
- vendorSoftwareProductObject.setDescription(map.getDescription());
- vendorSoftwareProductObject.setSubCategory(map.getSubCategory());
- vendorSoftwareProductObject.setVendorName(map.getVendorName());
- vendorSoftwareProductObject.setVspId(map.getVspId());
- Pair<String, VendorSoftwareProductObject> pair = new Pair<String, VendorSoftwareProductObject>(createVendorSoftwareProduct.left, vendorSoftwareProductObject);
- return pair;
+ return VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers);
}
-/* public static Resource createResourceFromVSP(Pair<String, Map<String, String>> createVendorSoftwareProduct, String vspName) throws Exception {
- List<String> tags = new ArrayList<>();
- tags.add(vspName);
- Map<String, String> map = createVendorSoftwareProduct.right;
- ResourceReqDetails resourceDetails = new ResourceReqDetails();
- resourceDetails.setCsarUUID(map.get("vspId"));
- resourceDetails.setCsarVersion("1.0");
- resourceDetails.setName(vspName);
- resourceDetails.setTags(tags);
- resourceDetails.setDescription(map.get("description"));
- resourceDetails.setResourceType(map.get("componentType"));
- resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
- resourceDetails.setVendorName(map.get("vendorName"));
- resourceDetails.setVendorRelease("1.0");
- resourceDetails.setResourceType("VF");
- resourceDetails.setResourceVendorModelNumber("666");
- resourceDetails.setContactId(map.get("attContact"));
- resourceDetails.setIcon("defaulticon");
- Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
-
- return resource;
- }*/
public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails) throws Exception {
Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
return resource;
@@ -133,28 +79,6 @@ public class OnboardingUtillViaApis {
}
}
-// public static void convertPayloadToFile(String payload, File file, boolean isBased64, boolean isSdcFormat) throws IOException{
-//
-// Gson gson = new Gson();
-// byte[] byteArray = null;
-// Map<String, String> fromJson;
-// @SuppressWarnings("unchecked")
-// String string = null;// = fromJson.get("base64Contents").toString();
-// if(isSdcFormat){
-// fromJson = gson.fromJson(payload, Map.class);
-// string = fromJson.get("base64Contents").toString();
-// }else if (isBased64) {
-// byteArray = Base64.decode(string.getBytes(StandardCharsets.UTF_8));
-// }else{
-// byteArray = payload.getBytes(StandardCharsets.UTF_8);
-// }
-// File downloadedFile = new File(file.getAbsolutePath());
-// FileOutputStream fos = new FileOutputStream(downloadedFile);
-// fos.write(byteArray);
-// fos.flush();
-// fos.close();
-//
-// }
public static void convertPayloadToFile(String payload, File file) throws IOException{
@@ -180,49 +104,8 @@ public class OnboardingUtillViaApis {
fos.flush();
fos.close();
-
-// ZipOutputStream fos = null;
-//
-//
-// for (Charset charset : Charset.availableCharsets().values()) {
-// try{
-// // System.out.println("How to do it???");
-// File downloadedFile = new File(file.getAbsolutePath() + "_" + charset +".csar");
-// fos = new ZipOutputStream(new FileOutputStream(downloadedFile));
-// byte[] byteArray = payload.getBytes(charset);
-// fos.write(byteArray);
-// fos.flush();
-//
-// }
-// catch(Exception e){
-// fos.close();
-// }
-// }
System.out.println("");
-// ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(byteArray));
-// ZipEntry entry = null;
-// while ((entry = zipStream.getNextEntry()) != null) {
-//
-// String entryName = entry.getName();
-//
-// FileOutputStream out = new FileOutputStream(file+"/"+entryName);
-//
-// byte[] byteBuff = new byte[4096];
-// int bytesRead = 0;
-// while ((bytesRead = zipStream.read(byteBuff)) != -1)
-// {
-// out.write(byteBuff, 0, bytesRead);
-// }
-//
-// out.close();
-// zipStream.closeEntry();
-// }
-// zipStream.close();
-//
-
-
-
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(payload.getBytes(StandardCharsets.ISO_8859_1)));
String filePath = file.toString();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
@@ -232,7 +115,7 @@ public class OnboardingUtillViaApis {
bos.close();
}
- public static Either<String, RestResponse> getVendorSoftwareProduct(String vspId, User user, Boolean validateState) throws Exception {
+ public static Either<String, RestResponse> getVendorSoftwareProduct(String vspId, User user, Boolean validateState) throws IOException {
Config config = Utils.getConfig();
String url = String.format(Urls.GET_VENDOR_SOFTWARE_PRODUCT, config.getOnboardingBeHost(), config.getOnboardingBePort(), vspId);
@@ -257,19 +140,15 @@ public class OnboardingUtillViaApis {
List<String> tags = new ArrayList<>();
tags.add(vendorSoftwareProductObject.getName());
-// ResourceReqDetails resourceDetails = new ResourceReqDetails();
resourceDetails.setCsarUUID(vendorSoftwareProductObject.getVspId());
resourceDetails.setCsarVersion(vendorSoftwareProductObject.getVersion());
resourceDetails.setName(vendorSoftwareProductObject.getName());
resourceDetails.setTags(tags);
resourceDetails.setDescription(vendorSoftwareProductObject.getDescription());
-// resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
resourceDetails.setVendorName(vendorSoftwareProductObject.getVendorName());
-// resourceDetails.setVendorRelease("1.0");
resourceDetails.setResourceType("VF");
resourceDetails.setResourceVendorModelNumber("666");
resourceDetails.setContactId(vendorSoftwareProductObject.getAttContact());
-// resourceDetails.setIcon("defaulticon");
return resourceDetails;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
index 6c3a3c4cd4..4f03767a85 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
index 71038920ae..366962ef0a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
@@ -20,56 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.nio.file.FileSystems;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONValue;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
-
-import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
-
-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;
-import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar;
-
-
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-
-import org.testng.Assert;
-
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
-
enum SnmpTypeEnum{
SNMP_POLL ("snmp"),
SNMP_TRAP ("snmp-trap");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
index 51e4923a1a..eca8921958 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
@@ -41,18 +41,18 @@ import static org.testng.AssertJUnit.assertEquals;
public class VendorSoftwareProductRestUtils {
- public static Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
+ public static VendorSoftwareProductObject createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
throws Exception {
- Pair<String, VendorSoftwareProductObject> pair = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers);
+ VendorSoftwareProductObject vendorSoftwareProductObject = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers);
if(cvfcArtifacts != null && ! cvfcArtifacts.isEmpty()){
- addCvfcArtifacts(cvfcArtifacts, user, pair.right);
+ addCvfcArtifacts(cvfcArtifacts, user, vendorSoftwareProductObject);
}
- prepareVspForUse(user, pair.right, true);
- return pair;
+ prepareVspForUse(user, vendorSoftwareProductObject, true);
+ return vendorSoftwareProductObject;
}
- public static Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers)
+ public static VendorSoftwareProductObject createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers)
throws Exception {
Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
@@ -83,14 +83,14 @@ public class VendorSoftwareProductRestUtils {
public static VendorSoftwareProductObject createAndFillVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filePath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
throws Exception {
- Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts);
+ VendorSoftwareProductObject createVendorSoftwareProduct = createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts);
VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(heatFileName, createVendorSoftwareProduct);
return vendorSoftwareProductObject;
}
- public static Pair<String, VendorSoftwareProductObject> createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception {
+ public static VendorSoftwareProductObject createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception {
String vspName = handleFilename(heatFileName);
if(ComponentBaseTest.getExtendTest() != null){
@@ -106,8 +106,7 @@ public class VendorSoftwareProductRestUtils {
RestResponse validateUpload = validateUpload(createNewVspPair.right, user);
assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue());
- Pair<String, VendorSoftwareProductObject> pair = new Pair<>(vspName, createNewVspPair.right);
- return pair;
+ return createNewVspPair.right;
}
public static void updateVspWithVfcArtifacts(String filepath, String updatedSnmpPoll, String updatedSnmpTrap, String componentInstanceId, User user, VendorSoftwareProductObject vendorSoftwareProductObject) throws Exception{
@@ -288,6 +287,19 @@ public class VendorSoftwareProductRestUtils {
return response;
}
+// TODO to check if for onboard API ACTION_ARCHIVE_RESTORE_COMPONENT format was added version parameter
+// if yes remove this method and use general actionOnComponent method
+ private static RestResponse actionOnComponent(String vspid, String body, String onboardComponent, User user) throws Exception {
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.ACTION_ARCHIVE_RESTORE_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid);
+ String userId = user.getUserId();
+ Map<String, String> headersMap = OnboardingUtils.prepareHeadersMap(userId);
+
+ HttpRequest http = new HttpRequest();
+ RestResponse response = http.httpSendPut(url, body, headersMap);
+ return response;
+ }
+
public static Pair<RestResponse, VendorSoftwareProductObject> createNewVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String vspName, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception {
Config config = Utils.getConfig();
@@ -317,6 +329,7 @@ public class VendorSoftwareProductRestUtils {
vendorSoftwareProductObject.setVspId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "itemId"));
vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:id"));
+// vendorSoftwareProductObject.setVersion(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:name"));
vendorSoftwareProductObject.setAttContact(user.getUserId());
return new Pair<>(response, vendorSoftwareProductObject);
@@ -659,17 +672,16 @@ public class VendorSoftwareProductRestUtils {
// }
- public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct) {
+ private static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, VendorSoftwareProductObject createVendorSoftwareProduct) {
VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
- VendorSoftwareProductObject map = createVendorSoftwareProduct.right;
- vendorSoftwareProductObject.setAttContact(map.getAttContact());
- vendorSoftwareProductObject.setCategory(map.getCategory());
- vendorSoftwareProductObject.setComponentId(map.getComponentId());
- vendorSoftwareProductObject.setDescription(map.getDescription());
- vendorSoftwareProductObject.setSubCategory(map.getSubCategory());
- vendorSoftwareProductObject.setVendorName(map.getVendorName());
- vendorSoftwareProductObject.setVspId(map.getVspId());
- vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
+ vendorSoftwareProductObject.setAttContact(createVendorSoftwareProduct.getAttContact());
+ vendorSoftwareProductObject.setCategory(createVendorSoftwareProduct.getCategory());
+ vendorSoftwareProductObject.setComponentId(createVendorSoftwareProduct.getComponentId());
+ vendorSoftwareProductObject.setDescription(createVendorSoftwareProduct.getDescription());
+ vendorSoftwareProductObject.setSubCategory(createVendorSoftwareProduct.getSubCategory());
+ vendorSoftwareProductObject.setVendorName(createVendorSoftwareProduct.getVendorName());
+ vendorSoftwareProductObject.setVspId(createVendorSoftwareProduct.getVspId());
+ vendorSoftwareProductObject.setName(createVendorSoftwareProduct.getName());
String[] arrFileNameAndExtension = vnfFile.split("\\.");
vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage");
vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]);
@@ -692,5 +704,14 @@ public class VendorSoftwareProductRestUtils {
prepareVspForUse(user,vendorSoftwareProductObject, true);
}
+ public static RestResponse archiveVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception {
+ String messageBody = "{\"action\":\"ARCHIVE\"}";
+ return actionOnComponent(vendorSoftwareProductObject.getVspId(), messageBody, "items", user);
+ }
+
+ public static RestResponse restoreVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception {
+ String messageBody = "{\"action\":\"RESTORE\"}";
+ return actionOnComponent(vendorSoftwareProductObject.getVspId(), messageBody, "items", user);
+ }
}