summaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java34
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java122
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java33
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java392
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java68
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java12
19 files changed, 387 insertions, 377 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
index 3977f16d5a..ea1c9eff8d 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
@@ -117,19 +117,19 @@ public interface Urls {
// *****************************************ECOMP User
// URL's*****************************************************
- final String ECOMP_PUSH_USER = "http://%s:%s/api/user";
+ final String ECOMP_PUSH_USER = "http://%s:%s/api/v2/user";
- final String ECOMP_EDIT_USER = "http://%s:%s/api/user/%s";
+ final String ECOMP_EDIT_USER = "http://%s:%s/api/v2/user/%s";
- final String ECOMP_GET_USER = "http://%s:%s/api/user/%s";
+ final String ECOMP_GET_USER = "http://%s:%s/api/v2/user/%s";
- final String ECOMP_GET_ALL_USERS = "http://%s:%s/api/users";
+ final String ECOMP_GET_ALL_USERS = "http://%s:%s/api/v2/users";
- final String ECOMP_GET_ALL_AVAILABLE_ROLES = "http://%s:%s/api/roles";
+ final String ECOMP_GET_ALL_AVAILABLE_ROLES = "http://%s:%s/api/v2/roles";
- final String ECOMP_PUSH_USER_ROLES = "http://%s:%s/api/user/%s/roles";
+ final String ECOMP_PUSH_USER_ROLES = "http://%s:%s/api/v2/user/%s/roles";
- final String ECOMP_GET_USER_ROLES = "http://%s:%s/api/user/%s/roles";
+ final String ECOMP_GET_USER_ROLES = "http://%s:%s/api/v2/user/%s/roles";
// *****************************************Elements*************************************************************
final String GET_TAGS_LIST = "http://%s:%s/sdc2/rest/v1/tags";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
index b1d04ba88d..537a70984e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
@@ -74,7 +74,7 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
.filter(att -> att.getName().equals("private_address")).findAny().get();
// update attribute on vfc instance
final Resource vfWithInsatncePreUpdate = swallowException(
- () -> (Resource) AtomicOperationUtils.getCompoenntObject(vf, UserRoleEnum.DESIGNER));
+ () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
ComponentInstanceProperty attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
final String newAttValue = "NewValue";
attributeOfRI.setValue(newAttValue);
@@ -86,7 +86,7 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
BaseRestUtils.acceptHeaderData));
// Retrieve updated vf and verify attribute was updated
final Resource vfWithInsatncePostUpdate = swallowException(
- () -> (Resource) AtomicOperationUtils.getCompoenntObject(vf, UserRoleEnum.DESIGNER));
+ () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
ComponentInstanceProperty updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
assertEquals(updatedAttribute.getValue(), newAttValue);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
index 6e36e1b675..45c6b18b59 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
@@ -45,26 +45,33 @@ import org.testng.annotations.Test;
public class AndreyTest {
+ private static ToscaDefinition parseToscaYamlToJavaObject;
+
+
public static void main(String[] args) throws Exception {
ToscaDefinition toscaDefinition;
System.out.println("start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
// File path = new File("C:/Data/D2.0/TOSCA_Ex/Definitions/tosca_definition_version.yaml");
// File path = new File("C:/Data/D2.0/TOSCA_Ex/resource-Vl11Vl10-template.yml");
- File path = new File("C:/Data/D2.0/TOSCA_Ex/service-Servicepxtc-template US822998.yml");
- File csarPath = new File("C:/Data/D2.0/TOSCA_Ex/Nested.csar");
+// File path = new File("C:/Data/D2.0/TOSCA_Ex/service-Servicepxtc-template US822998.yml");
+// File path = new File("C:/Data/FileToParse/Definitions/service-Ciservice513e6fa67d07-template.yml");
+ toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:/Data/FileToParse/LDSA/LDSA_amdocs.csar"));
+// File path = new File("C:/Data/FileToParse/Definitions/resource-Civfonboarded2016006VvmVvm301607E2100a9b04-template.yml");
+// File csarPath = new File("C:/Data/D2.0/TOSCA_Ex/Nested.csar");
- toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path);
+
+// toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path);
System.out.println("listTypeHeatMetaDefinition start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
- List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(csarPath);
+// List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(csarPath);
System.out.println("get service start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
- System.out.println(listTypeHeatMetaDefinition);
- for(TypeHeatMetaDefinition typeHeatMetaDefinition : listTypeHeatMetaDefinition){
- for(GroupHeatMetaDefinition groupHeatMetaDefinition : typeHeatMetaDefinition.getGroupHeatMetaDefinition()){
- List<HeatMetaFirstLevelDefinition> artifactList = groupHeatMetaDefinition.getArtifactList();
- boolean isBase = groupHeatMetaDefinition.getPropertyHeatMetaDefinition().getValue();
- }
-
- }
+// System.out.println(listTypeHeatMetaDefinition);
+// for(TypeHeatMetaDefinition typeHeatMetaDefinition : listTypeHeatMetaDefinition){
+// for(GroupHeatMetaDefinition groupHeatMetaDefinition : typeHeatMetaDefinition.getGroupHeatMetaDefinition()){
+// List<HeatMetaFirstLevelDefinition> artifactList = groupHeatMetaDefinition.getArtifactList();
+// boolean isBase = groupHeatMetaDefinition.getPropertyHeatMetaDefinition().getValue();
+// }
+//
+// }
System.out.println("Finished");
System.out.println("get service start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
index c52ee470cf..66bc153e70 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
@@ -238,7 +238,7 @@ public class BasicHttpAuthenticationTest extends ComponentBaseTest {
assertTrue(restResponse.getHeaderFields().containsKey(WWW_AUTHENTICATE));
List<String> getAuthenticateHeader = restResponse.getHeaderFields().get(WWW_AUTHENTICATE);
assertEquals("www-authenticate header contains more then one value", 1, getAuthenticateHeader.size());
- assertTrue(getAuthenticateHeader.get(0).equals("Basic realm=" + "\"ASDC\""));
+ assertTrue(getAuthenticateHeader.get(0).equals("Basic realm=" + "\"SDC\""));
validateAuditAuthentication("", AUTH_REQUIRED, ComponentTypeEnum.SERVICE);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
index 8ce8dc5433..b460b9fce0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
@@ -1816,8 +1816,8 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
importReqDetailsFather.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
}
- // DE202329
- @Test(enabled = false)
+ // DE202329 - TDP -154379
+ @Test(enabled = true)
public void requirementWithMissingTypeTest() throws Exception {
String fatherName = "father";
String fatherFileName = "DerivedFromWebApplication_HasNoReqType.yml";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
index 0a7b4a98aa..a33ee71f9e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
@@ -86,7 +86,7 @@ public class MultipleResourceUpdate extends ComponentBaseTest {
ComponentInstance instanceCP2 = AtomicOperationUtils
.addComponentInstanceToComponentContainer(cp2, vf, UserRoleEnum.DESIGNER, true).left().value();
- vf = (Resource) AtomicOperationUtils.getCompoenntObject(vf, UserRoleEnum.DESIGNER);
+ vf = (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER);
// Create Vertex(Link/Associate 2 Resource Instances on Canvas)
AtomicOperationUtils.associate2ResourceInstances(vf, instanceCP1, instanceVL, AssocType.LINKABLE.getAssocType(),
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
index 5a89a6766c..18b2329663 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
@@ -111,7 +111,7 @@ public class ToscaDefinition {
typeDescription.putMapPropertyType("metadata", String.class, String.class);
// TODO Andrey imports format
typeDescription.putMapPropertyType("imports", String.class, ToscaImportsDefinition.class);
- typeDescription.putListPropertyType("imports", List.class);
+// typeDescription.putListPropertyType("imports", List.class);
typeDescription.putMapPropertyType("node_types", String.class, ToscaNodeTypesDefinition.class);
return typeDescription;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java
new file mode 100644
index 0000000000..18d7d7d97b
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java
@@ -0,0 +1,9 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+public interface ToscaParameterConstants {
+
+ public static final String ENTRY_DEFINITION = "Entry-Definitions";
+ public static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
+ public static final String HEAT_META_PATH = "Artifacts/HEAT.meta";
+ public static final String IMPORT_STRUCTURE = "importStructure";
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
index 69c8b2fe2f..cd6687be0e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
@@ -30,11 +30,13 @@ import java.util.Set;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
import org.openecomp.sdc.ci.tests.datatypes.PropertyHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants;
import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,40 +44,34 @@ import org.slf4j.LoggerFactory;
public class CsarParserUtils {
private static Logger log = LoggerFactory.getLogger(CsarValidationUtils.class.getName());
- public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(File csarUUID) throws Exception {
-
- String artifactHeatMetaLocation = "Artifacts/HEAT.meta";
- JSONParser parser = new JSONParser();
- String csarPayload = CsarValidationUtils.getCsarPayload(csarUUID, artifactHeatMetaLocation);
- if (csarPayload != null) {
- Object parse = parser.parse(csarPayload);
- JSONObject jsonObject = (JSONObject) parse;
- JSONObject jsonObjectImportStructure = (JSONObject) jsonObject.get("importStructure");
- List<TypeHeatMetaDefinition> listHeatMetaDefenition = new ArrayList<TypeHeatMetaDefinition>();
- listHeatMetaDefenition = getArtifactsByGroup(jsonObjectImportStructure, listHeatMetaDefenition);
- return listHeatMetaDefenition;
- }
- return null;
+ public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(File csarFileLocation) throws Exception {
+ String artifactHeatMetaLocation = ToscaParameterConstants.HEAT_META_PATH;
+ String csarPayload = ToscaParserUtils.getYamlPayloadFromCsar(csarFileLocation, artifactHeatMetaLocation);
+ return getListTypeHeatMetaDefinitionByPayload(csarPayload);
}
-
+
public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(String csarUUID) throws Exception {
+
+ String artifactHeatMetaLocation = ToscaParameterConstants.HEAT_META_PATH;
+ String csarPayload = ToscaParserUtils.getCsarPayload(csarUUID, artifactHeatMetaLocation);
+ return getListTypeHeatMetaDefinitionByPayload(csarPayload);
+ }
- String artifactHeatMetaLocation = "Artifacts/HEAT.meta";
+ public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinitionByPayload(String csarPayload) throws ParseException {
JSONParser parser = new JSONParser();
- String csarPayload = CsarValidationUtils.getCsarPayload(csarUUID, artifactHeatMetaLocation);
if (csarPayload != null) {
Object parse = parser.parse(csarPayload);
JSONObject jsonObject = (JSONObject) parse;
- JSONObject jsonObjectImportStructure = (JSONObject) jsonObject.get("importStructure");
+ JSONObject jsonObjectImportStructure = (JSONObject) jsonObject.get(ToscaParameterConstants.IMPORT_STRUCTURE);
List<TypeHeatMetaDefinition> listHeatMetaDefenition = new ArrayList<TypeHeatMetaDefinition>();
listHeatMetaDefenition = getArtifactsByGroup(jsonObjectImportStructure, listHeatMetaDefenition);
return listHeatMetaDefenition;
}
return null;
-
}
+
protected static List<TypeHeatMetaDefinition> getArtifactsByGroup(JSONObject jsonObjectImportStructure, List<TypeHeatMetaDefinition> listHeatMetaDefenition) {
@SuppressWarnings("unchecked")
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
index 26fac7fd6e..3bae41fc57 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
@@ -21,19 +21,30 @@
package org.openecomp.sdc.ci.tests.utils;
import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
import java.io.File;
import java.io.FileInputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Map;
import java.util.Set;
import org.openecomp.sdc.ci.tests.datatypes.enums.ToscaKeysEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaNodeTemplatesTopologyTemplateDefinition;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaSubstitutionMappingsDefinition;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinition;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils;
import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
+import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray;
+import org.openecomp.sdc.common.util.ZipUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.TypeDescription;
@@ -45,20 +56,56 @@ public class ToscaParserUtils {
private static Logger log = LoggerFactory.getLogger(ToscaParserUtils.class.getName());
- public static ToscaDefinition parseToscaYamlToJavaObject(String csarUUID) throws Exception {
+
+ /**method get csarUUID and send GET API request toward BE
+ * @param csarUUID
+ * @return
+ * @throws Exception
+ */
+ public static ToscaDefinition parseToscaYamlToJavaObjectByCsarUuid(String csarUUID) throws Exception {
ToscaDefinition toscaDefinition = null;
- String TOSCAMetaLocation = "TOSCA-Metadata/TOSCA.meta";
+ String TOSCAMetaLocation = ToscaParameterConstants.TOSCA_META_PATH;
Map<?, ?> map = getToscaYamlMap(csarUUID, TOSCAMetaLocation);
assertNotNull("Tosca Entry-Definitions is null", map);
if (map != null) {
- File definitionYamlLocation = (File) map.get("Entry-Definitions");
+ File definitionYamlLocation = (File) map.get(ToscaParameterConstants.ENTRY_DEFINITION);
toscaDefinition = parseToscaYamlToJavaObject(definitionYamlLocation);
}
return toscaDefinition;
}
+ /**method read csar from location
+ * @param csarNameLocation - full path with csar name
+ * @return
+ * @throws Exception
+ */
+ public static ToscaDefinition parseToscaMainYamlToJavaObjectByCsarLocation(File csarNameLocation) throws Exception {
+
+ ToscaDefinition toscaDefinition = null;
+ String TOSCAMetaLocation = ToscaParameterConstants.TOSCA_META_PATH;
+// read file location of main yaml file(location+name) from TOSCA.meta file by
+ Map<?, ?> map = getToscaYamlMap(csarNameLocation, TOSCAMetaLocation);
+
+ assertNotNull("Tosca Entry-Definitions is null", map);
+
+ String definitionYamlLocation = (String) map.get(ToscaParameterConstants.ENTRY_DEFINITION);
+ String csarPayload = getYamlPayloadFromCsar(csarNameLocation, definitionYamlLocation);
+ toscaDefinition = parseToscaYamlPayloadToJavaObject(csarPayload);
+ return toscaDefinition;
+
+ }
+
+ public static ToscaDefinition parseToscaAnyYamlToJavaObjectByCsarLocation(File csarNameLocation, String yamlLocation) throws Exception {
+
+ ToscaDefinition toscaDefinition = null;
+ String csarPayload = getYamlPayloadFromCsar(csarNameLocation, yamlLocation);
+ toscaDefinition = parseToscaYamlPayloadToJavaObject(csarPayload);
+ return toscaDefinition;
+
+ }
+
public static ToscaDefinition parseToscaYamlToJavaObject(File path) throws Exception {
ToscaDefinition toscaDefinition = null;
@@ -72,7 +119,7 @@ public class ToscaParserUtils {
System.out.println("Exception: " + e);
}
- Constructor constructor = getConstructor();
+ Constructor constructor = initToscaDefinitionObject();
Yaml yaml = new Yaml(constructor);
try {
@@ -90,7 +137,7 @@ public class ToscaParserUtils {
public static ToscaDefinition parseToscaYamlPayloadToJavaObject(String payload){
ToscaDefinition toscaDefinition = null;
- Constructor constructor = getConstructor();
+ Constructor constructor = initToscaDefinitionObject();
Yaml yaml = new Yaml(constructor);
try {
@@ -104,23 +151,33 @@ public class ToscaParserUtils {
}
- public static Constructor getConstructor() {
- Constructor constructor = new Constructor(ToscaDefinition.class);
- constructor.addTypeDescription(ToscaDefinition.getTypeDescription());
- constructor.addTypeDescription(ToscaTopologyTemplateDefinition.getTypeDescription());
- constructor.addTypeDescription(ToscaNodeTemplatesTopologyTemplateDefinition.getTypeDescription());
- constructor.addTypeDescription(ToscaGroupsTopologyTemplateDefinition.getTypeDescription());
- constructor.addTypeDescription(ToscaSubstitutionMappingsDefinition.getTypeDescription());
+ public static Constructor initToscaDefinitionObject() {
+ Constructor toscaStructure = new Constructor(ToscaDefinition.class);
+ toscaStructure.addTypeDescription(ToscaDefinition.getTypeDescription());
+ toscaStructure.addTypeDescription(ToscaTopologyTemplateDefinition.getTypeDescription());
+ toscaStructure.addTypeDescription(ToscaNodeTemplatesTopologyTemplateDefinition.getTypeDescription());
+ toscaStructure.addTypeDescription(ToscaGroupsTopologyTemplateDefinition.getTypeDescription());
+ toscaStructure.addTypeDescription(ToscaSubstitutionMappingsDefinition.getTypeDescription());
// Skip properties which are found in YAML, but not found in POJO
PropertyUtils propertyUtils = new PropertyUtils();
propertyUtils.setSkipMissingProperties(true);
- constructor.setPropertyUtils(propertyUtils);
- return constructor;
+ toscaStructure.setPropertyUtils(propertyUtils);
+ return toscaStructure;
}
- public static Map<?, ?> getToscaYamlMap(String csarUUID, String fileLocation) throws Exception {
- String csarPayload = CsarValidationUtils.getCsarPayload(csarUUID, fileLocation);
+ public static Map<?, ?> getToscaYamlMap(String csarUUID, String yamlFileLocation) throws Exception {
+ String csarPayload = getCsarPayload(csarUUID, yamlFileLocation);
+ if (csarPayload != null) {
+ Yaml yaml = new Yaml();
+ Map<?, ?> map = (Map<?, ?>) yaml.load(csarPayload);
+ return map;
+ }
+ return null;
+ }
+
+ public static Map<?, ?> getToscaYamlMap(File csarPath, String yamlFileLocation) throws Exception {
+ String csarPayload = getYamlPayloadFromCsar(csarPath, yamlFileLocation);
if (csarPayload != null) {
Yaml yaml = new Yaml();
Map<?, ?> map = (Map<?, ?>) yaml.load(csarPayload);
@@ -129,6 +186,39 @@ public class ToscaParserUtils {
return null;
}
+
+ public static String getCsarPayload(String csarName, String yamlFileLocation) throws Exception {
+
+ RestResponseAsByteArray csar = ImportRestUtils.getCsar(csarName, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
+ assertTrue("Return response code different from 200", csar.getHttpStatusCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ byte[] data = csar.getResponse();
+ return getDataFromZipFileByBytes(yamlFileLocation, data);
+
+ }
+
+ public static String getYamlPayloadFromCsar(File csarName, String fileLocation) throws Exception {
+
+ Path path = csarName.toPath();
+ byte[] data = Files.readAllBytes(path);
+ return getDataFromZipFileByBytes(fileLocation, data);
+
+ }
+
+ /** method get file data from zip data by file location in the zip structure
+ * @param fileLocation
+ * @param data
+ * @return
+ */
+ public static String getDataFromZipFileByBytes(String fileLocation, byte[] data) {
+ Map<String, byte[]> readZip = null;
+ if (data != null && data.length > 0) {
+ readZip = ZipUtil.readZip(data);
+
+ }
+ byte[] artifactsBs = readZip.get(fileLocation);
+ String str = new String(artifactsBs, StandardCharsets.UTF_8);
+ return str;
+ }
/* public static Map<?, ?> getToscaYamlMap(String csarUUID, String fileLocation) throws Exception {
String csarPayload = CsarValidationUtils.getCsarPayload(csarUUID, fileLocation);
if (csarPayload != null) {
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 207c4bbe02..17148ce8a9 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
@@ -261,7 +261,7 @@ public final class AtomicOperationUtils {
LifeCycleStatesEnum curentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
if (curentCompState == targetState) {
- component = getCompoenntObject(component, userRole);
+ component = getComponentObject(component, userRole);
return Pair.of(component, null);
}
// List<LifeCycleStatesEnum> lifeCycleStatesEnumOrigList = new
@@ -299,7 +299,7 @@ public final class AtomicOperationUtils {
}
}
- Component componentJavaObject = getCompoenntObject(component, userRole);
+ Component componentJavaObject = getComponentObject(component, userRole);
if (validateState == true && isValidationFailed == true) {
assertTrue("change state failed" + lifeCycleStatesResponse.getResponse(), false);
@@ -431,6 +431,12 @@ public final class AtomicOperationUtils {
Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
return container;
}
+
+ public static Service getServiceObject(String uniqueId) throws Exception {
+ RestResponse serviceResponse = ServiceRestUtils.getService(uniqueId);
+ Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ return container;
+ }
public static Product getProductObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
@@ -439,7 +445,7 @@ public final class AtomicOperationUtils {
return container;
}
- public static Component getCompoenntObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
+ public static Component getComponentObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
switch (containerDetails.getComponentType()) {
@@ -521,7 +527,7 @@ public final class AtomicOperationUtils {
if (changeComponentInstanceVersionResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- Component compoenntObject = AtomicOperationUtils.getCompoenntObject(containerDetails, userRole);
+ Component compoenntObject = AtomicOperationUtils.getComponentObject(containerDetails, userRole);
ComponentInstance componentInstanceJavaObject = ResponseParser.convertComponentInstanceResponseToJavaObject(changeComponentInstanceVersionResp.getResponse());
return Either.left(Pair.of(compoenntObject, componentInstanceJavaObject));
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
index 25fce34a75..e387cd2544 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
+++ b/test-apis-ci/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;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
index d53d2da91b..22a352cbfe 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
@@ -262,19 +262,14 @@ public class LifecycleRestUtils extends BaseRestUtils {
LifeCycleStatesEnum LifeCycleStatesEnum) throws Exception {
Config config = Utils.getConfig();
String url = String.format(Urls.CHANGE_COMPONENT_LIFECYCLE_STATE, config.getCatalogBeHost(),
- config.getCatalogBePort(), ComponentTypeEnum.findParamByType(component.getComponentType()),
- component.getUniqueId(), LifeCycleStatesEnum);
- RestResponse LifeCycleStatesEnumServiceResponse = sendPost(url, createLifecycleCommentJson(COMMENT),
- sdncModifierDetails.getUserId(), acceptHeaderData);
+ config.getCatalogBePort(), ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(), LifeCycleStatesEnum);
+ RestResponse LifeCycleStatesEnumServiceResponse = sendPost(url, createLifecycleCommentJson(COMMENT), sdncModifierDetails.getUserId(), acceptHeaderData);
if (LifeCycleStatesEnumServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS) {
- String productUniqueId = ResponseParser
- .getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "uniqueId");
+ String productUniqueId = ResponseParser.getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "uniqueId");
component.setUniqueId(productUniqueId);
- String productVersion = ResponseParser
- .getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "version");
+ String productVersion = ResponseParser.getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "version");
component.setVersion(productVersion);
- String newLifecycleState = ResponseParser
- .getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "lifecycleState");
+ String newLifecycleState = ResponseParser.getValueFromJsonResponse(LifeCycleStatesEnumServiceResponse.getResponse(), "lifecycleState");
component.setLifecycleState(LifecycleStateEnum.valueOf(newLifecycleState));
}
return LifeCycleStatesEnumServiceResponse;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
index ad9f482bc1..95953838c9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
@@ -60,6 +60,7 @@ import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.google.gson.Gson;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
index a93587dbbc..9ba4a906c6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
@@ -94,6 +94,7 @@ public class ServiceRestUtils extends BaseRestUtils {
}
public static RestResponse createService(ServiceReqDetails service, User user) throws Exception {
+
Config config = Utils.getConfig();
String url = String.format(Urls.CREATE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort());
String serviceBodyJson = gson.toJson(service);
@@ -256,6 +257,7 @@ public class ServiceRestUtils extends BaseRestUtils {
config.getCatalogBePort(), serviceName, serviceVersion);
RestResponse deleteResponse = http.httpSendDelete(url, headersMap);
+ deleteMarkedServices(sdncModifierDetails.getUserId());
return deleteResponse;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
index 0fe11537e4..7423dbc808 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
@@ -44,39 +44,6 @@ import org.openecomp.sdc.common.util.ZipUtil;
public class CsarValidationUtils {
- public static String getCsarPayload(String csarName, String fileLocation) throws Exception {
-
- RestResponseAsByteArray csar = ImportRestUtils.getCsar(csarName, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- assertTrue("Return response code different from 200", csar.getHttpStatusCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- Map<String, byte[]> readZip = null;
- byte[] data = csar.getResponse();
- if (data != null && data.length > 0) {
- readZip = ZipUtil.readZip(data);
-
- }
- byte[] artifactsBs = readZip.get(fileLocation);
- String str = new String(artifactsBs, StandardCharsets.UTF_8);
- return str;
-
- }
-
- public static String getCsarPayload(File csarName, String fileLocation) throws Exception {
-
-// RestResponseAsByteArray csar = ImportRestUtils.getCsar(csarName, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-// assertTrue("Return response code different from 200", csar.getHttpStatusCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- Map<String, byte[]> readZip = null;
- Path path = csarName.toPath();
-
- byte[] data = Files.readAllBytes(path);
- if (data != null && data.length > 0) {
- readZip = ZipUtil.readZip(data);
- }
- byte[] artifactsBs = readZip.get(fileLocation);
- String str = new String(artifactsBs, StandardCharsets.UTF_8);
- return str;
-
- }
-
public static void validateCsarVfArtifact(String csarUUID, Resource resource) throws Exception {
List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(csarUUID);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
index a680990af8..127ae54784 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
@@ -80,7 +80,6 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
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.AutomationUtils;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.DistributionValidationUtils;
@@ -356,42 +355,45 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// create component/s & upload artifact via external api
if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
component = getComponentWithResourceInstanceInTargetLifeCycleState(chosenLifeCycleState, resourceTypeEnum);
-
restResponse = uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- component =AtomicOperationUtils.getCompoenntObject(component, UserRoleEnum.DESIGNER);
-
- if((LifeCycleStatesEnum.CERTIFICATIONREQUEST == chosenLifeCycleState) && (!component.getComponentType().toString().equals(ComponentTypeEnum.RESOURCE.toString()))) {
-// numberOfArtifact = component.getComponentInstances().get(0).getDeploymentArtifacts().size();
- numberOfArtifact = (component.getComponentInstances().get(0).getDeploymentArtifacts() == null ? 0 : component.getComponentInstances().get(0).getDeploymentArtifacts().size());
- } else {
-// numberOfArtifact = component.getComponentInstances().get(0).getDeploymentArtifacts().size() + 1;
- numberOfArtifact = (component.getComponentInstances().get(0).getDeploymentArtifacts() == null ? 0 : component.getComponentInstances().get(0).getDeploymentArtifacts().size());
- }
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ numberOfArtifact = (component.getComponentInstances().get(0).getDeploymentArtifacts() == null ? 0 : component.getComponentInstances().get(0).getDeploymentArtifacts().size());
} else {
component = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, chosenLifeCycleState, resourceTypeEnum);
-
restResponse = uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- numberOfArtifact = component.getDeploymentArtifacts().size() + 1;
+ component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
+ numberOfArtifact = component.getDeploymentArtifacts().size();
}
-
-
ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
-
// Get list of deployment artifact + download them via external API
Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be increase by one.");
+ Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifacts will be increase by one.");
// Download the uploaded artifact via external API
downloadResourceDeploymentArtifactExternalAPI(component, deploymentArtifacts.get(responseArtifact.getArtifactLabel()), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentTypeEnum);
-
+ return component;
+ }
+
+ /**
+ * according lifecycle state of component get updated component details
+ * @param chosenLifeCycleState
+ * @param component
+ * @return
+ * @throws Exception
+ */
+ public Component updateComponentDetailsByLifeCycleState(LifeCycleStatesEnum chosenLifeCycleState, Component component) throws Exception {
+ if(LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)){
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ }else{
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ }
return component;
}
// Upload artifact via external API + Check auditing for upload operation + Check response of external API
- public RestResponse uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, resourceDetails.getComponentInstances().get(0));
+ public RestResponse uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0));
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -406,18 +408,16 @@ public class CRUDExternalAPI extends ComponentBaseTest {
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts");
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts");
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);
return restResponse;
}
-
-
protected Component getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum lifeCycleStatesEnum, ResourceTypeEnum resourceTypeEnum) throws Exception {
Component component;
if(resourceTypeEnum == ResourceTypeEnum.VF) {
@@ -426,9 +426,9 @@ public class CRUDExternalAPI extends ComponentBaseTest {
Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, null);
AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
- // Add artifact to service if asked for certifcationrequest - must be at least one artifact for the flow
- if((LifeCycleStatesEnum.CERTIFICATIONREQUEST == lifeCycleStatesEnum) || (LifeCycleStatesEnum.STARTCERTIFICATION == lifeCycleStatesEnum)) {
- }
+ // Add artifact to service if asked for certification request - must be at least one artifact for the flow
+// if((LifeCycleStatesEnum.CERTIFICATIONREQUEST == lifeCycleStatesEnum) || (LifeCycleStatesEnum.STARTCERTIFICATION == lifeCycleStatesEnum)) {
+// }
AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, component, UserRoleEnum.DESIGNER, true, true).left().value();
component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, lifeCycleStatesEnum, true).getLeft();
} else {
@@ -446,8 +446,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// Upload artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(resourceDetails, sdncModifierDetails, artifactReqDetails);
+ protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -460,10 +460,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);
return restResponse;
@@ -478,7 +478,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// check that this version different for input version
// check that this component uniqueID different from input uniqueID
// Return: that version
- protected Component getNewerVersionOfComponent(Component component, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
+ protected synchronized Component getNewerVersionOfComponent(Component component, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
Component resourceDetails = null;
if((!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CHECKOUT)) && (!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.STARTCERTIFICATION))) {
@@ -501,7 +501,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
System.out.println("Service UniqueID: " + resourceDetails.getUniqueId());
// Checking that new version exist + different from old one by unique id
- Assert.assertNotEquals(resourceVersion, resourceNewVersion, "Expected for diffrent resource version.");
+ Assert.assertNotEquals(resourceVersion, resourceNewVersion, "Expected for different resource version.");
Assert.assertNotEquals(resourceUniqueID, resourceNewUniqueID, "Expected that resource will have new unique ID.");
} else {
if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
@@ -518,13 +518,13 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
- protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component resourceDetails, ArtifactDefinition artifactDefinition, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, ComponentTypeEnum componentTypeEnum) throws Exception {
+ protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, ComponentTypeEnum componentTypeEnum) throws Exception {
RestResponse restResponse;
if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
- restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getComponentType().toString());
+ restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
} else {
- restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceDetails.getUUID(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getComponentType().toString());
+ restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
}
Integer responseCode = restResponse.getErrorCode();
@@ -532,7 +532,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
- // For known artifact/payload - verify payload of downloaded artfaict
+ // For known artifact/payload - verify payload of downloaded artifact
if (artifactReqDetails != null) {
String response = restResponse.getResponse();
String payloadData = artifactReqDetails.getPayload();
@@ -575,8 +575,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
// download deployment via external api + check response code for success (200) + verify audit
- protected void downloadResourceDeploymentArtifactExternalAPI(Component resourceDetails, ArtifactDefinition artifactDefinition, User sdncModifierDetails) throws Exception {
- downloadResourceDeploymentArtifactExternalAPI(resourceDetails, artifactDefinition, sdncModifierDetails, null, resourceDetails.getComponentType());
+ protected void downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails) throws Exception {
+ downloadResourceDeploymentArtifactExternalAPI(component, artifactDefinition, sdncModifierDetails, null, component.getComponentType());
}
@@ -821,13 +821,13 @@ public class CRUDExternalAPI extends ComponentBaseTest {
{LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// DE306360 {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// DE306360 {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// DE306360 {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
{LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
{LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
@@ -902,104 +902,104 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
// Upload artifact with invalid type via external API - to long type
- protected void uploadArtifactWithInvalidTypeToLong(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidTypeToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
artifactReqDetails.setArtifactType("dsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfds");
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
List<String> variables = asList(artifactReqDetails.getArtifactType());
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with invalid type via external API - empty type
- protected void uploadArtifactWithInvalidTypeEmpty(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidTypeEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
artifactReqDetails.setArtifactType("");
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
List<String> variables = asList(artifactReqDetails.getArtifactType());
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with invalid checksum via external API
- protected void uploadArtifactWithInvalidCheckSum(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidCheckSum(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_INVALID_MD5.name());
List<String> variables = asList();
- uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables);
}
// Upload artifact with valid type & invalid name via external API - name to long
- protected void uploadArtifactWithInvalidNameToLong(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidNameToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
List<String> variables = asList("artifact name", "255");
artifactReqDetails.setArtifactName("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with valid type & invalid name via external API - name is empty
- protected void uploadArtifactWithInvalidNameEmpty(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidNameEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_ARTIFACT_NAME.name());
List<String> variables = asList();
artifactReqDetails.setArtifactName("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with valid type & invalid label via external API - label to long
- protected void uploadArtifactWithInvalidLabelToLong(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidLabelToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
List<String> variables = asList("artifact label", "255");
artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with valid type & invalid label via external API - label is empty
- protected void uploadArtifactWithInvalidLabelEmpty(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidLabelEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
List<String> variables = asList("artifact label");
artifactReqDetails.setArtifactLabel("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with invalid description via external API - to long description
- protected void uploadArtifactWithInvalidDescriptionToLong(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidDescriptionToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
List<String> variables = asList("artifact description", "256");
artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
// Upload artifact with invalid description via external API - empty description
- protected void uploadArtifactWithInvalidDescriptionEmpty(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithInvalidDescriptionEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
List<String> variables = asList("artifact description");
artifactReqDetails.setDescription("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
@@ -1007,14 +1007,14 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// Upload artifact with same label via external API
- protected void uploadArtifactWithSameLabel(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected void uploadArtifactWithSameLabel(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
ComponentInstance componentResourceInstanceDetails) throws Exception {
RestResponse restResponse = null;
if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
} else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
}
@@ -1022,18 +1022,18 @@ public class CRUDExternalAPI extends ComponentBaseTest {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_EXIST.name());
List<String> variables = asList(artifactDefinition.getArtifactDisplayName());
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
artifactReqDetails, 400, componentResourceInstanceDetails, errorInfo, variables, null, false);
}
- protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
Integer expectedResponseCode, ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean includeResourceNameInAudit) throws Exception {
RestResponse restResponse;
if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(resourceDetails, sdncModifierDetails, artifactReqDetails, componentResourceInstanceDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentResourceInstanceDetails);
} else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(resourceDetails, sdncModifierDetails, artifactReqDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
}
@@ -1046,30 +1046,30 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
responseArtifact.setUpdaterFullName("");
responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, resourceDetails.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- expectedExternalAudit.setRESOURCE_TYPE(resourceDetails.getComponentType().getValue());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
expectedExternalAudit.setARTIFACT_DATA(null);
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
if(componentResourceInstanceDetails != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName());
- 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());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts");
+ expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
} else {
if(includeResourceNameInAudit) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
} else {
if((lifeCycleStatesEnum == LifeCycleStatesEnum.CHECKIN) || (lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
expectedExternalAudit.setRESOURCE_NAME("");
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");
} else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
}
}
}
@@ -1085,14 +1085,14 @@ public class CRUDExternalAPI extends ComponentBaseTest {
- protected RestResponse uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ protected RestResponse uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
Integer expectedResponseCode, ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables) throws Exception {
RestResponse restResponse;
if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
} else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
}
@@ -1109,23 +1109,23 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
responseArtifact.setUpdaterFullName("");
responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, resourceDetails.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- expectedExternalAudit.setRESOURCE_TYPE(resourceDetails.getComponentType().getValue());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
expectedExternalAudit.setARTIFACT_DATA(null);
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
if(componentResourceInstanceDetails != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName());
- 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());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts");
+ expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
} else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
}
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);
@@ -1542,7 +1542,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
// Verify that it cannot update VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow
@Test(dataProvider="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI")
public void updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception {
@@ -1571,10 +1570,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
-
-
-
-
@DataProvider(name="updateArtifactOnRIViaExternalAPI", parallel=true)
public static Object[][] dataProviderUpdateArtifactOnRIViaExternalAPI() {
return new Object[][] {
@@ -1602,10 +1597,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
-
-
-
@Test(dataProvider="updateArtifactOnRIViaExternalAPI")
public void updateArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
@@ -1619,12 +1610,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
}
-
-
-
-
-
-
@DataProvider(name="updateArtifactOnVfcVlCpRIViaExternalAPI", parallel=true)
public static Object[][] dataProviderUpdateArtifactOnVfcVlCpRIViaExternalAPI() {
return new Object[][] {
@@ -1714,10 +1699,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
-
-
-
@Test(dataProvider="updateArtifactOnVfcVlCpRIViaExternalAPI")
public void updateArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
@@ -1732,15 +1713,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
}
-
-
-
-
-
-
-
-
-
@DataProvider(name="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true)
public static Object[][] dataProviderUpdateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
return new Object[][] {
@@ -1789,8 +1761,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
-
// External API
// Update artifact by diffrent user then creator of asset - Fail
@Test(dataProvider="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
@@ -1812,8 +1782,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
-
// External API
// Upload artifact on VF via external API - happy flow
@Test(dataProvider="updateArtifactOnAssetWhichNotExist")
@@ -1875,7 +1843,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
@Test(dataProvider="updateArtifactOnAssetWhichInInvalidStateForUploading")
public void updateArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum, String artifactType) throws Exception {
getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
@@ -2065,10 +2032,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
@@ -2100,10 +2067,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
@@ -2135,10 +2102,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
@@ -2170,10 +2137,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
@@ -2205,10 +2172,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
@@ -2241,21 +2208,14 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
} else {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 400, null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
}
}
-
-
-
-
-
-
-
// Unhappy flow - get chosen life cycle state, artifact type and asset type
// update artifact via external API + check audit & response code
@@ -2305,14 +2265,14 @@ public class CRUDExternalAPI extends ComponentBaseTest {
return component;
}
- protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails,
+ protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
Integer expectedResponseCode, ComponentInstance componentInstance, ArtifactReqDetails artifactReqDetails, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
RestResponse restResponse;
if(componentInstance != null) {
- restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(resourceDetails, sdncModifierDetails, artifactReqDetails, componentInstance, artifactUUID);
+ restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentInstance, artifactUUID);
} else {
- restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(resourceDetails, sdncModifierDetails, artifactReqDetails, artifactUUID);
+ restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails, artifactUUID);
}
@@ -2326,35 +2286,35 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API;
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
responseArtifact.setUpdaterFullName("");
responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, resourceDetails.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- expectedExternalAudit.setRESOURCE_TYPE(resourceDetails.getComponentType().getValue());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
expectedExternalAudit.setARTIFACT_DATA("");
expectedExternalAudit.setCURR_ARTIFACT_UUID(artifactUUID);
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
if(componentInstance != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName());
- 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());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID);
+ expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
} else {
expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID);
if((lifeCycleStatesEnum == LifeCycleStatesEnum.CHECKIN) || (lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
if(resourceNameInAudit) {
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
} else {
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
// body.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
expectedExternalAudit.setRESOURCE_NAME("");
}
} else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
}
}
@@ -2381,7 +2341,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
return downloadResourceDeploymentArtifactExternalAPI(component, component.getDeploymentArtifacts().get(artifactName), sdncModifierDetails, artifactReqDetails, componentTypeEnum);
}
- // Get deployment artifact of asset
+ // Get deployment artifact of RI
protected Map<String, ArtifactDefinition> getDeploymentArtifactsOfAsset(Component component, ComponentTypeEnum componentTypeEnum) {
Map<String, ArtifactDefinition> deploymentArtifacts = null;
if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
@@ -2447,20 +2407,13 @@ public class CRUDExternalAPI extends ComponentBaseTest {
deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
numberOfArtifact = deploymentArtifacts.size();
-
// create component/s & upload artifact via external api
if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- if((chosenLifeCycleState == LifeCycleStatesEnum.CERTIFICATIONREQUEST) && (!component.getComponentType().toString().equals(ComponentTypeEnum.RESOURCE.toString()))) {
- numberOfArtifact = numberOfArtifact - 1;
- }
restResponse = updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
} else {
-
restResponse = updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
}
-
-
ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
component = getNewerVersionOfComponent(component, chosenLifeCycleState);
@@ -2483,8 +2436,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// Update artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, resourceDetails.getComponentInstances().get(0), artifactUUID);
+ protected RestResponse updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0), artifactUUID);
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -2499,11 +2452,11 @@ public class CRUDExternalAPI extends ComponentBaseTest {
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
// expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);
return restResponse;
@@ -2511,8 +2464,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// Update artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID);
+ protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID);
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -2525,10 +2478,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API;
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);
@@ -2571,9 +2524,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
};
}
-
-
-
// Delete artifact for Service - Success
@Test(dataProvider="deleteArtifactForServiceViaExternalAPI")
public void deleteArtifactForServiceViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
@@ -2935,7 +2885,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
// External API
- // Delete artifact by diffrent user then creator of asset - Fail
+ // Delete artifact by different user then creator of asset - Fail
@Test(dataProvider="deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
public void deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum %s, lifeCycleStatesEnum %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType));
@@ -2955,10 +2905,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- 409, component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
} else {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- 409, null, artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
+ errorInfo.getCode(), null, artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
}
//TODO
@@ -3000,10 +2950,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 404, component.getComponentInstances().get(0), invalidArtifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), invalidArtifactUUID, errorInfo, variables, null, true);
} else {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 404, null, invalidArtifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, invalidArtifactUUID, errorInfo, variables, null, true);
}
@@ -3014,7 +2964,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER.name());
variables = asList("invalidNormalizedName", ComponentTypeEnum.RESOURCE_INSTANCE.getValue().toLowerCase(), ComponentTypeEnum.SERVICE.getValue(), component.getName());
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 404, component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
} else {
component.setUUID("invalidComponentUUID");
if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE)) {
@@ -3024,7 +2974,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
variables = asList("invalidComponentUUID");
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 404, null, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
+ errorInfo.getCode(), null, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
}
@@ -3065,10 +3015,10 @@ public class CRUDExternalAPI extends ComponentBaseTest {
if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 403, component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
} else {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 403, null, artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), null, artifactUUID, errorInfo, variables, null, true);
}
@@ -3110,17 +3060,17 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
List<String> variables = asList(artifactUUID);
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- 404, component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
+ errorInfo.getCode(), component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
}
- protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails,
+ protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
Integer expectedResponseCode, ComponentInstance componentInstance, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
RestResponse restResponse;
if(componentInstance != null) {
- restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(resourceDetails, sdncModifierDetails, componentInstance, artifactUUID);
+ restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, componentInstance, artifactUUID);
} else {
- restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(resourceDetails, sdncModifierDetails, artifactUUID);
+ restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, sdncModifierDetails, artifactUUID);
}
@@ -3133,37 +3083,37 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API;
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
responseArtifact.setUpdaterFullName("");
responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, resourceDetails.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- expectedExternalAudit.setRESOURCE_TYPE(resourceDetails.getComponentType().getValue());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
expectedExternalAudit.setARTIFACT_DATA(null);
expectedExternalAudit.setCURR_ARTIFACT_UUID(artifactUUID);
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
if(componentInstance != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getComponentInstances().get(0).getNormalizedName());
- 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());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID);
+ expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
} else {
expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID);
if((errorInfo.getMessageId().equals(ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name()).getMessageId())) ||
errorInfo.getMessageId().equals(ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()).getMessageId()) ||
(lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
if(resourceNameInAudit) {
- expectedExternalAudit.setRESOURCE_NAME(resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ expectedExternalAudit.setRESOURCE_NAME(component.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
} else {
expectedExternalAudit.setRESOURCE_NAME("");
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
}
} else {
if(resourceNameInAudit) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
} else {
expectedExternalAudit.setRESOURCE_NAME("");
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
@@ -3185,7 +3135,11 @@ public class CRUDExternalAPI extends ComponentBaseTest {
protected Component deleteArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState) throws Exception {
String artifactName = null;
component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
-
+ if(!LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)){
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ }else{
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ }
// get updated artifact data
String artifactUUID = null;
int moduleTypeArtifact = 0;
@@ -3202,12 +3156,9 @@ public class CRUDExternalAPI extends ComponentBaseTest {
break;
}
}
-
String componentVersionBeforeDelete = component.getVersion();
int numberOfArtifact = deploymentArtifacts.size();
-
-
// create component/s & upload artifact via external api
if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
@@ -3215,8 +3166,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
} else {
deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, 200);
}
-
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+
+ component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
// Get list of deployment artifact + download them via external API
deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
@@ -3228,7 +3179,6 @@ public class CRUDExternalAPI extends ComponentBaseTest {
} else {
Assert.assertEquals(numberOfArtifact - 1, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will decrease by one.");
}
-
if(chosenLifeCycleState == LifeCycleStatesEnum.CHECKOUT) {
Assert.assertEquals(componentVersionBeforeDelete, component.getVersion(), "Expected that check-out component will not change version number.");
@@ -3242,8 +3192,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
// Delete artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, ComponentInstance componentInstance, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getComponentInstances().get(0), artifactUUID);
+ protected RestResponse deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentInstances().get(0), artifactUUID);
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -3258,20 +3208,20 @@ public class CRUDExternalAPI extends ComponentBaseTest {
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
// expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + resourceDetails.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
+ expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);
-
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
return restResponse;
}
// Delete artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component resourceDetails, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID);
+ protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID);
// Check response of external API
Integer responseCode = restResponse.getErrorCode();
@@ -3284,26 +3234,26 @@ public class CRUDExternalAPI extends ComponentBaseTest {
AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API;
Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
+ body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((resourceDetails.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
+ AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
+ ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);
-
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
return restResponse;
}
// download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
- protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component resourceDetails, User sdncModifierDetails, String artifactUUID, ComponentTypeEnum componentTypeEnum) throws Exception {
+ protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, User sdncModifierDetails, String artifactUUID, ComponentTypeEnum componentTypeEnum) throws Exception {
RestResponse restResponse;
if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
- restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getComponentType().toString());
+ restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
} else {
- restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceDetails.getUUID(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), resourceDetails.getComponentType().toString());
+ restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
}
Integer responseCode = restResponse.getErrorCode();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
index 6acc54b54c..9d56316b18 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
@@ -20,11 +20,10 @@
package org.openecomp.sdc.externalApis;
-import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -34,58 +33,27 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Rule;
import org.junit.rules.TestName;
-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.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
import org.openecomp.sdc.be.model.Component;
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.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.api.Urls;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceAssetStructure;
-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;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
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.AssetRestUtils;
-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.ci.tests.utils.validation.AuditValidationUtils;
-import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertTrue;
-
-import com.google.gson.Gson;
-
-import fj.data.Either;
public class GetCSARofVF extends ComponentBaseTest {
@@ -224,22 +192,42 @@ public class GetCSARofVF extends ComponentBaseTest {
}
-
-
-
-
+ /**
+ * all files in list(expectedDefinitionFolderFileList) must be found in csar file
+ * @param resource
+ * @param toscaModelCsarFile
+ * @throws ZipException
+ * @throws IOException
+ */
public void validateCsarContent(Component resource, File toscaModelCsarFile) throws ZipException, IOException {
ZipFile zipFile = new ZipFile(toscaModelCsarFile);
+ List<String> expectedDefinitionFolderFileList = new ArrayList<String>();
+ expectedDefinitionFolderFileList.add("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template.yml");
+ expectedDefinitionFolderFileList.add("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template-interface.yml");
+ expectedDefinitionFolderFileList.add("Definitions/relationships.yml");
+ expectedDefinitionFolderFileList.add("Definitions/policies.yml");
+ expectedDefinitionFolderFileList.add("Definitions/nodes.yml");
+ expectedDefinitionFolderFileList.add("Definitions/interfaces.yml");
+ expectedDefinitionFolderFileList.add("Definitions/groups.yml");
+ expectedDefinitionFolderFileList.add("Definitions/data.yml");
+ expectedDefinitionFolderFileList.add("Definitions/capabilities.yml");
+ expectedDefinitionFolderFileList.add("Definitions/artifacts.yml");
+
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()){
ZipEntry nextElement = entries.nextElement();
if (!(nextElement.getName().contains("Artifacts")||nextElement.getName().contains("csar.meta"))){
- assertTrue("missing file in csar template", (nextElement.getName().equals("TOSCA-Metadata/TOSCA.meta") ||
- nextElement.getName().equals("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template.yml")) ||
- nextElement.getName().equals("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template-interface.yml"));
+// assertTrue("missing file in csar template", (nextElement.getName().equals("TOSCA-Metadata/TOSCA.meta") ||
+// nextElement.getName().equals("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template.yml")) ||
+// nextElement.getName().equals("Definitions/"+ resource.getComponentType().getValue().toLowerCase()+"-"+ resource.getSystemName()+"-template-interface.yml"));
+ if(expectedDefinitionFolderFileList.contains(nextElement.getName())){
+ expectedDefinitionFolderFileList.remove(nextElement.getName());
}
}
+ }
+ zipFile.close();
+ assertTrue("missing files in csar template definitions folder", expectedDefinitionFolderFileList.size() == 0);
}
public void validateAudit(Component resource) throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
index f93958542d..6e212d3155 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
@@ -216,10 +216,10 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
// Various failure flows
@Test(dataProvider="createVfcmtVariousFailureFlows")
public void createVfcmtVariousFailureFlows(String flow) throws Exception {
-
+ //TODO: check what happens now, test will prbably fail
if(flow.equals("resource_type_missing") || flow.equals("resource_type_invalid")) {
throw new SkipException("TC require repairs");
- }
+ }
User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
ResourceExternalReqDetails defaultResource = ElementFactory.getDefaultResourceByType("ci", ResourceCategoryEnum.TEMPLATE_MONITORING_TEMPLATE, defaultUser.getUserId(), ResourceTypeEnum.VFCMT.toString());
@@ -272,21 +272,21 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
case "description_with_invalid_char":
defaultResource.setDescription("\uC2B5");
expectedResourceAuditJavaObject.setDesc("t");
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_DESCRIPTION.name());
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_TYPE.name());
variables = asList(ComponentTypeEnum.RESOURCE.getValue());
break;
// TODO: defect on the flow - need to get error instead create VFC
case "resource_type_missing":
defaultResource.setResourceType("");
expectedResourceAuditJavaObject.setResourceType("");
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name());
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
variables = asList(ComponentTypeEnum.RESOURCE.getValue());
break;
// TODO: in audit RESOURCE_NAME is empty
case "resource_type_invalid":
defaultResource.setResourceType("invalid");
expectedResourceAuditJavaObject.setResourceType(ComponentTypeEnum.RESOURCE.getValue());
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_TYPE.name());
variables = asList(ComponentTypeEnum.RESOURCE.getValue());
break;
case "category_type_missing":
@@ -377,7 +377,7 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
// create vfcmt
RestResponse restResponse = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser);
- expectedResourceAuditJavaObject.setStatus("400");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);