aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java9
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java42
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java29
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java84
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java10
-rw-r--r--src/test/resources/csars/resource-Policy-csar.csarbin27747 -> 0 bytes
-rw-r--r--src/test/resources/csars/service-AlService-csar.csarbin37565 -> 0 bytes
7 files changed, 58 insertions, 116 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index b65d70b..1695671 100644
--- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -36,8 +36,7 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper resolveReqsCapsCsarQA;
static ISdcCsarHelper portMirroring;
static ISdcCsarHelper csarHelperServiceWithCrs;
- static ISdcCsarHelper csarHelperServicePolicy;
- static ISdcCsarHelper csarHelperVfPolicy;
+
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@@ -60,10 +59,8 @@ public abstract class SdcToscaParserBasicTest {
resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
- csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
- csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
-
- fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
+
+ fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> FDNT ;
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java
index b815064..b57522d 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java
@@ -6,15 +6,13 @@ import org.testng.annotations.Test;
import org.openecomp.sdc.tosca.parser.config.Configuration;
import org.openecomp.sdc.tosca.parser.config.ConfigurationManager;
-import java.io.IOException;
-
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
@Test
- public void testConfigurationConformanceLevel() throws IOException {
+ public void testConfigurationConformanceLevel() {
Configuration config = ConfigurationManager.getInstance().getConfiguration();
assertNotNull(config);
assertNotNull(config.getConformanceLevel());
@@ -24,28 +22,42 @@ public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
@Test
- public void testErrorConfigurations() throws IOException {
+ public void testErrorConfigurations() {
ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration();
assertNotNull(errorConfig);
assertNotNull(errorConfig.getErrors());
}
@Test
- public void testSetErrorConfiguration() throws IOException {
+ public void testSetErrorConfiguration() {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
- configurationManager.setErrorConfiguration("error-configuration-test.yaml");
- ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
- assertEquals(false, errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
- assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
+ try {
+ configurationManager.setErrorConfiguration("error-configuration-test.yaml");
+ ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
+ assertEquals(false,
+ errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
+ assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
+ }
+ finally {
+ // Reset the configuration for other tests
+ configurationManager.setErrorConfiguration("error-configuration.yaml");
+ }
}
@Test
- public void testSetJtoscaValidationIssueConfiguration() throws IOException {
+ public void testSetJtoscaValidationIssueConfiguration() {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
- configurationManager.setJtoscaValidationIssueConfiguration(
- "jtosca-validation-issue-configuration-test.yaml");
- JtoscaValidationIssueConfiguration issueConfig = configurationManager
- .getJtoscaValidationIssueConfiguration();
- assertNotNull(issueConfig);
+ try {
+ configurationManager.setJtoscaValidationIssueConfiguration(
+ "jtosca-validation-issue-configuration-test.yaml");
+ JtoscaValidationIssueConfiguration issueConfig = configurationManager
+ .getJtoscaValidationIssueConfiguration();
+ assertNotNull(issueConfig);
+ }
+ finally {
+ // Reset the configuration for other tests
+ configurationManager.setJtoscaValidationIssueConfiguration
+ ("jtosca-validation-issue-configuration.yaml");
+ }
}
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
index 0725cb9..1746042 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
@@ -3,7 +3,6 @@ package org.openecomp.sdc.impl;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.config.ConfigurationManager;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.testng.annotations.Test;
@@ -206,19 +205,23 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest {
@Test
public void testCSARMissingConformanceLevelWithCustomErrorConfig() throws
SdcToscaParserException {
+
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
- configurationManager.setErrorConfiguration("error-configuration-test.yaml");
- SdcToscaParserFactory.setConfigurationManager(configurationManager);
-
- ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper
- ("csars/service-missing-csar-meta-file.csar");
- String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel();
- assertNotNull(conformanceLevel);
- assertEquals(conformanceLevel, configurationManager.getConfiguration().getConformanceLevel()
- .getMaxVersion());
-
- configurationManager.setErrorConfiguration("error-configuration.yaml");
- SdcToscaParserFactory.setConfigurationManager(configurationManager);
+ try {
+ configurationManager.setErrorConfiguration("error-configuration-test.yaml");
+ factory.setConfigurationManager(configurationManager);
+ ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper
+ ("csars/service-missing-csar-meta-file.csar");
+ String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel();
+ assertNotNull(conformanceLevel);
+ assertEquals(conformanceLevel, configurationManager.getConfiguration().getConformanceLevel()
+ .getMaxVersion());
+ }
+ finally {
+ configurationManager.setErrorConfiguration("error-configuration.yaml");
+ factory.setConfigurationManager(configurationManager);
+ }
+
}
@Test(expectedExceptions = SdcToscaParserException.class)
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index 32336af..04675b4 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -5,6 +5,8 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.util.*;
+import static org.hamcrest.CoreMatchers.is;
+
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
@@ -12,8 +14,11 @@ import org.openecomp.sdc.tosca.parser.impl.FilterType;
import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
import org.openecomp.sdc.toscaparser.api.Group;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.Property;
import org.testng.annotations.Test;
+import fj.data.fingertrees.Node;
+
public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//region getServiceVfList
@@ -960,84 +965,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals(crTemplate.getPropertyValue("nf_naming").toString(), ImmutableMap.of("ecomp_generated_naming", "true").toString());
assertEquals(crTemplate.getPropertyValue("contrailport0_virtual_network"), "chaya");
}
-
- @Test
- public void testGetPoliciesOfOriginOfNodeTemplate() {
- NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
- NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
- List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0);
- assertNotNull(policies);
- assertEquals(policies.size(), 3);
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1);
- assertNotNull(policies);
- assertEquals(policies.size(), 3);
- }
-
- @Test
- public void testGetPoliciesOfOriginOfNodeTemplateByToscaPolicyType() {
- NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
- NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
- List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
-
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Antilocate");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
-
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.valet.Diversity");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
-
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Colocate");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
-
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Antilocate");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
-
- policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.valet.Diversity");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
- }
-
- @Test
- public void testGetPolicyTargetNodeTemplatesFromOrigin() {
- List<Map<String, Object>> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0");
- assertNotNull(nodeTemplates);
- assertEquals(nodeTemplates.size(), 2);
- }
-
- @Test
- public void testGetPoliciesOfNodeTemplate() {
- NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0);
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
- }
-
- @Test
- public void testGetPoliciesOfNodeTemplateByToscaPolicyType() {
- NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
- }
-
- @Test
- public void testGetPoliciesOfTopologyTemplate() {
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate();
- assertNotNull(policies);
- assertEquals(policies.size(), 1);
- }
-
- @Test
- public void testGetPolicyTargetNodeTemplates() {
- List<NodeTemplate> nodeTemplates = csarHelperVfPolicy.getPolicyTargetsFromTopologyTemplate("policy..Colocate..0");
- assertNotNull(nodeTemplates);
- assertEquals(nodeTemplates.size(), 2);
- }
+
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java
index 87d8f09..60119c4 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserValidationIssueTest.java
@@ -80,14 +80,16 @@ public class ToscaParserValidationIssueTest extends SdcToscaParserBasicTest {
System.out.println("SdcToscaParserException is caught here - this is WAD in this specific test.");
}
List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions();
- assertEquals(2, notAnalyzedReport.size());
+ assertEquals(3, notAnalyzedReport.size());
List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions();
assertEquals( 0, warningsReport.size());
List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions();
- assertEquals( 24, criticalsReport.size());
+ assertEquals( 22, criticalsReport.size());
//JE006 multy values sinceCsarConformanceLevel
- assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE006")).collect(Collectors.toList()).size(), 18);
- assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE003")).collect(Collectors.toList()).size(), 6);
+ assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE006")).collect
+ (Collectors.toList()).size(), 18);
+ assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE003")).collect
+ (Collectors.toList()).size(), 4);
}
diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar
deleted file mode 100644
index d6d7b42..0000000
--- a/src/test/resources/csars/resource-Policy-csar.csar
+++ /dev/null
Binary files differ
diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar
deleted file mode 100644
index 2532683..0000000
--- a/src/test/resources/csars/service-AlService-csar.csar
+++ /dev/null
Binary files differ