summaryrefslogtreecommitdiffstats
path: root/common/openecomp-sdc-artifact-generator-lib
diff options
context:
space:
mode:
Diffstat (limited to 'common/openecomp-sdc-artifact-generator-lib')
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGenerator.java6
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/service/ArtifactGenerationService.java4
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiArtifactGenerator.java2
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGeneratorImpl.java4
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/util/ArtifactGeneratorUtil.java2
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java608
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java217
7 files changed, 385 insertions, 458 deletions
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGenerator.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGenerator.java
index f3c2cb97e7..4a1e781049 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGenerator.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGenerator.java
@@ -30,15 +30,12 @@ import static org.openecomp.sdc.generator.data.GeneratorConstants.PARTNER_NAME;
import org.openecomp.sdc.generator.aai.model.Resource;
import org.openecomp.sdc.generator.aai.model.Service;
-import org.openecomp.sdc.generator.aai.model.Widget;
import org.openecomp.sdc.generator.logging.CategoryLogLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.Arrays;
public interface AaiModelGenerator {
@@ -58,8 +55,7 @@ public interface AaiModelGenerator {
MDC.put(ERROR_CODE, GENERATOR_ERROR_CODE);
MDC.put(ERROR_DESCRIPTION, GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
StringWriter sw = new StringWriter();
- exception.printStackTrace(new PrintWriter(sw));
- log.error(sw.toString());
+ log.error(sw.toString(), exception);
}
return null;
}
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/service/ArtifactGenerationService.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/service/ArtifactGenerationService.java
index 2ac25273ce..1fbd25e14e 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/service/ArtifactGenerationService.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-api/src/main/java/org/openecomp/sdc/generator/service/ArtifactGenerationService.java
@@ -65,9 +65,7 @@ public interface ArtifactGenerationService {
MDC.put(ERROR_CATEGORY, CategoryLogLevel.ERROR.name());
MDC.put(ERROR_CODE, GENERATOR_ERROR_CODE);
MDC.put(ERROR_DESCRIPTION, GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
- StringWriter sw = new StringWriter();
- exception.printStackTrace(new PrintWriter(sw));
- log.error(sw.toString());
+ log.error(GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED, exception);
}
log.debug(GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
return null;
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiArtifactGenerator.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiArtifactGenerator.java
index 26b884e465..8462a71a97 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiArtifactGenerator.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiArtifactGenerator.java
@@ -560,7 +560,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
return tosca;
} catch (Exception exception) {
throw new IllegalArgumentException(
- String.format(GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_TOSCA, input.getName()));
+ String.format(GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_TOSCA, input.getName()), exception);
}
} else {
throw new SecurityException(GeneratorConstants.GENERATOR_AAI_ERROR_CHECKSUM_MISMATCH);
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGeneratorImpl.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGeneratorImpl.java
index 7f4471c4c0..4e6153d7e4 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGeneratorImpl.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/aai/AaiModelGeneratorImpl.java
@@ -33,7 +33,6 @@ import org.openecomp.sdc.generator.aai.xml.ModelVers;
import org.openecomp.sdc.generator.aai.xml.Relationship;
import org.openecomp.sdc.generator.aai.xml.RelationshipData;
import org.openecomp.sdc.generator.aai.xml.RelationshipList;
-import org.openecomp.sdc.generator.logging.annotations.Audit;
import org.openecomp.sdc.generator.logging.annotations.Metrics;
import org.w3c.dom.DOMException;
@@ -271,12 +270,9 @@ public class AaiModelGeneratorImpl implements AaiModelGenerator {
jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
jaxbMarshaller.marshal(model, modelStringWriter);
} catch (JAXBException jaxbException) {
- //jaxbException.printStackTrace();
- log.error(jaxbException.getMessage());
throw new DOMException(DOMException.SYNTAX_ERR, jaxbException.getMessage());
}
- //System.out.println(modelStringWriter.toString());
return modelStringWriter.toString();
}
}
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/util/ArtifactGeneratorUtil.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/util/ArtifactGeneratorUtil.java
index aa3ce46013..26bbe7f619 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/util/ArtifactGeneratorUtil.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/main/java/org/openecomp/sdc/generator/util/ArtifactGeneratorUtil.java
@@ -163,7 +163,7 @@ public class ArtifactGeneratorUtil {
String hostname = ip.getHostName();
MDC.put(BE_FQDN, hostname);
} catch (UnknownHostException uhe) {
- log.error("Failed to get server FQDN");
+ log.error("Failed to get server FQDN", uhe);
}
if (log.isDebugEnabled()) {
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
index ced8acbb80..38462d05bb 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
@@ -46,11 +46,16 @@ import static org.openecomp.sdc.generator.SampleJUnitTest.additionalParams;
@SuppressWarnings("Duplicates")
public class ArtifactGenerationServiceTest {
+ public static final String RESOURCE_MAPPING_NOT_FOUND = "Resource mapping not found for ";
+ public static final String INV_UID = "-INV_UID";
+ public static final String VF_MODULE_NAMESPACE = "org.openecomp.groups.VfModule";
+ public static final String VF_MODULE_DESCRIPTION = "vf_module_description";
+ public static final String CATEGORY = "category";
static Map<String, String> resourcesVersion = new HashMap<>();
public static Properties properties = new Properties();
@SuppressWarnings("Since15")
- public static void validateName(List<Artifact> artifactList) {
+ public static void validateName(List<Artifact> artifactList) throws JAXBException {
for(Artifact artifact : artifactList){
String xml = new String(Base64.getDecoder().decode(artifact.getPayload()));
Model model = getUnmarshalledArtifactModel(xml);
@@ -90,10 +95,10 @@ public class ArtifactGenerationServiceTest {
String resourceVersion= resourcesVersion.get(toscaTemplate.getMetadata().get("UUID"));
toscaTemplate.getMetadata().put("version", resourceVersion);
if("VF".equals(toscaTemplate.getMetadata().get("type")) && !("Allotted Resource".equals
- (toscaTemplate.getMetadata().get("category"))) ){
+ (toscaTemplate.getMetadata().get(CATEGORY))) ){
testVfTosca(outputArtifactMap, toscaTemplate);
} else if("VF".equals(toscaTemplate.getMetadata().get("type")) && ("Allotted Resource".equals
- (toscaTemplate.getMetadata().get("category"))) ){
+ (toscaTemplate.getMetadata().get(CATEGORY))) ){
testAllottedResourceTosca(outputArtifactMap, toscaTemplate);
} else if("VL".equals(toscaTemplate.getMetadata().get("type"))){
testL3NetworkResourceTosca(outputArtifactMap, toscaTemplate);
@@ -102,224 +107,212 @@ public class ArtifactGenerationServiceTest {
}
public static void testVfTosca(Map<String, Model> outputArtifactMap , ToscaTemplate resourceTosca) {
- try {
- //ToscaTemplate resourceTosca = getResourceTosca(toscas);
- //resourceTosca.getTopology_template().getGroups().
- if (resourceTosca != null) {
- Resource resource = new Resource();
- resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
- String resourceNameVersionId = resource.getModelNameVersionId();
- Model resourceAAIModel =
- getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
- if (resourceAAIModel != null) {
- validateResourceModelMetadata(resource, resourceAAIModel);
- //Validate Resource instance base widget
-
- ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
-
- List<ModelElement> matchedVFBaseWidgetElements =
- getModelElementbyRelationshipValue(modelVersion.getModelElements(),
- Widget.getWidget(Widget.Type.VF).getId());
- validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
- Widget.getWidget(Widget.Type.VF).getName());
-
- validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.VF).getName(),
- Widget.getWidget(Widget.Type.VF).getWidgetId());
-
- ModelElements baseResourceWidgetModelElements =
- matchedVFBaseWidgetElements.get(0).getModelElements();
- if (resourceTosca.getTopology_template() != null) {
- Map<String, String> groupIdTypeStore = getGroupsTypeStore(resourceTosca);
-
- if (baseResourceWidgetModelElements.getModelElement().size() !=
- groupIdTypeStore.size()) {
- org.testng.Assert.fail("Missing VFModule in VF model.xml");
- }
- for (String key : groupIdTypeStore.keySet()) {
-
- List<ModelElement> matchedResourceElements =
- getModelElementbyRelationshipValue(baseResourceWidgetModelElements, key);
- validateMatchedModelElementsInService(matchedResourceElements,
- Widget.getWidget(Widget.Type.VFMODULE).getName());
- Model resourceAAIVFModel = getAAIModelByNameVersionId(key, outputArtifactMap);
- Map<String, String> vfModuleModelMetadata =
- getVFModuleMetadataTosca(resourceTosca, key);
- Map<String, Object> vfModuleMembers = getVFModuleMembersTosca(resourceTosca, key);
-
- validateVFModelMetadata(vfModuleModelMetadata, resourceAAIVFModel);
-
-
- ModelVer modelVfVersion = resourceAAIVFModel.getModelVers().getModelVer().get(0);
-
- List<ModelElement> matchedVFModuleBaseWidgetElements =
- getModelElementbyRelationshipValue(modelVfVersion.getModelElements(),
- Widget.getWidget(Widget.Type.VFMODULE).getId());
- validateMatchedModelElementsInService(matchedVFModuleBaseWidgetElements,
- Widget.getWidget(Widget.Type.VFMODULE).getName());
- validateWidgetIds(matchedVFModuleBaseWidgetElements, Widget.getWidget(Widget.Type.VFMODULE)
- .getName(), Widget.getWidget(Widget.Type.VFMODULE).getWidgetId());
-
- ModelElements baseResourceVFModuleWidgetModelElements =
- matchedVFModuleBaseWidgetElements.get(0).getModelElements();
- if (vfModuleMembers.containsKey("l3-network")) {
- //Validate l3
- List<ModelElement> matchedL3NetworkElements =
- getModelElementbyRelationshipValue(baseResourceVFModuleWidgetModelElements,
- Widget.getWidget(Widget.Type.L3_NET).getId());
- validateMatchedModelElementsInService(matchedL3NetworkElements,
- Widget.getWidget(Widget.Type.L3_NET).getName());
- validateWidgetIds(matchedL3NetworkElements, Widget.getWidget(Widget.Type.L3_NET)
- .getName(), Widget.getWidget(Widget.Type.L3_NET).getWidgetId());
- }
- if (vfModuleMembers.containsKey("vserver")) {
- //Validate vserver
- List<ModelElement> matchedVserverElements =
- getModelElementbyRelationshipValue(baseResourceVFModuleWidgetModelElements,
- Widget.getWidget(Widget.Type.VSERVER).getId());
- validateMatchedModelElementsInService(matchedVserverElements,
- Widget.getWidget(Widget.Type.VSERVER).getName());
- ModelElements vserverWidgetModelElements =
- matchedVserverElements.get(0).getModelElements();
-
- validateWidgetIds(matchedVserverElements, Widget.getWidget(Widget.Type.VSERVER)
- .getName(), Widget.getWidget(Widget.Type.VSERVER).getWidgetId());
-
-
- //Validate vserver->vfc
- List<ModelElement> matchedVfcElements =
- getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.VFC).getId());
- validateMatchedModelElementsInService(matchedVfcElements,
- Widget.getWidget(Widget.Type.VFC).getName());
- validateWidgetIds(matchedVfcElements, Widget.getWidget(Widget.Type.VFC).getName(),
- Widget.getWidget(Widget.Type.VFC).getWidgetId());
-
- //Validate vserver->Image
- List<ModelElement> matchedImageElements =
- getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.IMAGE).getId());
- validateMatchedModelElementsInService(matchedImageElements,
- Widget.getWidget(Widget.Type.IMAGE).getName());
- validateWidgetIds(matchedImageElements, Widget.getWidget(Widget.Type.IMAGE)
- .getName(), Widget.getWidget(Widget.Type.IMAGE).getWidgetId());
+ if (resourceTosca != null) {
+ Resource resource = new Resource();
+ resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
+ String resourceNameVersionId = resource.getModelNameVersionId();
+ Model resourceAAIModel =
+ getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
+ if (resourceAAIModel != null) {
+ validateResourceModelMetadata(resource, resourceAAIModel);
+ //Validate Resource instance base widget
+
+ ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
+
+ List<ModelElement> matchedVFBaseWidgetElements =
+ getModelElementbyRelationshipValue(modelVersion.getModelElements(),
+ Widget.getWidget(Widget.Type.VF).getId());
+ validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
+ Widget.getWidget(Widget.Type.VF).getName());
+
+ validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.VF).getName(),
+ Widget.getWidget(Widget.Type.VF).getWidgetId());
+
+ ModelElements baseResourceWidgetModelElements =
+ matchedVFBaseWidgetElements.get(0).getModelElements();
+ if (resourceTosca.getTopology_template() != null) {
+ Map<String, String> groupIdTypeStore = getGroupsTypeStore(resourceTosca);
+
+ if (baseResourceWidgetModelElements.getModelElement().size() !=
+ groupIdTypeStore.size()) {
+ org.testng.Assert.fail("Missing VFModule in VF model.xml");
+ }
+ for (String key : groupIdTypeStore.keySet()) {
- //Validate vserver->Flavor
- List<ModelElement> matchedFlavorElements =
+ List<ModelElement> matchedResourceElements =
+ getModelElementbyRelationshipValue(baseResourceWidgetModelElements, key);
+ validateMatchedModelElementsInService(matchedResourceElements,
+ Widget.getWidget(Widget.Type.VFMODULE).getName());
+ Model resourceAAIVFModel = getAAIModelByNameVersionId(key, outputArtifactMap);
+ Map<String, String> vfModuleModelMetadata =
+ getVFModuleMetadataTosca(resourceTosca, key);
+ Map<String, Object> vfModuleMembers = getVFModuleMembersTosca(resourceTosca, key);
+
+ validateVFModelMetadata(vfModuleModelMetadata, resourceAAIVFModel);
+
+
+ ModelVer modelVfVersion = resourceAAIVFModel.getModelVers().getModelVer().get(0);
+
+ List<ModelElement> matchedVFModuleBaseWidgetElements =
+ getModelElementbyRelationshipValue(modelVfVersion.getModelElements(),
+ Widget.getWidget(Widget.Type.VFMODULE).getId());
+ validateMatchedModelElementsInService(matchedVFModuleBaseWidgetElements,
+ Widget.getWidget(Widget.Type.VFMODULE).getName());
+ validateWidgetIds(matchedVFModuleBaseWidgetElements, Widget.getWidget(Widget.Type.VFMODULE)
+ .getName(), Widget.getWidget(Widget.Type.VFMODULE).getWidgetId());
+
+ ModelElements baseResourceVFModuleWidgetModelElements =
+ matchedVFModuleBaseWidgetElements.get(0).getModelElements();
+ if (vfModuleMembers.containsKey("l3-network")) {
+ //Validate l3
+ List<ModelElement> matchedL3NetworkElements =
+ getModelElementbyRelationshipValue(baseResourceVFModuleWidgetModelElements,
+ Widget.getWidget(Widget.Type.L3_NET).getId());
+ validateMatchedModelElementsInService(matchedL3NetworkElements,
+ Widget.getWidget(Widget.Type.L3_NET).getName());
+ validateWidgetIds(matchedL3NetworkElements, Widget.getWidget(Widget.Type.L3_NET)
+ .getName(), Widget.getWidget(Widget.Type.L3_NET).getWidgetId());
+ }
+ if (vfModuleMembers.containsKey("vserver")) {
+ //Validate vserver
+ List<ModelElement> matchedVserverElements =
+ getModelElementbyRelationshipValue(baseResourceVFModuleWidgetModelElements,
+ Widget.getWidget(Widget.Type.VSERVER).getId());
+ validateMatchedModelElementsInService(matchedVserverElements,
+ Widget.getWidget(Widget.Type.VSERVER).getName());
+ ModelElements vserverWidgetModelElements =
+ matchedVserverElements.get(0).getModelElements();
+
+ validateWidgetIds(matchedVserverElements, Widget.getWidget(Widget.Type.VSERVER)
+ .getName(), Widget.getWidget(Widget.Type.VSERVER).getWidgetId());
+
+
+ //Validate vserver->vfc
+ List<ModelElement> matchedVfcElements =
+ getModelElementbyRelationshipValue(vserverWidgetModelElements,
+ Widget.getWidget(Widget.Type.VFC).getId());
+ validateMatchedModelElementsInService(matchedVfcElements,
+ Widget.getWidget(Widget.Type.VFC).getName());
+ validateWidgetIds(matchedVfcElements, Widget.getWidget(Widget.Type.VFC).getName(),
+ Widget.getWidget(Widget.Type.VFC).getWidgetId());
+
+ //Validate vserver->Image
+ List<ModelElement> matchedImageElements =
+ getModelElementbyRelationshipValue(vserverWidgetModelElements,
+ Widget.getWidget(Widget.Type.IMAGE).getId());
+ validateMatchedModelElementsInService(matchedImageElements,
+ Widget.getWidget(Widget.Type.IMAGE).getName());
+ validateWidgetIds(matchedImageElements, Widget.getWidget(Widget.Type.IMAGE)
+ .getName(), Widget.getWidget(Widget.Type.IMAGE).getWidgetId());
+
+
+ //Validate vserver->Flavor
+ List<ModelElement> matchedFlavorElements =
+ getModelElementbyRelationshipValue(vserverWidgetModelElements,
+ Widget.getWidget(Widget.Type.FLAVOR).getId());
+ validateMatchedModelElementsInService(matchedFlavorElements,
+ Widget.getWidget(Widget.Type.FLAVOR).getName());
+ validateWidgetIds(matchedFlavorElements, Widget.getWidget(Widget.Type.FLAVOR).getName(),
+ Widget.getWidget(Widget.Type.FLAVOR).getWidgetId());
+
+ //Validate vserver->Tenant
+ List<ModelElement> matchedTenantElements =
+ getModelElementbyRelationshipValue(vserverWidgetModelElements,
+ Widget.getWidget(Widget.Type.TENANT).getId());
+ validateMatchedModelElementsInService(matchedTenantElements,
+ Widget.getWidget(Widget.Type.TENANT).getName());
+ validateWidgetIds(matchedTenantElements, Widget.getWidget(Widget.Type.TENANT).getName(),
+ Widget.getWidget(Widget.Type.TENANT).getWidgetId());
+
+ //Validate vserver->l-interface
+ if (vfModuleMembers.containsKey("l-interface")) {
+ List<ModelElement> matchedLinterfaceElements =
getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.FLAVOR).getId());
- validateMatchedModelElementsInService(matchedFlavorElements,
- Widget.getWidget(Widget.Type.FLAVOR).getName());
- validateWidgetIds(matchedFlavorElements, Widget.getWidget(Widget.Type.FLAVOR).getName(),
- Widget.getWidget(Widget.Type.FLAVOR).getWidgetId());
-
- //Validate vserver->Tenant
- List<ModelElement> matchedTenantElements =
+ Widget.getWidget(Widget.Type.LINT).getId());
+ validateMatchedModelElementsInService(matchedLinterfaceElements,
+ Widget.getWidget(Widget.Type.LINT).getName());
+ validateWidgetIds(matchedLinterfaceElements, Widget.getWidget(Widget.Type.LINT).getName(),
+ Widget.getWidget(Widget.Type.LINT).getWidgetId());
+ }
+ //Validate vserver->volume
+ if (vfModuleMembers.containsKey("volume")) {
+ List<ModelElement> matchedVolumeElements =
getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.TENANT).getId());
- validateMatchedModelElementsInService(matchedTenantElements,
- Widget.getWidget(Widget.Type.TENANT).getName());
- validateWidgetIds(matchedTenantElements, Widget.getWidget(Widget.Type.TENANT).getName(),
- Widget.getWidget(Widget.Type.TENANT).getWidgetId());
-
- //Validate vserver->l-interface
- if (vfModuleMembers.containsKey("l-interface")) {
- List<ModelElement> matchedLinterfaceElements =
- getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.LINT).getId());
- validateMatchedModelElementsInService(matchedLinterfaceElements,
- Widget.getWidget(Widget.Type.LINT).getName());
- validateWidgetIds(matchedLinterfaceElements, Widget.getWidget(Widget.Type.LINT).getName(),
- Widget.getWidget(Widget.Type.LINT).getWidgetId());
- }
- //Validate vserver->volume
- if (vfModuleMembers.containsKey("volume")) {
- List<ModelElement> matchedVolumeElements =
- getModelElementbyRelationshipValue(vserverWidgetModelElements,
- Widget.getWidget(Widget.Type.VOLUME).getId());
- validateMatchedModelElementsInService(matchedVolumeElements,
- Widget.getWidget(Widget.Type.VOLUME).getName());
- validateWidgetIds(matchedVolumeElements, Widget.getWidget(Widget.Type.VOLUME).getName(),
- Widget.getWidget(Widget.Type.VOLUME).getWidgetId());
- }
+ Widget.getWidget(Widget.Type.VOLUME).getId());
+ validateMatchedModelElementsInService(matchedVolumeElements,
+ Widget.getWidget(Widget.Type.VOLUME).getName());
+ validateWidgetIds(matchedVolumeElements, Widget.getWidget(Widget.Type.VOLUME).getName(),
+ Widget.getWidget(Widget.Type.VOLUME).getWidgetId());
}
}
}
- } else {
- System.out.println("Resource mapping not found for " + resourceNameVersionId);
}
+ } else {
+ System.out.println(RESOURCE_MAPPING_NOT_FOUND + resourceNameVersionId);
}
-
- } catch (IllegalArgumentException e) {
- org.testng.Assert.fail(e.getMessage()); //Can come while populating metadata
}
-
}
public static void testAllottedResourceTosca(Map<String, Model> outputArtifactMap , ToscaTemplate
resourceTosca) {
- try {
- if (resourceTosca != null) {
- Resource resource = new Resource();
- resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
- String resourceNameVersionId = resource.getModelNameVersionId();
- Model resourceAAIModel =
- getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
- if (resourceAAIModel != null) {
- validateResourceModelMetadata(resource, resourceAAIModel);
- //Validate Resource instance base widget
- ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
+ if (resourceTosca != null) {
+ Resource resource = new Resource();
+ resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
+ String resourceNameVersionId = resource.getModelNameVersionId();
+ Model resourceAAIModel =
+ getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
+ if (resourceAAIModel != null) {
+ validateResourceModelMetadata(resource, resourceAAIModel);
+ //Validate Resource instance base widget
- List<ModelElement> matchedVFBaseWidgetElements =
- getModelElementbyRelationshipValue(modelVersion.getModelElements(),
- Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getId());
- validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
- Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName());
+ ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
- validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName(),
- Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getWidgetId());
+ List<ModelElement> matchedVFBaseWidgetElements =
+ getModelElementbyRelationshipValue(modelVersion.getModelElements(),
+ Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getId());
+ validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
+ Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName());
- validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName(),
- Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getWidgetId());
+ validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName(),
+ Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getWidgetId());
- Map<String, Object> providingServiceDetails = getProvidingServiceDetails(resourceTosca);
+ validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName(),
+ Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getWidgetId());
- ModelElements containedModelElements = modelVersion.getModelElements().getModelElement().
- get(0).getModelElements();
+ Map<String, Object> providingServiceDetails = getProvidingServiceDetails(resourceTosca);
- org.testng.Assert.assertEquals(containedModelElements.getModelElement().get(0).getRelationshipList()
- .getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue(),
- providingServiceDetails.get("providing_service_uuid"));
+ ModelElements containedModelElements = modelVersion.getModelElements().getModelElement().
+ get(0).getModelElements();
- org.testng.Assert.assertEquals(containedModelElements.getModelElement().get(0).getRelationshipList()
- .getRelationship().get(0).getRelationshipData().get(1).getRelationshipValue(),
- providingServiceDetails.get("providing_service_invariant_uuid"));
+ org.testng.Assert.assertEquals(containedModelElements.getModelElement().get(0).getRelationshipList()
+ .getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue(),
+ providingServiceDetails.get("providing_service_uuid"));
+ org.testng.Assert.assertEquals(containedModelElements.getModelElement().get(0).getRelationshipList()
+ .getRelationship().get(0).getRelationshipData().get(1).getRelationshipValue(),
+ providingServiceDetails.get("providing_service_invariant_uuid"));
- if("Allotted Resource".equals(resourceTosca.getMetadata().get("category")) &&
- "Tunnel XConnect".equals(resourceTosca.getMetadata().get("subcategory"))) {
- List<ModelElement> matchedTunnelXConnectWidgetElements =
- getModelElementbyRelationshipValue(containedModelElements,
- Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getId());
- validateMatchedModelElementsInService(matchedTunnelXConnectWidgetElements,
- Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getName());
+ if("Allotted Resource".equals(resourceTosca.getMetadata().get(CATEGORY)) &&
+ "Tunnel XConnect".equals(resourceTosca.getMetadata().get("subcategory"))) {
- validateWidgetIds(matchedTunnelXConnectWidgetElements, Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getName(),
- Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getWidgetId());
- }
+ List<ModelElement> matchedTunnelXConnectWidgetElements =
+ getModelElementbyRelationshipValue(containedModelElements,
+ Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getId());
+ validateMatchedModelElementsInService(matchedTunnelXConnectWidgetElements,
+ Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getName());
- }else {
- System.out.println("Resource mapping not found for " + resourceNameVersionId);
+ validateWidgetIds(matchedTunnelXConnectWidgetElements, Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getName(),
+ Widget.getWidget(Widget.Type.TUNNEL_XCONNECT).getWidgetId());
}
- }
- }catch (IllegalArgumentException e) {
- org.testng.Assert.fail(e.getMessage()); //Can come while populating metadata
+ }else {
+ System.out.println(RESOURCE_MAPPING_NOT_FOUND + resourceNameVersionId);
+ }
}
-
}
public static Map<String, Object> getProvidingServiceDetails(ToscaTemplate resourceTemplate) {
@@ -329,7 +322,7 @@ public class ArtifactGenerationServiceTest {
for(String key : keys) {
NodeTemplate node = resourceTemplate.getTopology_template().getNode_templates().get(key);
if(node.getType().contains("org.openecomp.resource.vfc") &&
- node.getMetadata().get("category").equals("Allotted Resource")) {
+ node.getMetadata().get(CATEGORY).equals("Allotted Resource")) {
nodeProperties = node.getProperties();
}
}
@@ -339,114 +332,102 @@ public class ArtifactGenerationServiceTest {
public static void testL3NetworkResourceTosca(Map<String, Model> outputArtifactMap , ToscaTemplate
resourceTosca) {
- try {
- if (resourceTosca != null) {
- Resource resource = new Resource();
- resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
- String resourceNameVersionId = resource.getModelNameVersionId();
- Model resourceAAIModel =
- getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
- if (resourceAAIModel != null) {
- validateResourceModelMetadata(resource, resourceAAIModel);
- //Validate Resource instance base widget
-
- ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
-
- List<ModelElement> matchedVFBaseWidgetElements =
- getModelElementbyRelationshipValue(modelVersion.getModelElements(),
- Widget.getWidget(Widget.Type.L3_NET).getId());
- validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
- Widget.getWidget(Widget.Type.L3_NET).getName());
-
- validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.L3_NET).getName(),
- Widget.getWidget(Widget.Type.L3_NET).getWidgetId());
- }else {
- System.out.println("Resource mapping not found for " + resourceNameVersionId);
- }
+ if (resourceTosca != null) {
+ Resource resource = new Resource();
+ resource.populateModelIdentificationInformation(resourceTosca.getMetadata());
+ String resourceNameVersionId = resource.getModelNameVersionId();
+ Model resourceAAIModel =
+ getAAIModelByNameVersionId(resourceNameVersionId, outputArtifactMap);
+ if (resourceAAIModel != null) {
+ validateResourceModelMetadata(resource, resourceAAIModel);
+ //Validate Resource instance base widget
+
+ ModelVer modelVersion = resourceAAIModel.getModelVers().getModelVer().get(0);
+
+ List<ModelElement> matchedVFBaseWidgetElements =
+ getModelElementbyRelationshipValue(modelVersion.getModelElements(),
+ Widget.getWidget(Widget.Type.L3_NET).getId());
+ validateMatchedModelElementsInService(matchedVFBaseWidgetElements,
+ Widget.getWidget(Widget.Type.L3_NET).getName());
+
+ validateWidgetIds(matchedVFBaseWidgetElements, Widget.getWidget(Widget.Type.L3_NET).getName(),
+ Widget.getWidget(Widget.Type.L3_NET).getWidgetId());
+
+ }else {
+ System.out.println(RESOURCE_MAPPING_NOT_FOUND + resourceNameVersionId);
}
-
- }catch (IllegalArgumentException e) {
- org.testng.Assert.fail(e.getMessage()); //Can come while populating metadata
}
-
}
public static void testServiceTosca(Map<String, Model> outputArtifactMap,List<ToscaTemplate>
toscas) {
- try {
- ToscaTemplate serviceTosca = getServiceTosca(toscas);
- if (serviceTosca == null) {
- org.testng.Assert.fail("Service Tosca not found");
- }
- serviceTosca.getMetadata().put("version", additionalParams.get(AdditionalParams
- .ServiceVersion.getName()));
- Service service = new Service();
- service.populateModelIdentificationInformation(serviceTosca.getMetadata());
- String serviceNameVersionId = service.getModelNameVersionId();
- Model serviceAAIModel = getAAIModelByNameVersionId(serviceNameVersionId, outputArtifactMap);
- validateServiceModelMetadata(service, serviceAAIModel);
- //Validate Service instance base widget
- ModelVer modelVersion = serviceAAIModel.getModelVers().getModelVer().get(0);
-
- List<ModelElement> matchedServiceBaseWidgetElements =
- getModelElementbyRelationshipValue( modelVersion.getModelElements(),
- Widget.getWidget(Widget.Type.SERVICE).getId());
- validateMatchedModelElementsInService(matchedServiceBaseWidgetElements,
- Widget.getWidget(Widget.Type.SERVICE).getName());
-
- validateWidgetIds(matchedServiceBaseWidgetElements, Widget.getWidget(Widget.Type.SERVICE).getName(),
- Widget.getWidget(Widget.Type.SERVICE).getWidgetId());
-
- ModelElements baseServiceWidgetModelElements =
- matchedServiceBaseWidgetElements.get(0).getModelElements();
-
-
- Map<String, String> nodeTemplateIdTypeStore = getNodeTemplateTypeStore(serviceTosca);
- if (nodeTemplateIdTypeStore != null) {
- for (String key : nodeTemplateIdTypeStore.keySet()) {
- if (nodeTemplateIdTypeStore.get(key).contains("org.openecomp.resource.vf")) {
- List<ModelElement> matchedResourceElements =
- getModelElementbyRelationshipValue(baseServiceWidgetModelElements, key);
- if (nodeTemplateIdTypeStore.get(key).contains("org.openecomp.resource.vf.allottedResource")){
- validateMatchedModelElementsInService(matchedResourceElements,
- Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName());
- }else {
- validateMatchedModelElementsInService(matchedResourceElements,
- Widget.getWidget(Widget.Type.VF).getName());
- }
- //Validate uuid and invariantuuid are populated in model-ver.model-version-id and model.model-invariant-id
- org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList()
- .getRelationship().get(0)
- .getRelationshipData().get(0).getRelationshipValue(),key);
-
- org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList().getRelationship().get(0)
- .getRelationshipData().get(1).getRelationshipValue(), nodeTemplateIdTypeStore
- .get(key+"-INV_UID"));
- } else if(nodeTemplateIdTypeStore.get(key).contains("org.openecomp.resource.vl")){
- //validate l3-network in service tosca
- List<ModelElement> matchedResourceElements =
- getModelElementbyRelationshipValue(baseServiceWidgetModelElements, key);
+ ToscaTemplate serviceTosca = getServiceTosca(toscas);
+ if (serviceTosca == null) {
+ org.testng.Assert.fail("Service Tosca not found");
+ }
+ serviceTosca.getMetadata().put("version", additionalParams.get(AdditionalParams
+ .ServiceVersion.getName()));
+ Service service = new Service();
+ service.populateModelIdentificationInformation(serviceTosca.getMetadata());
+ String serviceNameVersionId = service.getModelNameVersionId();
+ Model serviceAAIModel = getAAIModelByNameVersionId(serviceNameVersionId, outputArtifactMap);
+ validateServiceModelMetadata(service, serviceAAIModel);
+ //Validate Service instance base widget
+ ModelVer modelVersion = serviceAAIModel.getModelVers().getModelVer().get(0);
+
+ List<ModelElement> matchedServiceBaseWidgetElements =
+ getModelElementbyRelationshipValue( modelVersion.getModelElements(),
+ Widget.getWidget(Widget.Type.SERVICE).getId());
+ validateMatchedModelElementsInService(matchedServiceBaseWidgetElements,
+ Widget.getWidget(Widget.Type.SERVICE).getName());
+
+ validateWidgetIds(matchedServiceBaseWidgetElements, Widget.getWidget(Widget.Type.SERVICE).getName(),
+ Widget.getWidget(Widget.Type.SERVICE).getWidgetId());
+
+ ModelElements baseServiceWidgetModelElements =
+ matchedServiceBaseWidgetElements.get(0).getModelElements();
+
+
+ Map<String, String> nodeTemplateIdTypeStore = getNodeTemplateTypeStore(serviceTosca);
+ if (nodeTemplateIdTypeStore != null) {
+ for (Map.Entry<String, String> entry : nodeTemplateIdTypeStore.entrySet()) {
+ if (entry.getValue().contains("org.openecomp.resource.vf")) {
+ List<ModelElement> matchedResourceElements =
+ getModelElementbyRelationshipValue(baseServiceWidgetModelElements, entry.getKey());
+ if (entry.getValue().contains("org.openecomp.resource.vf.allottedResource")){
validateMatchedModelElementsInService(matchedResourceElements,
- Widget.getWidget(Widget.Type.L3_NET).getName());
- //Validate uuid and invariantuuid are populated in model-ver.model-version-id and model.model-invariant-id
- org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList()
- .getRelationship().get(0)
- .getRelationshipData().get(0).getRelationshipValue(),key);
-
- org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList().getRelationship().get(0)
- .getRelationshipData().get(1).getRelationshipValue(), nodeTemplateIdTypeStore
- .get(key+"-INV_UID"));
+ Widget.getWidget(Widget.Type.ALLOTTED_RESOURCE).getName());
+ }else {
+ validateMatchedModelElementsInService(matchedResourceElements,
+ Widget.getWidget(Widget.Type.VF).getName());
}
- }
-
-
- System.out.println();
+ //Validate uuid and invariantuuid are populated in model-ver.model-version-id and model.model-invariant-id
+ org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList()
+ .getRelationship().get(0)
+ .getRelationshipData().get(0).getRelationshipValue(),entry.getKey());
+
+ org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList().getRelationship().get(0)
+ .getRelationshipData().get(1).getRelationshipValue(), nodeTemplateIdTypeStore
+ .get(entry.getKey()+ INV_UID));
+ } else if(entry.getValue().contains("org.openecomp.resource.vl")){
+ //validate l3-network in service tosca
+ List<ModelElement> matchedResourceElements =
+ getModelElementbyRelationshipValue(baseServiceWidgetModelElements, entry.getKey());
+ validateMatchedModelElementsInService(matchedResourceElements,
+ Widget.getWidget(Widget.Type.L3_NET).getName());
+ //Validate uuid and invariantuuid are populated in model-ver.model-version-id and model.model-invariant-id
+ org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList()
+ .getRelationship().get(0)
+ .getRelationshipData().get(0).getRelationshipValue(),entry.getKey());
+
+ org.testng.Assert.assertEquals(matchedResourceElements.get(0).getRelationshipList().getRelationship().get(0)
+ .getRelationshipData().get(1).getRelationshipValue(), nodeTemplateIdTypeStore
+ .get(entry.getKey() + INV_UID));
+ }
}
- } catch (IllegalArgumentException e) {
- org.testng.Assert.fail(e.getMessage()); //Can come while populating metadata
}
}
@@ -486,7 +467,7 @@ public class ArtifactGenerationServiceTest {
}
}
if(e.getValue().getType().contains("org.openecomp.resource.vf.")&& (e.getValue()
- .getMetadata().get("category").equals("Allotted Resource")))
+ .getMetadata().get(CATEGORY).equals("Allotted Resource")))
{
e.getValue().setType("org.openecomp.resource.vf.allottedResource");
}
@@ -495,7 +476,7 @@ public class ArtifactGenerationServiceTest {
("version"));
//Populate invraintUuId for V9
String invUuId = e.getValue().getMetadata().get("invariantUUID");
- nodeTemplateIdTypeStore.put(uuid+"-INV_UID" , invUuId);
+ nodeTemplateIdTypeStore.put(uuid + INV_UID , invUuId);
}
}
return nodeTemplateIdTypeStore;
@@ -511,7 +492,7 @@ public class ArtifactGenerationServiceTest {
Map<String, String> groupDefinitionIdTypeStore = new LinkedHashMap<>();
if (groupDefinitionMap != null) {
for (Map.Entry<String, GroupDefinition> e : groupDefinitionMap.entrySet()) {
- if (e.getValue().getType().contains("org.openecomp.groups.VfModule")) {
+ if (e.getValue().getType().contains(VF_MODULE_NAMESPACE)) {
String uuid = e.getValue().getMetadata().get("vfModuleModelUUID");
if (GeneratorUtil.isEmpty(uuid)) {
uuid = e.getValue().getMetadata().get("UUID");
@@ -561,7 +542,7 @@ public class ArtifactGenerationServiceTest {
.getModelVer().get(0).getModelName());
Assert.assertEquals(vfModuleModelMetadata.get("vfModuleModelVersion"), generatedAAIModel.getModelVers()
.getModelVer().get(0).getModelVersion());
- Assert.assertEquals(vfModuleModelMetadata.get("vf_module_description"), generatedAAIModel.getModelVers()
+ Assert.assertEquals(vfModuleModelMetadata.get(VF_MODULE_DESCRIPTION), generatedAAIModel.getModelVers()
.getModelVer().get(0).getModelDescription());
}
@@ -590,7 +571,7 @@ public class ArtifactGenerationServiceTest {
return matchedModelElements;
}
- public static void populateAAIGeneratedModelStore(Map<String, Model> outputArtifactMap,List<Artifact> resultData) {
+ public static void populateAAIGeneratedModelStore(Map<String, Model> outputArtifactMap,List<Artifact> resultData) throws JAXBException {
for (Artifact outputArtifact : resultData) {
if (outputArtifact.getType().equals(ArtifactType.MODEL_INVENTORY_PROFILE.name())) {
byte[] decodedPayload = GeneratorUtil.decoder(outputArtifact.getPayload());
@@ -600,20 +581,16 @@ public class ArtifactGenerationServiceTest {
}
}
- private static Model getUnmarshalledArtifactModel(String aaiModel) {
+ private static Model getUnmarshalledArtifactModel(String aaiModel) throws JAXBException {
JAXBContext jaxbContext;
- try {
- jaxbContext = JAXBContext.newInstance(Model.class);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- try (InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes())) {
- return (Model) unmarshaller.unmarshal(aaiModelStream);
- } catch (IOException ignored) { /* ignore */ }
+ jaxbContext = JAXBContext.newInstance(Model.class);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- } catch (JAXBException e) {
- e.printStackTrace();
- }
- return null;
+ try (InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes())) {
+ return (Model) unmarshaller.unmarshal(aaiModelStream);
+ } catch (IOException ignored) { /* ignore */ }
+ throw new RuntimeException("could not resolve artifact model");
}
/**
@@ -635,28 +612,15 @@ public class ArtifactGenerationServiceTest {
}
- private static ToscaTemplate getResourceTosca(List<ToscaTemplate> input) {
- Iterator<ToscaTemplate> iter = input.iterator();
- while (iter.hasNext()) {
- ToscaTemplate tosca = iter.next();
- if (!tosca.isService()) {
- iter.remove();
- return tosca;
- }
- }
- return null;
- }
-
-
private static Map<String, String> getVFModuleMetadataTosca(ToscaTemplate toscaTemplate, String vfModuleModelUUID) {
Map<String, GroupDefinition> groupDefinitionMap = toscaTemplate.getTopology_template().getGroups();
Map<String, String> vfModuleModelMetadata = new LinkedHashMap<>();
for (Map.Entry<String, GroupDefinition> e : groupDefinitionMap.entrySet()) {
- if (e.getValue().getType().contains("org.openecomp.groups.VfModule")) {
+ if (e.getValue().getType().contains(VF_MODULE_NAMESPACE)) {
String uuid = e.getValue().getMetadata().get("vfModuleModelUUID");
if (uuid == vfModuleModelUUID) {
vfModuleModelMetadata = e.getValue().getMetadata();
- vfModuleModelMetadata.put("vf_module_description", (String) e.getValue().getProperties().get("vf_module_description"));
+ vfModuleModelMetadata.put(VF_MODULE_DESCRIPTION, (String) e.getValue().getProperties().get(VF_MODULE_DESCRIPTION));
}
}
}
@@ -667,9 +631,9 @@ public class ArtifactGenerationServiceTest {
Map<String, GroupDefinition> groupDefinitionMap = toscaTemplate.getTopology_template().getGroups();
Map<String, NodeTemplate> nodeTemplateMaps = toscaTemplate.getTopology_template().getNode_templates();
Map<String, Object> vfModuleMembers = new LinkedHashMap<>();
- List<String> vfModuleModelMetadata = new ArrayList<>();
+ List<String> vfModuleModelMetadata;
for (Map.Entry<String, GroupDefinition> e : groupDefinitionMap.entrySet()) {
- if (e.getValue().getType().contains("org.openecomp.groups.VfModule")) {
+ if (e.getValue().getType().contains(VF_MODULE_NAMESPACE)) {
String uuid = e.getValue().getMetadata().get("vfModuleModelUUID");
if (uuid == vfModuleModelUUID) {
vfModuleModelMetadata = e.getValue().getMembers();
@@ -697,7 +661,7 @@ public class ArtifactGenerationServiceTest {
private static String membersType(String toscaType) {
String modelToBeReturned = null;
- while (toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null) {
+ while (toscaType != null && toscaType.lastIndexOf('.') != -1 && modelToBeReturned == null) {
switch (toscaType) {
@@ -714,7 +678,7 @@ public class ArtifactGenerationServiceTest {
case "org.openecomp.resource.vf":
modelToBeReturned = "generic-vnf";
break;
- case "org.openecomp.groups.VfModule":
+ case VF_MODULE_NAMESPACE:
modelToBeReturned = "vf-module";
break;
case "org.openecomp.resource.vfc.nodes.heat.cinder":
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
index 6d44a37a92..089d773f94 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
@@ -38,32 +38,39 @@ import static org.openecomp.sdc.generator.data.GeneratorConstants.*;
public class SampleJUnitTest extends TestCase {
- public static final String aaiArtifactType = ArtifactType.AAI.name();
- public static final String aaiArtifactGroupType = GroupType.DEPLOYMENT.name();
- public static final String generatorConfig = "{\"artifactTypes\": [\"OTHER\",\"AAI\"]}";
- public static final String ARTIFACTGENERATOR_CONFIG = "artifactgenerator.config";
- public static final String CONFIG_PATH = "/qa-test-repo/jmeter3/apache-jmeter-3" +
+ private static final String AAI_ARTIFACT_TYPE = ArtifactType.AAI.name();
+ private static final String AAI_ARTIFACT_GROUP_TYPE = GroupType.DEPLOYMENT.name();
+ private static final String GENERATOR_CONFIG = "{\"artifactTypes\": [\"OTHER\",\"AAI\"]}";
+ private static final String ARTIFACT_GENERATOR_CONFIG = "artifactgenerator.config";
+ private static final String CONFIG_PATH = "/qa-test-repo/jmeter3/apache-jmeter-3" +
".0/lib/junit/";
- //public static final String CONFIG_PATH ="C:\\Jmeter-Copy\\jmeter3\\apache-jmeter-3" +
- //".0\\lib\\junit\\";
- public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
+ private static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
"Cannot generate artifacts. Widget configuration not found for %s";
- public static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND =
+ private static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND =
"Cannot generate artifacts. Artifact Generator Configuration file not found at %s";
- public static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND =
+ private static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND =
"Cannot generate artifacts. artifactgenerator.config system property not configured";
- public static final String INVALID_VALUE_INVARIANT =
+ private static final String INVALID_VALUE_INVARIANT =
"Invalid value for mandatory attribute <invariantUUID> in Artifact";
- public static final String INVALID_VALUE_UUID =
+ private static final String INVALID_VALUE_UUID =
"Invalid value for mandatory attribute <UUID> in Artifact:";
- public static final Map<String, String> additionalParams = new HashMap<>();
+ static final Map<String, String> additionalParams = new HashMap<>();
+ public static final String ARTIFACT_GENERATOR_PROPERTIES = "Artifact-Generator.properties";
+ public static final String VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML = "vf_vmme_template_NoSystemPropConfigured.yml";
+ public static final String SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML = "service_vmme_template_NoSystemPropConfigured.yml";
static{
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1.0");
}
+ public SampleJUnitTest(String name) throws IOException {
+ super(name);
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
+ loadConfig(ArtifactGenerationServiceTest.properties);
+ }
+
private void loadConfig(Properties properties) throws IOException {
- String configLocation = System.getProperty(ARTIFACTGENERATOR_CONFIG);
+ String configLocation = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
if (configLocation != null) {
File file = new File(configLocation);
if (file.exists()) {
@@ -74,15 +81,10 @@ public class SampleJUnitTest extends TestCase {
}
}
}
- public SampleJUnitTest(String name) throws Exception {
- super(name);
- System.setProperty(ARTIFACTGENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator.properties");
- loadConfig(ArtifactGenerationServiceTest.properties);
- }
public SampleJUnitTest() {
super();
- System.setProperty(ARTIFACTGENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator.properties");
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
}
@Test
@@ -95,7 +97,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -128,7 +130,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -161,7 +163,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -180,7 +182,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts2, "service_vmme_template_SameWidget2.yml");
ArtifactGenerationServiceImpl obj2 = new ArtifactGenerationServiceImpl();
- GenerationData data2 = obj2.generateArtifact(inputArtifacts2, generatorConfig,additionalParams);
+ GenerationData data2 = obj2.generateArtifact(inputArtifacts2, GENERATOR_CONFIG,additionalParams);
List<Artifact> resultData2 = data2.getResultData();
List<ToscaTemplate> toscas2 = new LinkedList();
@@ -210,8 +212,8 @@ public class SampleJUnitTest extends TestCase {
}
}
Assert.assertEquals(map.size(),map2.size());
- for(String name : map.keySet()){
- Assert.assertEquals(map.get(name),map2.get(name));
+ for(Map.Entry<String, String> entry : map.entrySet()){
+ Assert.assertEquals(entry.getValue(), map2.get(entry.getKey()));
}
} catch (Exception e) {
@@ -223,7 +225,6 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationMulVFModule() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- String[] resourceFileList = {};
readPayloadFromResource(inputArtifacts, "vf_vmme_template_MulVFVFMod.yml");
readPayloadFromResource(inputArtifacts, "service_vmme_template_MulVFVFMod.yml");
@@ -231,7 +232,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -270,7 +271,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -303,7 +304,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -336,7 +337,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -368,7 +369,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -400,7 +401,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -431,7 +432,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts, "service_vmme_template_NullFields.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals("Invalid Service/Resource definition mandatory attribute <UUID> missing in Artifact: <"+inputArtifacts.get(0).getName()+">",data.getErrorData().get("AAI").get(0));
@@ -439,7 +440,6 @@ public class SampleJUnitTest extends TestCase {
Assert.assertEquals(2,data.getResultData().size());
} catch (Exception e) {
- e.printStackTrace();
Assert.fail(e.getMessage());
}
}
@@ -459,7 +459,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals("Invalid format for Tosca YML : "+inputArtifacts.get(1).getName(),data.getErrorData().get("AAI").get(0));
@@ -481,7 +481,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -517,7 +517,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -549,7 +549,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -587,7 +587,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -606,7 +606,6 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceTest.validateName(data.getResultData());
} catch (Exception e) {
- e.printStackTrace();
Assert.fail(e.getMessage());
}
}
@@ -618,7 +617,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals("Service tosca missing from list of input artifacts",data.getErrorData().get("AAI").get(0));
@@ -665,7 +664,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -699,7 +698,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -733,7 +732,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -775,7 +774,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -811,7 +810,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -851,7 +850,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -891,7 +890,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -929,7 +928,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -971,7 +970,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1004,7 +1003,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals(INVALID_VALUE_INVARIANT + ": <" +inputArtifacts.get(1).getName()+">",data.getErrorData().get("AAI").get(0));
@@ -1012,7 +1011,6 @@ public class SampleJUnitTest extends TestCase {
Assert.assertEquals(2,data.getResultData().size());
} catch (Exception e) {
- e.printStackTrace();
Assert.fail(e.getMessage());
}
}
@@ -1026,7 +1024,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals(INVALID_VALUE_UUID + " <"
@@ -1035,26 +1033,24 @@ public class SampleJUnitTest extends TestCase {
Assert.assertEquals(2,data.getResultData().size());
} catch (Exception e) {
- e.printStackTrace();
Assert.fail(e.getMessage());
}
}
@Test
- public void testErrorWhenNoSystemPropConfigured() throws Exception {
- String configLoc = System.getProperty(ARTIFACTGENERATOR_CONFIG);
+ public void testErrorWhenNoSystemPropConfigured() {
+ String configLoc = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
try {
List<Artifact> inputArtifacts = new ArrayList();
- readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- System.clearProperty(ARTIFACTGENERATOR_CONFIG);
+ System.clearProperty(ARTIFACT_GENERATOR_CONFIG);
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
Assert.assertEquals(data.getErrorData().
get("AAI").get(0), GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND);
@@ -1062,48 +1058,46 @@ public class SampleJUnitTest extends TestCase {
Assert.fail(e.getMessage());
}
finally{
- System.setProperty(ARTIFACTGENERATOR_CONFIG,configLoc);
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc);
}
}
@Test
- public void testErrorWhenNoFileAtConfigLocation() throws Exception {
- String configLoc = System.getProperty(ARTIFACTGENERATOR_CONFIG);
+ public void testErrorWhenNoFileAtConfigLocation() {
+ String configLoc = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
try {
List<Artifact> inputArtifacts = new ArrayList();
- readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- System.setProperty(ARTIFACTGENERATOR_CONFIG,configLoc + File.separator + "testErrorWhenNoFileAtConfigLocation");
- Map<String, Model> outputArtifactMap = new HashMap<>();
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc + File.separator + "testErrorWhenNoFileAtConfigLocation");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format(
GENERATOR_AAI_CONFIGFILE_NOT_FOUND,System.getProperty
- (ARTIFACTGENERATOR_CONFIG)));
+ (ARTIFACT_GENERATOR_CONFIG)));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
finally{
- System.setProperty(ARTIFACTGENERATOR_CONFIG,configLoc);
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc);
}
}
@Test
- public void testErrorWhenNoWidgetInConfig() throws Exception {
- System.setProperty(ARTIFACTGENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator1.properties");
+ public void testErrorWhenNoWidgetInConfig() throws IOException {
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator1.properties");
loadConfig(ArtifactGenerationServiceTest.properties);
try {
List<Artifact> inputArtifacts = new ArrayList();
- readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
+ readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
String assertMsg = ArtifactType.AAI.name() + ".model-version-id." + Widget.getWidget
(Widget.Type.SERVICE).getName();
@@ -1114,13 +1108,13 @@ public class SampleJUnitTest extends TestCase {
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
- System.setProperty(ARTIFACTGENERATOR_CONFIG, CONFIG_PATH+"Artifact-Generator.properties");
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG, CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
loadConfig(ArtifactGenerationServiceTest.properties);
}
}
@Test
- public void testArtifactGenerationWithUpdatedUUIDInConfig() throws Exception {
+ public void testArtifactGenerationWithUpdatedUUIDInConfig() throws IOException {
try {
List<Artifact> inputArtifacts = new ArrayList();
readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithUpdatedUUIDInConfig.yml");
@@ -1128,7 +1122,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts, "service_vmme_template_WithUpdatedUUIDInConfig.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
List<ToscaTemplate> toscas = new LinkedList();
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1139,14 +1133,14 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
testResourceTosca(toscas.iterator(), outputArtifactMap);
- System.setProperty(ARTIFACTGENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator2.properties");
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator2.properties");
loadConfig(ArtifactGenerationServiceTest.properties);
List<ToscaTemplate> toscas2 = new LinkedList();
for (Artifact inputArtifact : inputArtifacts) {
toscas2.add(getToscaModel(inputArtifact));
}
- GenerationData data2 = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Map<String, Model> outputArtifactMap2 = new HashMap<>();
ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap2,
data2.getResultData());
@@ -1156,7 +1150,7 @@ public class SampleJUnitTest extends TestCase {
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
- System.setProperty(ARTIFACTGENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator.properties");
+ System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
loadConfig(ArtifactGenerationServiceTest.properties);
}
}
@@ -1170,8 +1164,7 @@ public class SampleJUnitTest extends TestCase {
readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, new HashMap<String, String>());
- List<Artifact> resultData = data.getResultData();
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, new HashMap<String, String>());
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION);
@@ -1190,23 +1183,20 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1");
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
- List<Artifact> resultData = data.getResultData();
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),GENERATOR_AAI_INVALID_SERVICE_VERSION);
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"0.1");
- GenerationData data2 = obj.generateArtifact(inputArtifacts, generatorConfig,
+ GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
additionalParams);
- List<Artifact> resultData2 = data.getResultData();
Assert.assertEquals(data2.getErrorData().isEmpty(),false);
Assert.assertEquals(data2.getErrorData().get("AAI").get(0),
GENERATOR_AAI_INVALID_SERVICE_VERSION);
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"0.0");
- GenerationData data3 = obj.generateArtifact(inputArtifacts, generatorConfig,
+ GenerationData data3 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
additionalParams);
- List<Artifact> resultData3 = data.getResultData();
Assert.assertEquals(data3.getErrorData().isEmpty(),false);
Assert.assertEquals(data3.getErrorData().get("AAI").get(0),
GENERATOR_AAI_INVALID_SERVICE_VERSION);
@@ -1228,7 +1218,7 @@ public class SampleJUnitTest extends TestCase {
List<ToscaTemplate> toscas = new LinkedList();
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"9.0");
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1270,8 +1260,7 @@ public class SampleJUnitTest extends TestCase {
toscas.add(getToscaModel(inputArtifact));
}
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
- List<Artifact> resultData = data.getResultData();
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),
String.format(GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA,
@@ -1280,9 +1269,8 @@ public class SampleJUnitTest extends TestCase {
inputArtifacts.remove(1);
readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyResourceVersionFormat2.yml");
- GenerationData data2 = obj.generateArtifact(inputArtifacts, generatorConfig,
+ GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
additionalParams);
- List<Artifact> resultData2 = data2.getResultData();
Assert.assertEquals(data2.getErrorData().isEmpty(),false);
Assert.assertEquals(data2.getErrorData().get("AAI").get(0),
String.format(GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA,
@@ -1306,8 +1294,7 @@ public class SampleJUnitTest extends TestCase {
toscas.add(getToscaModel(inputArtifact));
}
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
- List<Artifact> resultData = data.getResultData();
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format(GENERATOR_AAI_ERROR_NULL_RESOURCE_VERSION_IN_SERVICE_TOSCA,toscas.get(0).getMetadata().get("UUID")));
} catch (Exception e) {
@@ -1330,9 +1317,8 @@ public class SampleJUnitTest extends TestCase {
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
}
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
- List<Artifact> resultData = data.getResultData();
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format
(GENERATOR_AAI_PROVIDING_SERVICE_MISSING, toscas.get(1).getModelId()));
@@ -1354,7 +1340,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1391,7 +1377,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1427,7 +1413,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1465,7 +1451,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
@@ -1509,8 +1495,7 @@ public class SampleJUnitTest extends TestCase {
toscas.add(getToscaModel(inputArtifact));
}
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
- List<Artifact> resultData = data.getResultData();
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
Assert.assertEquals(data.getErrorData().isEmpty(),false);
Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format
(GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING, toscas.get(2).getModelId()));
@@ -1537,7 +1522,7 @@ public class SampleJUnitTest extends TestCase {
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
- GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
+ GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
for (Artifact inputArtifact : inputArtifacts) {
toscas.add(getToscaModel(inputArtifact));
}
@@ -1563,12 +1548,10 @@ public class SampleJUnitTest extends TestCase {
fis.read(payload);
String checksum = GeneratorUtil.checkSum(payload);
byte[] encodedPayload = GeneratorUtil.encode(payload);
- Artifact artifact = new Artifact(aaiArtifactType, aaiArtifactGroupType, checksum, encodedPayload);
+ Artifact artifact = new Artifact(AAI_ARTIFACT_TYPE, AAI_ARTIFACT_GROUP_TYPE, checksum, encodedPayload);
artifact.setName(fileName);
artifact.setLabel(fileName);
artifact.setDescription(fileName);
- //artifact.setVersion("1.0");
- System.out.println(artifact.getName());
inputArtifacts.add(artifact);
}
@@ -1580,14 +1563,13 @@ public class SampleJUnitTest extends TestCase {
* @return Translated {@link ToscaTemplate tosca} object
* @throws SecurityException
*/
- public static ToscaTemplate getToscaModel(Artifact input) throws SecurityException {
+ public static ToscaTemplate getToscaModel(Artifact input) {
byte[] decodedInput = GeneratorUtil.decoder(input.getPayload());
String checksum = GeneratorUtil.checkSum(decodedInput);
if (checksum.equals(input.getChecksum())) {
try {
return GeneratorUtil.translateTosca(new String(decodedInput), ToscaTemplate.class);
} catch (Exception e) {
- e.printStackTrace();
throw new IllegalArgumentException(String.format(GENERATOR_AAI_ERROR_INVALID_TOSCA, input.getName()));
}
} else {
@@ -1603,15 +1585,6 @@ public class SampleJUnitTest extends TestCase {
}
}
- /*public static void testResourceTosca(Iterator<ToscaTemplate> itr, Map<String, Model> outputArtifactMap) {
- while(itr.hasNext()){
- ToscaTemplate toscaTemplate = itr.next();
- if("VF".equals(toscaTemplate.getMetadata().get("type"))){
- ArtifactGenerationServiceTest.testResourceTosca(outputArtifactMap, toscaTemplate);
- }
- }
- }*/
-
private void readPayloadFromResource(List<Artifact> inputArtifacts, String fileName) throws IOException {
try (InputStream fis = SampleJUnitTest.class.getResourceAsStream("/" + fileName)) {