From af2d8ef12f6b75ae837fffdeaf5d152756cec6d6 Mon Sep 17 00:00:00 2001 From: Pavel Aharoni Date: Thu, 11 May 2017 16:41:38 +0300 Subject: [SDC-18] Tosca Parser conformance level - initial Change-Id: I0d8d27f4b8085d918ecc94aace423d3216337f2d Signed-off-by: Pavel Aharoni --- .../java/org/openecomp/sdc/impl/BasicTest.java | 134 +++++++++++++++++++-- .../sdc/impl/ToscaParserConfigurationTest.java | 21 ++++ .../sdc/impl/ToscaParserGeneralUtilTest.java | 23 ++++ .../openecomp/sdc/impl/ToscaParserGroupTest.java | 28 ++--- .../sdc/impl/ToscaParserMetadataTest.java | 35 ++++-- .../sdc/impl/ToscaParserNodeTemplateTest.java | 118 +++++++++--------- .../sdc/impl/ToscaParserServiceInputTest.java | 18 +-- .../sdc/impl/ToscaParserSubsMappingsTest.java | 118 +++++++++++++++++- .../openecomp/sdc/impl/ToscaParserTestSuite.java | 56 --------- .../src/test/resources/config/configuration.yaml | 3 + .../src/test/resources/csars/csar_hello_world.zip | Bin 936 -> 0 bytes .../csars/service-ServiceFdnt-csar-0904-2.csar | Bin 41245 -> 41437 bytes .../csars/service-ServiceFdnt-csar-rainy.csar | Bin 39700 -> 39892 bytes .../resources/csars/service-ServiceFdnt-csar.csar | Bin 39979 -> 40171 bytes .../csars/service-ServiceFdnt-with-allotted.csar | Bin 44976 -> 45194 bytes 15 files changed, 385 insertions(+), 169 deletions(-) create mode 100644 sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java create mode 100644 sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java delete mode 100644 sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java create mode 100644 sdc-tosca-parser/src/test/resources/config/configuration.yaml delete mode 100644 sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip (limited to 'sdc-tosca-parser/src/test') diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java index 450e6b1..373ff97 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java @@ -1,22 +1,130 @@ package org.openecomp.sdc.impl; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; +import java.io.File; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -public class BasicTest { +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; - @Rule - public TestName testName = new TestName(); +public abstract class BasicTest { - @Before - public void setup(){ - System.out.println("#### Starting Test " + testName.getMethodName() + " ###########"); + public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73"; + static SdcToscaParserFactory factory; + static ISdcCsarHelper rainyCsarHelperSingleVf; + static ISdcCsarHelper rainyCsarHelperMultiVfs; + static ISdcCsarHelper fdntCsarHelper; + static Map>> fdntCsarHelper_Data; + @BeforeSuite + public static void init(ITestContext context) throws Exception { + + factory = SdcToscaParserFactory.getInstance(); + long startTime = System.currentTimeMillis(); + long estimatedTime = System.currentTimeMillis() - startTime; + System.out.println("Time to init factory " + estimatedTime); + + String fileStr1 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-with-allotted.csar").getFile(); + File file1 = new File(fileStr1); + startTime = System.currentTimeMillis(); + + fdntCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath()); + + estimatedTime = System.currentTimeMillis() - startTime; + System.out.println("init CSAR Execution time: " + estimatedTime); + + String fileStr2 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar-rainy.csar").getFile(); + File file2 = new File(fileStr2); + rainyCsarHelperMultiVfs = factory.getSdcCsarHelper(file2.getAbsolutePath()); + + String fileStr3 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar.csar").getFile(); + File file3 = new File(fileStr3); + rainyCsarHelperSingleVf = factory.getSdcCsarHelper(file3.getAbsolutePath()); + + /* Objects for QA Validation Tests */ + + fdntCsarHelper_Data = new HashMap>>(){ + { + HashMap> FDNT ; + + FDNT = new HashMap>(); + FDNT.put("VF Name", Arrays.asList("FDNT 1")); + FDNT.put("capabilities", Arrays.asList( + "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI", + "dnt_fw_rhrg.host_DNT_FW_SERVER", + "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI", + "dnt_fw_rhrg.scalable_DNT_FW_SERVER", + "dnt_fw_rhrg.endpoint_DNT_FW_SERVER", + "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI", + "dnt_fw_rhrg.os_DNT_FW_SERVER", + "dnt_fw_rhrg.feature", + "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI", + "dnt_fw_rhrg.binding_DNT_FW_SERVER", + "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI", + "dnt_fw_rsg_si_1.feature")); + FDNT.put("requirements", Arrays.asList( + "DNT_FW_RSG_SI_1.dependency", + "DNT_FW_RHRG.dependency", + "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI", + "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI", + "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI", + "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI", + "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI", + "DNT_FW_RSG_SI_1.port", + "DNT_FW_RHRG.local_storage_DNT_FW_SERVER")); + FDNT.put("capabilitiesTypes", Arrays.asList( + "tosca.capabilities.network.Bindable", + "tosca.capabilities.OperatingSystem", + "tosca.capabilities.network.Bindable", + "tosca.capabilities.Scalable", + "tosca.capabilities.Endpoint.Admin", + "tosca.capabilities.network.Bindable", + "tosca.capabilities.network.Bindable", + "tosca.capabilities.network.Bindable", + "tosca.capabilities.Node", + "tosca.capabilities.Container", + "tosca.nodes.SoftwareComponent", + "tosca.capabilities.network.Bindable")); + FDNT.put("capabilityProperties", Arrays.asList( + "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none", + "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;", + "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI", + "dnt_fw_rhrg.scalable_DNT_FW_SERVER", + "dnt_fw_rhrg.endpoint_DNT_FW_SERVER", + "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI", + "dnt_fw_rhrg.os_DNT_FW_SERVER", + "dnt_fw_rhrg.feature", + "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI", + "dnt_fw_rhrg.binding_DNT_FW_SERVER", + "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI", + "dnt_fw_rsg_si_1.feature")); + + put("FDNT", FDNT); + } + }; + }; + + @AfterSuite + public static void after(){ + long startTime = System.currentTimeMillis(); + long estimatedTime = System.currentTimeMillis() - startTime; + System.out.println("close Execution time: "+estimatedTime); + }; + + @BeforeMethod + public void setupTest(Method method) { + System.out.println("#### Starting Test " + method.getName() + " ###########"); } - @After - public void tearDown(){ - System.out.println("#### Ended test " + testName.getMethodName() + " ###########"); + @AfterMethod + public void tearDown(Method method){ + System.out.println("#### Ended test " + method.getName() + " ###########"); } } diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java new file mode 100644 index 0000000..0e6387d --- /dev/null +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java @@ -0,0 +1,21 @@ +package org.openecomp.sdc.impl; + +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.assertNotNull; + +public class ToscaParserConfigurationTest extends BasicTest { + + @Test + public void testConfigurationConformanceLevel() throws IOException { + Configuration config = ConfigurationManager.getInstance().getConfiguration(); + assertNotNull(config); + assertNotNull(config.getConformanceLevel()); + assertNotNull(config.getConformanceLevel().getMaxVersion()); + assertNotNull(config.getConformanceLevel().getMinVersion()); + } +} diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java new file mode 100644 index 0000000..b903867 --- /dev/null +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java @@ -0,0 +1,23 @@ +package org.openecomp.sdc.impl; + +import org.testng.annotations.Test; +import org.openecomp.sdc.tosca.parser.utils.GeneralUtility; + +import static org.testng.Assert.assertTrue; + +public class ToscaParserGeneralUtilTest extends BasicTest { + + @Test + public void testVersionCompare() { + assertTrue(GeneralUtility.conformanceLevelCompare("2", "3.0") < 0); + assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.5") == 0); + assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.6") < 0); + assertTrue(GeneralUtility.conformanceLevelCompare("1.5", "2.6") < 0); + assertTrue(GeneralUtility.conformanceLevelCompare("0.2", "0.1") > 0); + assertTrue(GeneralUtility.conformanceLevelCompare("2", "1.15") > 0); + assertTrue(GeneralUtility.conformanceLevelCompare("2", "2.0.0") == 0); + assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.0") == 0); + assertTrue(GeneralUtility.conformanceLevelCompare("2.", "2.0.0.0") == 0); + assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.2") < 0); + } +} diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java index 0bda21e..706c864 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java @@ -1,20 +1,20 @@ package org.openecomp.sdc.impl; -import org.junit.Test; +import org.testng.annotations.Test; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.toscaparser.api.Group; import org.openecomp.sdc.toscaparser.api.elements.Metadata; import java.util.List; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class ToscaParserGroupTest extends BasicTest{ //region getVfModulesByVf @Test public void testVfModulesFromVf(){ - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); assertEquals(2, vfModulesByVf.size()); for (Group group : vfModulesByVf){ assertTrue(group.getName().startsWith("fdnt1")); @@ -25,7 +25,7 @@ public class ToscaParserGroupTest extends BasicTest{ @Test public void testGetGroupMetadata(){ - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); boolean found = false; for (Group group : vfModulesByVf){ if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){ @@ -40,7 +40,7 @@ public class ToscaParserGroupTest extends BasicTest{ @Test public void testGetGroupEmptyMetadata(){ - List vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72"); + List vfModulesByVf = rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72"); boolean found = false; for (Group group : vfModulesByVf){ if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){ @@ -54,14 +54,14 @@ public class ToscaParserGroupTest extends BasicTest{ @Test public void testGetVfModuleNonExisitingVf() { - List vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperSingleVf.getVfModulesByVf("dummy"); + List vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf("dummy"); assertNotNull(vfModulesByVf); assertEquals(0, vfModulesByVf.size()); } @Test public void testGetVfModuleNullVf() { - List vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperSingleVf.getVfModulesByVf(null); + List vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf(null); assertNotNull(vfModulesByVf); assertEquals(0, vfModulesByVf.size()); } @@ -70,28 +70,28 @@ public class ToscaParserGroupTest extends BasicTest{ //region getGroupPropertyLeafValue @Test public void testGroupFlatProperty() throws SdcToscaParserException { - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); - String volumeGroup = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group"); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); + String volumeGroup = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group"); assertEquals("false", volumeGroup); } @Test public void testGroupPropertyLeafValueByNullProperty() { - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); - String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); + String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null); assertNull(groupProperty); } @Test public void testGroupPropertyLeafValueByDummyProperty() { - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); - String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX"); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); + String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX"); assertNull(groupProperty); } @Test public void testGroupPropertyLeafValueByNullGroup() { - String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group"); + String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group"); assertNull(groupProperty); } //endregion diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java index 9321bc6..802d5b8 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java @@ -1,18 +1,18 @@ package org.openecomp.sdc.impl; -import org.junit.Test; +import org.testng.annotations.Test; import org.openecomp.sdc.toscaparser.api.elements.Metadata; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; public class ToscaParserMetadataTest extends BasicTest { //region getServiceMetadata @Test public void testGetServiceMetadata() { - Metadata serviceMetadata = ToscaParserTestSuite.fdntCsarHelper.getServiceMetadata(); + Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); assertNotNull(serviceMetadata); assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", serviceMetadata.getValue("invariantUUID")); assertEquals("Service FDNT", serviceMetadata.getValue("name")); @@ -21,7 +21,7 @@ public class ToscaParserMetadataTest extends BasicTest { @Test public void testServiceMetadata() { - Metadata metadata = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceMetadata(); + Metadata metadata = rainyCsarHelperSingleVf.getServiceMetadata(); assertNull(metadata); } //endregion @@ -29,30 +29,39 @@ public class ToscaParserMetadataTest extends BasicTest { //region getMetadataPropertyValue @Test public void testGetMetadataProperty(){ - Metadata serviceMetadata = ToscaParserTestSuite.fdntCsarHelper.getServiceMetadata(); - String metadataPropertyValue = ToscaParserTestSuite.fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID"); + Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); + String metadataPropertyValue = fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID"); assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", metadataPropertyValue); } @Test public void testGetNullMetadataPropertyValue() { - String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX"); + String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX"); assertNull(value); } @Test public void testGetMetadataByNullPropertyValue() { - Metadata metadata = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceMetadata(); - String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null); + Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata(); + String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null); assertNull(value); } @Test public void testGetMetadataByEmptyPropertyValue() { - Metadata metadata = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceMetadata(); - String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, ""); + Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata(); + String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, ""); assertNull(value); } //endregion + //region getConformanceLevel + @Test + public void testSunnyGetConformanceLevel() { + String conformanceLevel = fdntCsarHelper.getConformanceLevel(); + assertNotNull(conformanceLevel); + assertEquals("3.0", conformanceLevel); + } + //endregion + } diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java index 8c748f6..9a78ed5 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java @@ -1,14 +1,14 @@ package org.openecomp.sdc.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import org.junit.Test; +import org.testng.annotations.Test; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.toscaparser.api.Group; import org.openecomp.sdc.toscaparser.api.NodeTemplate; @@ -18,7 +18,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getServiceVfList @Test public void testNumberOfVfSunnyFlow() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); + List serviceVfList = fdntCsarHelper.getServiceVfList(); assertNotNull(serviceVfList); assertEquals(2, serviceVfList.size()); } @@ -26,7 +26,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest { @Test public void testSingleVFWithNotMetadata() throws SdcToscaParserException { //If there is no metadata on VF level - There is no VF's because the type is taken from metadata values. - List serviceVfList = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceVfList(); + List serviceVfList = rainyCsarHelperSingleVf.getServiceVfList(); assertNotNull(serviceVfList); assertEquals(0, serviceVfList.size()); } @@ -35,54 +35,54 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getNodeTemplatePropertyLeafValue @Test public void testNodeTemplateFlatProperty() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); - assertEquals("2", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count")); - assertEquals("3", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances")); - assertEquals("some code", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code")); + List serviceVfList = fdntCsarHelper.getServiceVfList(); + assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count")); + assertEquals("3", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances")); + assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code")); } @Test public void testNodeTemplateNestedProperty() throws SdcToscaParserException { - List serviceVlList = ToscaParserTestSuite.fdntCsarHelper.getServiceVlList(); + List serviceVlList = fdntCsarHelper.getServiceVlList(); NodeTemplate nodeTemplate = serviceVlList.get(0); //System.out.println("node template " + nodeTemplate.toString()); - assertEquals("24", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask")); - assertEquals("7a6520b-9982354-ee82992c-105720", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding")); + assertEquals("24", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask")); + assertEquals("7a6520b-9982354-ee82992c-105720", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding")); } @Test public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); + List serviceVfList = fdntCsarHelper.getServiceVfList(); NodeTemplate nodeTemplate = serviceVfList.get(0); //System.out.println("node template " + nodeTemplate.toString()); - assertEquals("true", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming")); - assertEquals("FDNT_instance_VF_2", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy")); + assertEquals("true", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming")); + assertEquals("FDNT_instance_VF_2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy")); } @Test public void testNodeTemplateNestedPropertyNotExists() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); - String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku"); + List serviceVfList = fdntCsarHelper.getServiceVfList(); + String nodeTemplatePropertyLeafValue = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku"); assertNull(nodeTemplatePropertyLeafValue); } @Test public void testNodeTemplateFlatPropertyByNotFoundProperty() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList(); - String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX"); + List serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); + String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX"); assertNull(nodeTemplatePropertyLeafValue); } @Test public void testNodeTemplateFlatPropertyByNullProperty() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList(); - String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null); + List serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); + String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null); assertNull(nodeTemplatePropertyLeafValue); } @Test public void testNodeTemplateFlatPropertyByNullNodeTemplate() throws SdcToscaParserException { - String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count"); + String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count"); assertNull(nodeTemplatePropertyLeafValue); } //endregion @@ -90,14 +90,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getServiceVlList @Test public void testServiceVl() { - List vlList = ToscaParserTestSuite.fdntCsarHelper.getServiceVlList(); + List vlList = fdntCsarHelper.getServiceVlList(); assertEquals(1, vlList.size()); assertEquals("exVL", vlList.get(0).getName()); } @Test public void testNumberOfVLRainyFlow() throws SdcToscaParserException { - List serviceVlList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVlList(); + List serviceVlList = rainyCsarHelperMultiVfs.getServiceVlList(); assertNotNull(serviceVlList); assertEquals(0, serviceVlList.size()); } @@ -106,21 +106,21 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getServiceNodeTemplatesByType @Test public void testServiceNodeTemplatesByType() throws SdcToscaParserException { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt"); + List serviceVfList = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt"); assertNotNull(serviceVfList); assertEquals(1, serviceVfList.size()); } @Test public void testServiceNodeTemplatesByNull() { - List nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null); + List nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null); assertNotNull(nodeTemplates); assertEquals(0, nodeTemplates.size()); } @Test public void testServiceNodeTemplatesByNotFoundProperty() { - List nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX"); + List nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX"); assertNotNull(nodeTemplates); assertEquals(0, nodeTemplates.size()); } @@ -129,14 +129,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getTypeOfNodeTemplate @Test public void testGetTypeOfNodeTemplate() { - List serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); - String typeOfNodeTemplate = ToscaParserTestSuite.fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0)); + List serviceVfList = fdntCsarHelper.getServiceVfList(); + String typeOfNodeTemplate = fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0)); assertEquals("org.openecomp.resource.vf.Fdnt", typeOfNodeTemplate); } @Test public void testGetTypeOfNullNodeTemplate() { - String typeOfNodeTemplate = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null); + String typeOfNodeTemplate = rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null); assertNull(typeOfNodeTemplate); } //endregion @@ -144,13 +144,13 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getAllottedResources @Test public void testGetAllottedResources() { - List allottedResources = ToscaParserTestSuite.fdntCsarHelper.getAllottedResources(); + List allottedResources = fdntCsarHelper.getAllottedResources(); assertEquals(1, allottedResources.size()); } @Test public void testGetAllottedResourcesZero() { - List allottedResources = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getAllottedResources(); + List allottedResources = rainyCsarHelperMultiVfs.getAllottedResources(); assertNotNull(allottedResources); assertEquals(0, allottedResources.size()); } @@ -159,20 +159,20 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getVfcListByVf @Test public void testGetVfcFromVf() { - List vfcListByVf = ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); + List vfcListByVf = fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID); assertEquals(2, vfcListByVf.size()); } @Test public void testVfcListByNull() { - List vfcList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfcListByVf(null); + List vfcList = rainyCsarHelperMultiVfs.getVfcListByVf(null); assertNotNull(vfcList); assertEquals(0, vfcList.size()); } @Test public void testVfcListByNotFoundProperty() { - List vfcList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfcListByVf("XXX"); + List vfcList = rainyCsarHelperMultiVfs.getVfcListByVf("XXX"); assertNotNull(vfcList); assertEquals(0, vfcList.size()); } @@ -181,7 +181,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getCpListByVf @Test public void testGetCpFromVf() { - List cpListByVf = ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); + List cpListByVf = fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID); assertEquals(1, cpListByVf.size()); NodeTemplate nodeTemplate = cpListByVf.get(0); assertEquals("DNT_PORT", nodeTemplate.getName()); @@ -189,14 +189,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest { @Test public void testGetCpFromVfByNullId() { - List cpListByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getCpListByVf(null); + List cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf(null); assertNotNull(cpListByVf); assertEquals(0, cpListByVf.size()); } @Test public void testGetCpFromVfXxx() { - List cpListByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getCpListByVf("XXXXX"); + List cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf("XXXXX"); assertNotNull(cpListByVf); assertEquals(0, cpListByVf.size()); } @@ -205,7 +205,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getNodeTemplatePairsByReqName @Test public void testGetNodeTemplatePairsByReqName() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(1, nodeTemplatePairsByReqName.size()); Pair pair = nodeTemplatePairsByReqName.get(0); @@ -217,40 +217,40 @@ public class ToscaParserNodeTemplateTest extends BasicTest { @Test public void testGetNodeTemplatePairsByReqNameWithNullVF() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - null, ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + null, fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @Test public void testGetNodeTemplatePairsByReqNameWithEmptyVF() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - new ArrayList<>(), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + new ArrayList<>(), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @Test public void testGetNodeTemplatePairsByReqNameWithNullCap() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), null, "binding"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), null, "binding"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @Test public void testGetNodeTemplatePairsByReqNameWithEmptyCap() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @Test public void testGetNodeTemplatePairsByReqNameWithNullReq() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), null); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), null); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @@ -258,8 +258,8 @@ public class ToscaParserNodeTemplateTest extends BasicTest { @Test public void testGetNodeTemplatePairsByReqNameWithDummyReq() { - List> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName( - ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "XXX"); + List> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( + fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "XXX"); assertNotNull(nodeTemplatePairsByReqName); assertEquals(0, nodeTemplatePairsByReqName.size()); } @@ -268,11 +268,11 @@ public class ToscaParserNodeTemplateTest extends BasicTest { //region getMembersOfVfModule @Test public void testGetMembersOfVfModule() { - NodeTemplate vf = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList().get(0); - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); + NodeTemplate vf = fdntCsarHelper.getServiceVfList().get(0); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); assertEquals(2, vfModulesByVf.size()); for (Group group : vfModulesByVf) { - List membersOfVfModule = ToscaParserTestSuite.fdntCsarHelper.getMembersOfVfModule(vf, group); + List membersOfVfModule = fdntCsarHelper.getMembersOfVfModule(vf, group); assertNotNull(membersOfVfModule); if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")) { assertEquals(1, membersOfVfModule.size()); @@ -289,16 +289,16 @@ public class ToscaParserNodeTemplateTest extends BasicTest { @Test public void testMembersOfVfModuleByNullVf() { - List vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID); - List nodeTemplates = ToscaParserTestSuite.fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0)); + List vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); + List nodeTemplates = fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0)); assertNotNull(nodeTemplates); assertEquals(0, nodeTemplates.size()); } @Test public void testMembersOfVfModuleByNullGroup() { - List serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList(); - List nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null); + List serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); + List nodeTemplates = rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null); assertNotNull(nodeTemplates); assertEquals(0, nodeTemplates.size()); } diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java index 3444e53..d357d21 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java @@ -1,27 +1,27 @@ package org.openecomp.sdc.impl; -import org.junit.Test; +import org.testng.annotations.Test; import org.openecomp.sdc.toscaparser.api.parameters.Input; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; public class ToscaParserServiceInputTest extends BasicTest { //region getServiceInputs @Test public void testGetServiceInputs(){ - List serviceInputs = ToscaParserTestSuite.fdntCsarHelper.getServiceInputs(); + List serviceInputs = fdntCsarHelper.getServiceInputs(); assertNotNull(serviceInputs); assertEquals(1, serviceInputs.size()); } @Test public void testServiceInputs() { - List inputs = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceInputs(); + List inputs = rainyCsarHelperSingleVf.getServiceInputs(); assertNotNull(inputs); assertEquals(0, inputs.size()); } @@ -30,19 +30,19 @@ public class ToscaParserServiceInputTest extends BasicTest { //region getServiceInputLeafValueOfDefault @Test public void testGetServiceInputLeafValue(){ - String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default"); + String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default"); assertEquals("test service naming", serviceInputLeafValue); } @Test public void testGetServiceInputLeafValueNotExists(){ - String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku"); + String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku"); assertNull(serviceInputLeafValue); } @Test public void testGetServiceInputLeafValueNull(){ - String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault(null); + String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null); assertNull(serviceInputLeafValue); } //endregion diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java index fc0aff5..c61f465 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java @@ -1,24 +1,132 @@ package org.openecomp.sdc.impl; -import org.junit.Test; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.stream.Collectors; + +import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.openecomp.sdc.toscaparser.api.Capability; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.CapabilityTypeDef; +//import org.testng.ReporterConfig.Property; +import org.testng.annotations.Test; +import org.openecomp.sdc.toscaparser.api.Property; + +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertNull; public class ToscaParserSubsMappingsTest extends BasicTest { //region getServiceSubstitutionMappingsTypeName @Test public void testGetServiceSubstitutionMappingsTypeName() { - String serviceSubstitutionMappingsTypeName = ToscaParserTestSuite.fdntCsarHelper.getServiceSubstitutionMappingsTypeName(); + String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName(); assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName); } @Test public void testServiceSubstitutionMappingsTypeName() { - String substitutionMappingsTypeName = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName(); + String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName(); assertNull(substitutionMappingsTypeName); } //endregion + + //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names). + //@Test // - BUG 283369 + public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException { + List serviceVfList = fdntCsarHelper.getServiceVfList(); + String sName = serviceVfList.get(0).getName(); + assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0)); + LinkedHashMap lCapabilitys = serviceVfList.get(0).getCapabilities(); + List CPkeys = new ArrayList<>(lCapabilitys.keySet()); + List CapabilitiesNames = new ArrayList(CPkeys.size()); + + for (int i = 0; i < CPkeys.size(); i++) { + + Capability cCp = lCapabilitys.get(CPkeys.get(i)); + + CapabilitiesNames.add(cCp.getName()); + + assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive???? + + //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase())); + //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase())); + //System.out.println(String.format("*******%d*******",i)); + } + + for (int i = 0; i < CPkeys.size(); i++) { + assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one. + } + + assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual + } + + //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties). + //@Test + public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException { + List serviceVfList = fdntCsarHelper.getServiceVfList(); + String sName = serviceVfList.get(0).getName(); + assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0)); + LinkedHashMap lCapabilitys = serviceVfList.get(0).getCapabilities(); + + List CPkeys = new ArrayList<>(lCapabilitys.keySet()); + List CPPropkeys = new ArrayList<>(lCapabilitys.keySet()); + List CapabilitiesTypes = new ArrayList(CPkeys.size()); + + //int iKeysSize = keys.size(); //for debug + + for (int i = 0; i < CPkeys.size(); i++) { + + Capability cCp = lCapabilitys.get(CPkeys.get(i)); + CapabilityTypeDef CpDef = cCp.getDefinition(); + CapabilitiesTypes.add(CpDef.getType()); + + //LinkedHashMap lProperties = cCp.getDefinition().getProperties(); + LinkedHashMap lPropertiesR = cCp.getProperties(); + + List CP_Propkeys = new ArrayList<>(lPropertiesR.keySet()); + + for (int j = 0; j < CP_Propkeys.size(); j++) { + + Property p = lPropertiesR.get(CP_Propkeys.get(j)); + + if(p != null){ + String sPType = p.getType(); + Boolean bPRequired = p.isRequired(); + + System.out.println(sPType + " " + bPRequired); + + } + + } + + } + + for (int i = 0; i < CPkeys.size(); i++) { + + } + + assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual + } + + //@Test // - BUG 283387 + public void testRequirmentsofVF() throws SdcToscaParserException { + List serviceVfList = fdntCsarHelper.getServiceVfList(); + String sName = serviceVfList.get(0).getName(); + assertEquals(sName,"FDNT 1"); + + List ActualReqsValues = new ArrayList<>(Arrays.asList( )); + + ArrayList lRequirements = serviceVfList.get(0).getRequirements(); + + assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); // + + // Continue from here after bug is fixed ! ! ! ! - Test the Requirements values + } } diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java deleted file mode 100644 index 83e7d13..0000000 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.openecomp.sdc.impl; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; - -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; -import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector; -import org.openecomp.sdc.toscaparser.api.common.JToscaException; - -@RunWith( Suite.class ) -@Suite.SuiteClasses( { - ToscaParserNodeTemplateTest.class, - ToscaParserSubsMappingsTest.class, - ToscaParserGroupTest.class, - ToscaParserMetadataTest.class, - ToscaParserServiceInputTest.class, -} ) -public class ToscaParserTestSuite { - - public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73"; - static SdcToscaParserFactory factory; - static ISdcCsarHelper rainyCsarHelperSingleVf; - static ISdcCsarHelper rainyCsarHelperMultiVfs; - static ISdcCsarHelper fdntCsarHelper; - - @BeforeClass - public static void init() throws SdcToscaParserException, JToscaException, IOException { - - factory = SdcToscaParserFactory.getInstance(); - fdntCsarHelper = getCsarHelper("csars/service-ServiceFdnt-with-allotted.csar"); - rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar"); - rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar"); - } - - private static ISdcCsarHelper getCsarHelper(String path) throws JToscaException, IOException, SdcToscaParserException { - System.out.println("Parsing CSAR "+path+"..."); - String fileStr1 = ToscaParserTestSuite.class.getClassLoader().getResource(path).getFile(); - File file1 = new File(fileStr1); - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath()); - ArrayList exceptionReport = ExceptionCollector.getExceptionReport(); - if (!exceptionReport.isEmpty()){ - System.out.println("TOSCA Errors found in CSAR - failing the tests..."); - System.out.println(exceptionReport.toString()); - ExceptionCollector.clear(); - throw new SdcToscaParserException("CSAR didn't pass validation"); - } - return sdcCsarHelper; - } - -} diff --git a/sdc-tosca-parser/src/test/resources/config/configuration.yaml b/sdc-tosca-parser/src/test/resources/config/configuration.yaml new file mode 100644 index 0000000..379e962 --- /dev/null +++ b/sdc-tosca-parser/src/test/resources/config/configuration.yaml @@ -0,0 +1,3 @@ +conformanceLevel: + minVersion: '3.0' + maxVersion: '3.0' \ No newline at end of file diff --git a/sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip b/sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip deleted file mode 100644 index 43ffbbc..0000000 Binary files a/sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip and /dev/null differ diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar index fc21af3..4f57b71 100644 Binary files a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar and b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar differ diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar index 7752244..f3b3a46 100644 Binary files a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar and b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar differ diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar index 6179316..983dc9b 100644 Binary files a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar and b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar differ diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar index a343e84..ef6d03e 100644 Binary files a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar and b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar differ -- cgit 1.2.3-korg