From b6c2ccf8658133a73b43a1e22f6df5ab608a2bab Mon Sep 17 00:00:00 2001 From: PriyanshuAgarwal Date: Wed, 11 Apr 2018 22:19:30 +0530 Subject: Interfaces support in SDC Parser Part 2 of the changes of interface support in SDC Parser. Change-Id: I0e234415c2dd77a447908359c2f75e7ea3f3f27d Issue-ID: SDC-1197 Signed-off-by: priyanshu --- .../org/onap/sdc/impl/SdcToscaParserBasicTest.java | 2 + .../onap/sdc/impl/ToscaParserInterfaceTest.java | 59 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java (limited to 'src/test/java/org') diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java index ff4f3db..08f5bf1 100644 --- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java @@ -42,6 +42,7 @@ public abstract class SdcToscaParserBasicTest { static ISdcCsarHelper csarHelperServiceGroupsCapabilities; static ISdcCsarHelper csarHelperVfGroupsPolicies; static ISdcCsarHelper csarHelperServiceGroupsPolicies; + static ISdcCsarHelper csarHelperVfInterfaces; static Map>> fdntCsarHelper_Data; @@ -71,6 +72,7 @@ public abstract class SdcToscaParserBasicTest { csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar"); csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar"); csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar"); + csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar"); fdntCsarHelper_Data = new HashMap>>(){ { diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java new file mode 100644 index 0000000..e6755e1 --- /dev/null +++ b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java @@ -0,0 +1,59 @@ +package org.onap.sdc.impl; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.List; +import java.util.Map; +import org.mockito.internal.util.collections.Sets; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.elements.InterfacesDef; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest { + + List vfs; + + @BeforeClass + public void setup(){ + vfs = csarHelperVfInterfaces.getServiceVfList(); + } + + @Test + public void testGetInterfaceOf() { + Map> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0)); + assertNotNull(interfaceDetails); + assertEquals(interfaceDetails.size(), 2); + } + + @Test + public void testGetInterfaces() { + List interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0)); + assertNotNull(interfaceNames); + assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard")); + } + + @Test + public void testGetInterfaceDetails() { + List interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); + assertNotNull(interfaceDetails); + assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate"); + assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade"); + } + + @Test + public void testGetAllInterfaceOperations() { + List operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); + assertNotNull(operations); + assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete")); + } + + @Test + public void testGetInterfaceOperationDetails() { + InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate"); + assertNotNull(interfaceDef); + assertEquals(interfaceDef.getOperationName(), "instantiate"); + } + +} -- cgit 1.2.3-korg