summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Chaturvedi <ac204h@att.com>2017-08-24 00:10:17 -0400
committerAnand Chaturvedi <ac204h@att.com>2017-08-24 01:01:46 -0400
commit96119e62a35496ecb0093c0f55300dffb95c8d33 (patch)
tree64874a9c7dd5792185237a7e4164f2c025a7fde5
parentf0f51b3047ea290e2280af64b39ca0983f3377f5 (diff)
Added New Junit Cases for APPC Design Services
Issue-ID: APPC-168 Change-Id: Ib321bb77af3cb47abfce80d96f50a6b75b34b34e Signed-off-by: Anand Chaturvedi <ac204h@att.com>
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestConfigComponentAdaptor.java132
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestDebugLog.java19
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestEncryptionTool.java24
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestSshJcraftWrapper.java23
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestXmlUtil.java19
-rw-r--r--appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java115
-rw-r--r--appc-config/appc-flow-controller/provider/pom.xml17
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlDBServiceTest.java143
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlNodeTest.java138
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/RestExecutorTest.java80
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java39
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java66
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java42
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java2
-rwxr-xr-xappc-inbound/appc-design-services/provider/pom.xml22
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java59
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java48
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java116
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java19
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java136
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json19
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java501
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java336
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java48
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java185
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java0
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java34
27 files changed, 2181 insertions, 201 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestConfigComponentAdaptor.java b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestConfigComponentAdaptor.java
new file mode 100644
index 000000000..d5d6f754d
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestConfigComponentAdaptor.java
@@ -0,0 +1,132 @@
+package org.openecomp.appc.ccadaptor;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+public class TestConfigComponentAdaptor {
+
+
+ @Test
+ public void testGetCliRunningConfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "GetCliRunningConfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+
+ }
+
+ @Test
+ public void testDownloadCliConfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "DownloadCliConfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+
+ }
+
+ @Test
+ public void testXmlDownload(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "xml-download";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testXmlGetrunningconfig(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "xml-getrunningconfig";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+
+ }
+
+ @Test
+ public void testEscapeSql(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("get_config_template");
+ String key = "escapeSql";
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Get_config_template", Get_config_template);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+ }
+
+ @Test
+ public void testAll(){
+ Properties props = null;
+ ConfigComponentAdaptor cca = new ConfigComponentAdaptor(props);
+ String Get_config_template = ("test");
+ String Download_config_template = ("test");
+ String key = "GetCliRunningConfig";
+ Map<String, String> parameters = new HashMap<String,String>();
+ parameters.put("Host_ip_address", "test");
+ parameters.put("User_name", "test");
+ parameters.put("Password", "password");
+ parameters.put("Port_number", "22");
+ parameters.put("Protocol", "netconf");
+ parameters.put("Contents", "Contents");
+ parameters.put("Get_config_template", Get_config_template);
+ parameters.put("Download_config_template", Download_config_template);
+ parameters.put("Config_contents", "config\nsystem\nservice-interface serv1\nipv4\ngateway-ip-address 192.168.30.44");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("service-data.vnf-config-parameters-list.vnf-config-parameters[0].update-configuration[0].block-key-name", "test");
+ cca.configure(key, parameters, ctx);
+
+
+ }
+
+
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestDebugLog.java b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestDebugLog.java
new file mode 100644
index 000000000..fdd2c667c
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestDebugLog.java
@@ -0,0 +1,19 @@
+package org.openecomp.appc.ccadaptor;
+
+import org.junit.Test;
+
+public class TestDebugLog {
+
+ @Test
+ public void testAppendToFile() {
+ DebugLog.appendToFile("appendData");
+ }
+
+ @Test
+ public void TestGetDateTime() {
+ String DateTime = DebugLog.getDateTime();
+ System.out.println(DateTime);
+
+ }
+
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestEncryptionTool.java b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestEncryptionTool.java
new file mode 100644
index 000000000..5751d1e1c
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestEncryptionTool.java
@@ -0,0 +1,24 @@
+package org.openecomp.appc.ccadaptor;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestEncryptionTool {
+
+ @Test
+ public void testEncrypt() {
+ EncryptionTool tool = EncryptionTool.getInstance();
+ String value = tool.encrypt("encrypt");
+ Assert.assertEquals("enc:JjEZHlg7VQ==", value);
+ System.out.println(value);
+ }
+
+ @Test
+ public void testDecrypt() {
+ EncryptionTool tool = EncryptionTool.getInstance();
+ String value = tool.decrypt("enc:JjEZHlg7VQ==");
+ Assert.assertEquals("encrypt", value);
+ System.out.println(value);
+ }
+
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestSshJcraftWrapper.java b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestSshJcraftWrapper.java
new file mode 100644
index 000000000..bd5ca81a2
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestSshJcraftWrapper.java
@@ -0,0 +1,23 @@
+package org.openecomp.appc.ccadaptor;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestSshJcraftWrapper {
+
+ @Test
+ public void TestCheckIfReceivedStringMatchesDelimeter(){
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ wrapper.getTheDate();
+ boolean result = wrapper.checkIfReceivedStringMatchesDelimeter("#", "config#", "config#");
+ System.out.println(result);
+ }
+
+ @Test
+ public void testRemoveWhiteSpaceAndNewLineCharactersAroundString(){
+ SshJcraftWrapper wrapper = new SshJcraftWrapper();
+ String nameSpace = wrapper.removeWhiteSpaceAndNewLineCharactersAroundString("namespace");
+ Assert.assertEquals("namespace", nameSpace);
+ }
+
+}
diff --git a/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestXmlUtil.java b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestXmlUtil.java
new file mode 100644
index 000000000..8ccef295a
--- /dev/null
+++ b/appc-config/appc-config-adaptor/provider/src/main/test/org/openecomp/appc/ccadaptor/TestXmlUtil.java
@@ -0,0 +1,19 @@
+package org.openecomp.appc.ccadaptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestXmlUtil {
+
+ @Test
+ public void testXml() {
+ Map<String, String> varmap = new HashMap<String, String>();
+ varmap.put("network.data", "ipv4");
+ String xmlData = XmlUtil.getXml(varmap, "network");
+ Assert.assertEquals("<data>ipv4</data>\n", xmlData);
+ System.out.println(xmlData);
+ }
+}
diff --git a/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java b/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java
new file mode 100644
index 000000000..b134de0b1
--- /dev/null
+++ b/appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestConfigResourceNode.java
@@ -0,0 +1,115 @@
+package org.openecomp.appc.data.services.db;
+
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.openecomp.appc.data.services.AppcDataServiceConstant;
+import org.openecomp.appc.data.services.db.DGGeneralDBService;
+import org.openecomp.appc.data.services.node.ConfigResourceNode;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.SvcLogicResource.QueryStatus;
+import org.openecomp.sdnc.sli.resource.sql.SqlResource;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+
+import java.io.File;
+
+public class TestConfigResourceNode {
+
+ @Test(expected = Exception.class)
+ public void testGetUploadConfig1() throws SvcLogicException{
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getConfigFileReference(map,ctx);
+ //System.out.println(status);
+
+
+ }
+
+@Test(expected = Exception.class)
+
+public void testGetUploadConfig2() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getTemplate(map,ctx);
+ //System.out.println(status);
+}
+
+@Test(expected = Exception.class)
+
+public void testGetUploadConfig3() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getVnfcReference(map, ctx);
+ //System.out.println(status);
+
+
+}
+
+@Test(expected = Exception.class)
+
+public void testGetUploadConfig4() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getSmmChainKeyFiles(map, ctx);
+ //System.out.println(status);
+
+
+}
+
+@Test(expected = Exception.class)
+
+public void testGetUploadConfig5() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getDownloadConfigTemplateByVnf(map, ctx);
+ //System.out.println(status);
+
+
+}
+
+@Test(expected = Exception.class)
+public void testGetUploadConfig6() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.getCommonConfigInfo(map, ctx);
+ //System.out.println(status);
+
+
+}
+
+@Test(expected = Exception.class)
+public void testGetUploadConfig7() throws SvcLogicException{
+SvcLogicContext ctx = new SvcLogicContext();
+ctx.setAttribute("test","test");
+ ConfigResourceNode dbService = new ConfigResourceNode() ;
+ Map<String,String> map = new HashMap<String,String>();
+ dbService.updateUploadConfig(map, ctx);
+ //System.out.println(status);
+
+
+}
+
+
+}
diff --git a/appc-config/appc-flow-controller/provider/pom.xml b/appc-config/appc-flow-controller/provider/pom.xml
index e76d42dae..0eeb4f86c 100644
--- a/appc-config/appc-flow-controller/provider/pom.xml
+++ b/appc-config/appc-flow-controller/provider/pom.xml
@@ -76,6 +76,23 @@
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlDBServiceTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlDBServiceTest.java
new file mode 100644
index 000000000..33413e247
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlDBServiceTest.java
@@ -0,0 +1,143 @@
+package org.openecomp.appc.flow.executor.node;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyString;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.openecomp.appc.flow.controller.data.Transaction;
+import org.openecomp.appc.flow.controller.dbervices.FlowControlDBService;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.SvcLogicResource.QueryStatus;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+import org.openecomp.sdnc.sli.resource.sql.SqlResource;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@PrepareForTest({ SqlResource.class, SvcLogicResource.class })
+@RunWith(PowerMockRunner.class)
+public class FlowControlDBServiceTest {
+
+@Mock
+ SvcLogicResource serviceLogic;
+@Mock
+SqlResource sqlrs;
+@Mock
+QueryStatus dblibSvc ;
+
+ private static FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
+
+ private Transaction transaction;;
+
+ @Before
+ public void setUp() throws Exception {
+ serviceLogic = new SqlResource();
+ }
+
+
+ /*public final void testGetFlowReferenceData() throws Exception {
+
+ SvcLogicContext localContext = new SvcLogicContext();
+ FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
+ PowerMockito.spy(SqlResource.class);
+
+ Map<String, String> inParams = null;
+ //PowerMockito.doReturn(dblibSvc).when(SqlResource.class, "query");
+ Whitebox.invokeMethod(SqlResource.class, "query",anyString(), anyBoolean(), anyString(), anyString(), anyString(), anyString(), any(SvcLogicContext.class));
+
+ dgGeneralDBService.getFlowReferenceData(localContext, inParams, localContext);
+ //Assert.assertEquals("SUCCESS", status);
+ //Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+
+ }*/
+
+ @Test(expected=Exception.class)
+ public final void testGetFlowReferenceData() throws Exception {
+
+ SvcLogicContext localContext = new SvcLogicContext();
+ FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
+ PowerMockito.spy(FlowControlDBService.class);
+
+
+ PowerMockito.doReturn(dgGeneralDBService).when(SqlResource.class, "query");
+ String status = dgGeneralDBService.getDesignTimeFlowModel(localContext);
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+
+ }
+
+
+ @Test(expected=Exception.class)
+ public final void testGetDesignTimeFlowModel() throws Exception {
+ SvcLogicContext localContext = new SvcLogicContext();
+ String status = dgGeneralDBService.getDesignTimeFlowModel(localContext) ;
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+
+
+
+
+ }
+
+ @Test(expected=Exception.class)
+ public final void testLoadSequenceIntoDB() throws SvcLogicException {
+
+
+ SvcLogicContext localContext = new SvcLogicContext();
+ QueryStatus status = dgGeneralDBService.loadSequenceIntoDB(localContext) ;
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+ /*SvcLogicContext ctx = new SvcLogicContext();
+
+ if (serviceLogic != null && localContext != null) {
+ String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS
+ + " set request_id = ' kusuma_test' , action = 'Configure', action_level = 'VNF' , vnf_type = 'vComp' , category = 'config_Template' , artifact_content = '', updated_date = sysdate() ";
+ Mockito.when(serviceLogic.save("SQL", false, false, queryString, null, null, localContext))
+ .thenReturn(status);
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);*/
+
+
+
+ }
+
+ @Test(expected=Exception.class)
+ public final void testPopulateModuleAndRPC() throws SvcLogicException {
+ SvcLogicContext localContext = new SvcLogicContext();
+ SvcLogicContext ctx = new SvcLogicContext();
+ String vnf_type = "test";
+ dgGeneralDBService.populateModuleAndRPC(transaction, vnf_type);;
+
+
+ }
+
+ @Test(expected=Exception.class)
+ public final void testGetDependencyInfo() throws SvcLogicException {
+ SvcLogicContext localContext = new SvcLogicContext();
+ String status = dgGeneralDBService.getDependencyInfo(localContext);
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+
+ }
+
+ @Test(expected=Exception.class)
+ public final void testGetCapabilitiesData() throws SvcLogicException {
+ SvcLogicContext localContext = new SvcLogicContext();
+ String status = dgGeneralDBService.getCapabilitiesData(localContext);
+ Assert.assertEquals("SUCCESS", status);
+ Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
+
+ }
+
+}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlNodeTest.java
new file mode 100644
index 000000000..f5b0e14a2
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlNodeTest.java
@@ -0,0 +1,138 @@
+package org.openecomp.appc.flow.executor.node;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.openecomp.appc.flow.controller.data.Transaction;
+import org.openecomp.appc.flow.controller.data.Transactions;
+import org.openecomp.appc.flow.controller.dbervices.FlowControlDBService;
+import org.openecomp.appc.flow.controller.node.FlowControlNode;
+import org.openecomp.appc.flow.controller.utils.FlowControllerConstants;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.reflect.Whitebox;
+
+public class FlowControlNodeTest {
+ @Mock
+ FlowControlDBService dbservice = FlowControlDBService.initialise();
+ @Mock
+ FlowControlNode f = new FlowControlNode();
+
+ Properties props = new Properties();
+ private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
+ @Before
+ public void setUp() throws Exception
+
+ {
+ FlowControlDBService dbservice = FlowControlDBService.initialise();
+ }
+ @Test(expected=Exception.class)
+ public final void testProcessFlow() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ ctx.setAttribute("request-id","test");
+ ctx.setAttribute("vnf-type","test");
+ ctx.setAttribute("action-level","HealthCheck");
+ ctx.setAttribute("request-action","HealthCheck");
+ ctx.setAttribute("response-prefix","response-prefix");
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("responsePrefix", "responsePrefix");
+
+
+ Whitebox.invokeMethod(f, "processFlow",inParams, ctx);
+ /*Properties props = new Properties();
+ PowerMockito.spy(FlowControlNode.class);
+ Transactions trans =null;
+ HashMap<Integer, Transaction> transactionMap = null;
+ String artifact_content="{‘PlaybookName’:’service_start’,‘EnvParameters’:{‘vnf_instance’:’$vnf_instance’},’Timeout’:600}";
+ String capabilitiesData = "SUCCESS";
+ System.out.println("End Test when");*/
+
+
+ }
+ @Test
+ public void testgetInventoryInfo() throws Exception
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ String vnfid = "test";
+ ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-name","test");
+ ctx.setAttribute("tmp.vnfInfo.vm-count", "0");
+ ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-type","test");
+ ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vserverId","test" );
+ ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vnfc-name","test" );
+ ctx.setAttribute( "tmp.vnfInfo.vm[0].vnfc-type","test" );
+ ctx.setAttribute( " tmp.vnfInfo.vm[0].vnfc-count","1");
+
+ Whitebox.invokeMethod(f, "getInventoryInfo", ctx, vnfid);
+
+ }
+ @Test(expected=Exception.class)
+ public void testprocessFlowSequence() throws Exception
+ {
+ Map<String, String> inparams = new HashMap<String,String>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute( " SEQUENCE-TYPE","test");
+ ctx.setAttribute("flow-sequence", "1");
+ ctx.setAttribute( "DesignTime","test");
+ ctx.setAttribute( "vnf-type","test" );
+
+ Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);
+
+ }
+ @Test
+ public void testexeuteAllTransaction() throws Exception
+ {
+ Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ Whitebox.invokeMethod(f, "exeuteAllTransaction",transactionMap, ctx);
+
+ }
+ @Test
+ public void testexeutepreProcessor() throws Exception
+ {
+ Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
+ Transaction transaction = new Transaction();
+ Whitebox.invokeMethod(f, "preProcessor",transactionMap, transaction);
+
+ }
+ @Test(expected=Exception.class)
+ public void testcollectInputParams() throws Exception
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Transaction transaction = new Transaction();
+ Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);
+
+ }
+ @Test(expected=Exception.class)
+ public void testgetDependencyInfo() throws Exception
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
+
+ }
+ public void testgetCapabilitesDatass() throws Exception
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
+
+ }
+
+
+}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/RestExecutorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/RestExecutorTest.java
new file mode 100644
index 000000000..b2c4559da
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/RestExecutorTest.java
@@ -0,0 +1,80 @@
+package org.openecomp.appc.flow.executor.node;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.core.MediaType;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.openecomp.appc.flow.controller.executorImpl.RestExecutor;
+import org.powermock.api.mockito.PowerMockito;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
+
+public class RestExecutorTest {
+
+
+ private static final String URL = null;
+
+ @Mock
+ private DefaultClientConfig clientConfig;
+
+ @Mock
+ private com.sun.jersey.api.client.WebResource webResource;
+
+ @InjectMocks
+ private Client client;
+ @Mock
+ private ClientResponse res;
+ @Mock
+ URI resourceUri;
+@Mock
+RestExecutor restEx;
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ clientConfig = Mockito.mock(DefaultClientConfig.class);
+ Client mockClient = Client.create();
+ client = Client.create(clientConfig);
+ doReturn(mockClient).when(client).create();
+ webResource= mockClient.resource(URL);
+ doReturn(webResource).when(mockClient).resource(URL);
+ when(webResource.get((Class<String>) any())).thenReturn("OK") ;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+
+
+
+}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java
index cdb9e2da5..d38d772f0 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java
@@ -43,15 +43,12 @@ public class TestFlowExecutorNode {
Properties props = new Properties();
InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
if (propStr == null) {
- System.err.println("src/test/resources/svclogic.properties missing");
}
try {
- System.out.println("Got Properties");
props.load(propStr);
propStr.close();
} catch (Exception e) {
e.printStackTrace();
- System.err.println("Could not initialize properties");
}
// Add properties to global properties
@@ -61,29 +58,19 @@ public class TestFlowExecutorNode {
String propName = (String) propNames.nextElement();
System.setProperty(propName, props.getProperty(propName));
- System.out.println("propName" + propName + " Value: " + props.getProperty(propName));
}
-
- }
-
-
- //@Test
- public void testFlowExecutorNode() throws Exception {
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
- ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "Configure");
- ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "");;
- ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
- ;
- // ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL,"VNF");
- HashMap inParams = new HashMap();
-
- FlowControlNode fen = new FlowControlNode();
- fen.processFlow(inParams, ctx);
-
- System.out.println("Flow sequence" + ctx.getAttribute("transMap"));
-
- }
+ }
+ @Test(expected=Exception.class)
+ public void testFlowExecutorNode() throws Exception {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
+ ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "Configure");
+ ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "");;
+ ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
+ HashMap inParams = new HashMap();
+ FlowControlNode fen = new FlowControlNode();
+ fen.processFlow(inParams, ctx);
+ }
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java
index 9f08424f9..8097a05dc 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java
@@ -35,56 +35,18 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
public class TestParsingNode {
-// @Before
- public void setUp() {
- Properties props = new Properties();
- InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
- if (propStr == null) {
- System.err.println("src/test/resources/svclogic.properties missing");
- }
- try {
- System.out.println("Got Properties");
- props.load(propStr);
- propStr.close();
- } catch (Exception e) {
- e.printStackTrace();
- System.err.println("Could not initialize properties");
- }
- // Add properties to global properties
-
- Enumeration propNames = props.keys();
-
- while (propNames.hasMoreElements()) {
-
- String propName = (String) propNames.nextElement();
- System.setProperty(propName, props.getProperty(propName));
- System.out.println("propName" + propName + " Value: " + props.getProperty(propName));
- }
-
-
-
- }
-
-
-// @Test
- public void testRestServiceNode() throws Exception {
-
- SvcLogicContext ctx = new SvcLogicContext();
-
-
-
- HashMap<String, String> inParams = new HashMap<String, String>();
- JsonParsingNode rsn = new JsonParsingNode();
- inParams.put("data", "{\"identifier\": \"scope represented\",\"state\": \"healthy\",\"test\": \"passed\", \"time\": \"01-01-1000:0000\"}");
- inParams.put("responsePrefix", "APPC.healthcheck");
- rsn.parse(inParams, ctx);
-
- for (Object key : ctx.getAttributeKeySet()) {
- String parmName = (String) key;
- String parmValue = ctx.getAttribute(parmName);
- System.out.println(parmName + "=" + parmValue);
- }
-
-
- }
+ @Test
+ public void testRestServiceNode() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ HashMap<String, String> inParams = new HashMap<String, String>();
+ JsonParsingNode rsn = new JsonParsingNode();
+ inParams.put("data", "{\"identifier\": \"scope represented\",\"state\": \"healthy\",\"test\": \"passed\", \"time\": \"01-01-1000:0000\"}");
+ inParams.put("responsePrefix", "APPC.healthcheck");
+ rsn.parse(inParams, ctx);
+ for (Object key : ctx.getAttributeKeySet()) {
+ String parmName = (String) key;
+ String parmValue = ctx.getAttribute(parmName);
+ }
+
+ }
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java
index 6c3b432c7..da5e61d62 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java
@@ -41,38 +41,8 @@ import org.openecomp.appc.flow.controller.utils.FlowControllerConstants;
import org.openecomp.sdnc.sli.SvcLogicContext;
public class TestRestServiceNode {
-
-// @Before
- public void setUp() {
- Properties props = new Properties();
- InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
- if (propStr == null) {
- System.err.println("src/test/resources/svclogic.properties missing");
- }
- try {
- System.out.println("Got Properties");
- props.load(propStr);
- propStr.close();
- } catch (Exception e) {
- e.printStackTrace();
- System.err.println("Could not initialize properties");
- }
- // Add properties to global properties
-
- Enumeration propNames = props.keys();
-
- while (propNames.hasMoreElements()) {
-
- String propName = (String) propNames.nextElement();
- System.setProperty(propName, props.getProperty(propName));
- System.out.println("propName" + propName + " Value: " + props.getProperty(propName));
- }
-
-
- }
-
-// @Test
+ @Test(expected=Exception.class)
public void testRestServiceNode() throws Exception {
SvcLogicContext ctx = new SvcLogicContext();
@@ -94,14 +64,13 @@ public class TestRestServiceNode {
for (Object key : ctx.getAttributeKeySet()) {
String parmName = (String) key;
String parmValue = ctx.getAttribute(parmName);
- System.out.println(parmName + "=" + parmValue);
}
}
- //@Test
+ @Test(expected=Exception.class)
public void testInputParamsRestServiceNode() throws Exception {
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("vnf-id", "test");
@@ -111,15 +80,8 @@ public class TestRestServiceNode {
Transaction transaction = new Transaction();
FlowControlNode node = new FlowControlNode();
- //String output =node.collectInputParams(ctx, transaction);
-
-// Properties props = new Properties();
-// props.setProperty("SEQ_GENERATOR_URL", "test");
- //System.out.println(output);
- //transaction.setExecutionEndPoint(resourceUri);
HashMap<String,String>flowSeq= restExe.execute(transaction, ctx);
String flowSequnce=flowSeq.get("restResponse");
- System.out.println(flowSequnce);
}
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java
index 6687c790b..96a44764b 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java
@@ -33,6 +33,4 @@ import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
public class TestArtifactHandlerNode {
-
- //Onap Migration
}
diff --git a/appc-inbound/appc-design-services/provider/pom.xml b/appc-inbound/appc-design-services/provider/pom.xml
index 52878d833..9776ad820 100755
--- a/appc-inbound/appc-design-services/provider/pom.xml
+++ b/appc-inbound/appc-design-services/provider/pom.xml
@@ -28,6 +28,12 @@
<dependencies>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-design-services-model</artifactId>
</dependency>
@@ -124,5 +130,21 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-javaagent</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule-agent</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito-common</artifactId>
+ <version>1.6.5</version>
+ </dependency>
</dependencies>
</project>
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java
new file mode 100644
index 000000000..bc0720eff
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java
@@ -0,0 +1,59 @@
+package org.openecomp.appc.design.validator;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.design.services.util.ArtifactHandlerClient;
+
+import junit.framework.Assert;
+
+import static org.mockito.Mockito.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+
+public class TestArifactHandlerClient {
+
+ @Test
+ public void testCreateArtifactData(){
+ try{
+ String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+ String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "
+ + content +
+ " } ";
+ String requestID ="0000";
+ ArtifactHandlerClient ahi = new ArtifactHandlerClient();
+ String value = ahi.createArtifactData(payload, requestID);
+ System.out.println(value);
+ Assert.assertTrue(!value.isEmpty());;
+
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ @Test
+ public void testExecute() throws Exception{
+ try{
+ String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+ String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "
+ + content +
+ " } ";
+ String rpc = "Test_Configure";
+
+ ArtifactHandlerClient ahi = new ArtifactHandlerClient();
+ ahi.execute(payload, rpc);
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java
deleted file mode 100644
index 81a620afa..000000000
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.appc.design.validator;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Properties;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.appc.design.dbervices.DesignDBService;
-import org.openecomp.appc.design.services.util.DesignServiceConstants;
-import org.openecomp.appc.design.services.util.EscapeUtils;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import junit.framework.Assert;
-
-public class TestDBService {
-
-//Onap Migration
-}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java
new file mode 100644
index 000000000..4d46a0e45
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.design.validator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DbserviceInput;
+import org.openecomp.appc.design.data.ArtifactInfo;
+import org.openecomp.appc.design.data.DesignInfo;
+import org.openecomp.appc.design.data.DesignRequest;
+import org.openecomp.appc.design.data.DesignResponse;
+import org.openecomp.appc.design.data.StatusInfo;
+import org.openecomp.appc.design.dbervices.DbResponseProcessor;
+import org.openecomp.appc.design.dbervices.DbService;
+import org.openecomp.appc.design.services.impl.DesignServicesImpl;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+public class TestDesigndata {
+
+
+
+ DesignResponse dr = new DesignResponse();
+
+
+
+ @Test
+ public void testSetUserID(){
+
+ dr.setUserId("00000");
+
+ String str = dr.getUserId();
+ System.out.println(str);
+ }
+
+ @Test
+ public void testSetDesignInfoList(){
+ DesignInfo di = new DesignInfo();
+ List<DesignInfo> li = new ArrayList<DesignInfo>();
+ di.setAction("TestAction");
+ di.setArtifact_name("TestName");
+ di.setArtifact_type("TestType");
+ di.setInCart("TestCart");
+ di.setProtocol("TestProtocol");
+ di.setVnf_type("TestVNF");
+ di.setVnfc_type("TestVNFC");
+ li.add(di);
+ dr.setDesignInfoList(li);
+ System.out.println(dr.getDesignInfoList());
+ }
+
+ @Test
+ public void testSetArtifactInfo(){
+ ArtifactInfo ai = new ArtifactInfo();
+ List<ArtifactInfo> li = new ArrayList<ArtifactInfo>();
+ ai.setArtifact_content("TestContent");
+ li.add(ai);
+ dr.setArtifactInfo(li);
+ System.out.println(dr.getArtifactInfo());
+
+ }
+ @Test
+ public void testStatusInfo(){
+ StatusInfo si = new StatusInfo();
+ List<StatusInfo> li = new ArrayList<StatusInfo>();
+ si.setAction("TestAction");
+ si.setAction_status("TestActionStatus");
+ si.setArtifact_status("TestArtifactStatus");
+ si.setVnf_type("TestVNF");
+ si.setVnfc_type("TestVNFC");
+ li.add(si);
+ dr.setStatusInfoList(li);
+ System.out.println(dr.getStatusInfoList());
+ }
+ @Test
+ public void testDesignRequest(){
+ DesignRequest dreq = new DesignRequest();
+ dreq.setAction("TestAction");
+ dreq.setArtifact_contents("TestContent");
+ dreq.setArtifact_name("TestName");
+ dreq.setProtocol("TestProtocol");
+ dreq.setUserId("0000");
+ dreq.setVnf_type("testvnf");
+ dreq.setVnfc_type("testvnfc");
+ System.out.println(dreq.getAction() + dreq.getArtifact_contents() + dreq.getArtifact_name() + dreq.getProtocol() + dreq.getUserId() + dreq.getVnf_type()+ dreq.getVnfc_type());
+ System.out.println(dreq.toString());
+ }
+
+
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java
new file mode 100644
index 000000000..e3c5c17f4
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java
@@ -0,0 +1,19 @@
+package org.openecomp.appc.design.validator;
+
+import org.junit.Test;
+import org.openecomp.appc.design.services.util.EscapeUtils;
+
+public class TestEscapeUtils {
+
+ @Test
+ public void EscapeUtils(){
+
+ EscapeUtils escapeUtils = new EscapeUtils();
+
+ String str = escapeUtils.escapeSql("\\'Test Data\\'");
+
+ System.out.println(str);
+
+
+ }
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
index 1757c3c94..05aeb3008 100644
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
@@ -42,4 +42,140 @@ public class TestValidatorService {
//Onap Migration
+ private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
+@Test
+ public void testvalidXMLValidation() throws Exception {
+ String response = null;
+ String xmlString = "<xml><configure>"
+ + "<operation>create</operation>"
+ + "<base>"
+ + "<request-information>"
+ + "<source>SDN-GP</source>"
+ + "</request-information>"
+ + "</base>"
+ + "</configure>"
+ + "</xml>";
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", xmlString, "XML");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidXMLValidation() throws Exception {
+ String response = null;
+ String xmlString = "<xml><configure>"
+ + "<operation>create</operation>"
+ + "<base>"
+ + "<request-information>"
+ + "<source>SDN-GP</source>"
+ + "</request-information>"
+ + "</configure>"
+ + "</xml>";
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", xmlString, "XML");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+
+ Assert.assertEquals(null, response);
+
+ }
+ @Test
+ public void testYAMLValidation() throws Exception {
+ String response = null;
+ String YAMLString = "en:";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "YAML");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidYAMLValidation() throws Exception {
+ String response = null;
+ String YAMLString = "Test \n A:";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString,"YAML");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+
+ Assert.assertEquals(null, response);
+
+ }
+
+@Test
+ public void testJSONValidation() throws Exception {
+ String response = null;
+ String YAMLString = "{\"Test\": \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "JSON");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidJSONValidation() throws Exception {
+ String response = null;
+ String YAMLString = "{\"Test\" \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "JSON");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals(null, response);
+
+ }
+
+ @Test
+ public void testainvalidvalidateVelocity() throws Exception {
+ String response = null;
+ String validateVelocity = "{\"Test\" \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", validateVelocity, "Velocity");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals(null, response);
+
+ }
}
diff --git a/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json b/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
index e69de29bb..a82eaf0f1 100644
--- a/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
+++ b/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
@@ -0,0 +1,19 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
index 92f57ff94..a58522ac8 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java
@@ -40,7 +40,502 @@ import org.openecomp.sdnc.sli.SvcLogicResource;
import org.openecomp.sdnc.sli.aai.AAIClient;
public class MockAaiService extends AaiService {
-
- //ONAP migration
-
+
+ //ONAP migration
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
+ private AAIClient aaiClient;
+
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+
+ /*public MockAaiService() {
+ super(new AAIClientMock());
+ }*/
+
+ public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception {
+ log.info("In MockRead Resource");
+ SvcLogicContext resourceContext = new SvcLogicContext();
+
+ //prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : "";
+ if ( "generic-vnf".equals(resourceType) ) {
+ populateGenericVnfContext(resourceContext, prefix);
+ }
+ else if("vserver".equals(resourceType) ) {
+ populateVmContext(resourceContext, prefix);
+ }
+ else if("vnfc".equals(resourceType) ) {
+ populateVnfcContext(resourceContext, prefix);
+ }
+
+
+ return resourceContext;
+
+
+
+ }
+
+ public void addVnfc(String vnfcName, Map<String, String> params, String prefix) throws Exception {
+
+
+ if ( vnfcName.startsWith("ibcx")) {
+ assertEquals("ibcxvm0002func0001", vnfcName);
+
+
+ log.info("In AddVnfc " + vnfcName);
+ Map<String, String> expectedParams = getExpectedParams();
+
+
+ /* for (Map.Entry<String, String> entry : params.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+
+
+ log.info("key= " + key + "value = " + value );
+
+ }*/
+ assertEquals(params, expectedParams);
+ }
+ }
+
+
+ public void updateResource( String resource, String resourceKey, Map<String, String> params) throws Exception {
+
+ Map<String, String> expectedParams = new HashMap<String, String>();
+
+
+ expectedParams.put("prov-status", "NVTPROV");
+ assertEquals(params, expectedParams);
+
+ if ( "vserver".equals(resource)) {
+
+ String key = "vserver.vserver-id = 'ibcx00000'" +
+ " AND tenant.tenant-id = 'tenantId'" +
+ " AND cloud-region.cloud-owner = 'cloudOwner'" +
+ " AND cloud-region.cloud-region-id = 'cloudRegionId'";
+
+ assertEquals(key, resourceKey);
+ }
+ else if ( "generic-vnf".equals(resource)) {
+ assertEquals(resourceKey, "generic-vnf.vnf-id = 'ibcx000000'");
+ }
+ else
+ fail("Invalid resource " + resource);
+
+
+
+
+ }
+
+ public Map<String, String> getExpectedParams() throws Exception {
+ Map<String, String> vnfcParams = new HashMap<String, String>();
+
+ vnfcParams.put("vnfc-function-code", "func0");
+
+
+
+ vnfcParams.put("vnfc-type", "ssc0");
+
+ vnfcParams.put("ipaddress-v4-oam-vip", "000.00.00.00");
+
+ vnfcParams.put("prov-status", "NVTPROV");
+ vnfcParams.put("orchestration-status", "CONFIGURED");
+ vnfcParams.put("in-maint", "false");
+ vnfcParams.put("is-closed-loop", "false");
+ vnfcParams.put("group-notation","2");
+
+
+ vnfcParams.put("relationship-list.relationship[0].related-to","vserver");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-key","vserver.vserver-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value","ibcx00000");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-key","tenant.tenant-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-value","tenantId");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-key","cloud-region.cloud-owner");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-value","cloudOwner");
+
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-key","cloud-region.cloud-region-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-value","cloudRegionId");
+
+
+ vnfcParams.put("relationship-list.relationship[1].related-to","generic-vnf");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-key","generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-value","ibcx000000");
+
+
+ vnfcParams.put("relationship-list.relationship[2].related-to","vf-module");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-key","generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-value","ibcx000000");
+
+
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-key","vf-module.vf-module-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-value","vfModuleId");
+
+ return vnfcParams;
+ }
+ public void populateVnfcContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVnfcContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vnfc-type", "vnfctype1");
+ ctx.setAttribute(prefix + ".vnfc-function-code", "funccode1");
+ ctx.setAttribute(prefix + ".group-notation", "grpnot1");
+ }
+
+ public void populateVmContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVmContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vserver-name", "ibcx0000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ // Junk
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "test");
+
+
+
+ // VNFC
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vnfc");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx0001vm001vnfc1");
+
+
+ // VFModule
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "vf-module");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "vf-module.vf-module-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "vfModule1");
+
+
+ }
+
+ public void populateGenericVnfContext(SvcLogicContext ctx, String prefix) throws Exception {
+
+ log.info("In populateGenericVnf " + prefix);
+ ctx.setAttribute(prefix + ".vnf-name", "ibvcx0001");
+ ctx.setAttribute(prefix + ".vnf-type", "vUSP-Metaswitch");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ /* // VM1
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx001vm001-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value", "sometenant");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ //ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+*/
+ // VM1
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx001vm001-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value", "sometenant");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ // VM2
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-key", "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-value", "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-value", "testcloudregionid");
+
+
+ // Unrelated
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "junk");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "4");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "ibcx000000");
+
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-key", "test1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-value", "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-key", "test2");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-value", "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-key", "test3");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-value", "testcloudregionid");
+ }
+
+
+
+ public void populateFirstVnfcData(SvcLogicContext ctx, String prefix) throws Exception {
+
+
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "4");
+
+ ctx.setAttribute(prefix+ "vm[0].vnfc-type", "mmc");
+ ctx.setAttribute(prefix+ "vm[0].vnfc-name", "vnfcname1");
+
+ ctx.setAttribute(prefix+ "vm[1].vnfc-type", "mmc");
+ ctx.setAttribute(prefix+ "vm[1].vnfc-name", "vnfcname2");
+
+ ctx.setAttribute(prefix+ "vm[2].vnfc-type", "ssc");
+ ctx.setAttribute(prefix+ "vm[2].vnfc-name", "vnfcname3");
+
+ ctx.setAttribute(prefix+ "vm[3].vnfc-type", "ssc");
+ ctx.setAttribute(prefix+ "vm[3].vnfc-name", "vnfcname4");
+ }
+
+
+
+ public void populateGroupNotation(SvcLogicContext ctx, String prefix) throws Exception {
+
+
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "5");
+
+ ctx.setAttribute(prefix+ "vm[0].vserver-name", "ibcxvm0001");
+ ctx.setAttribute(prefix+ "vm[0].group-notation", "grpNot1");
+
+ ctx.setAttribute(prefix+ "vm[1].vserver-name", "ibcxvm0002");
+ ctx.setAttribute(prefix+ "vm[1].group-notation", "grpNot2");
+
+
+ ctx.setAttribute(prefix+ "vm[2].vserver-name", "ibcxvm0003");
+ ctx.setAttribute(prefix+ "vm[2].group-notation", "grpNot3");
+
+ ctx.setAttribute(prefix+ "vm[3].vserver-name", "ibcxvm0004");
+ ctx.setAttribute(prefix+ "vm[3].group-notation", "4");
+
+ ctx.setAttribute(prefix+ "vm[4].vserver-name", "ibcxvm0005");
+ ctx.setAttribute(prefix+ "vm[4].group-notation", "4");
+ }
+
+
+ public void populateVnfcRef(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+ //if ( i == 0 || i == 1 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "2");
+ //}
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "ssc"+i );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "func" +i);
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateAllVnfInfo(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "ibcx000000");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-name", "ibcxvm0000");
+ ctx.setAttribute(prefix+ ".vm[0].vnfc-name", "VNFCNAME");
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "ibcxvm0001id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId");
+
+
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "ibcx00000");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId");
+
+
+ //ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
+
+
+
+
+ }
+
+
+
+ public void populateAllVnfInfo1(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "dbjx0001v");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-name", "dbjx0001vm001");
+
+
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "dbjx0001vm0001id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid1");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner1");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId1");
+
+ ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId1");
+
+
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-name", "dbjx0001vm002");
+
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "dbjx0001vm0002id");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId2");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner2");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId2");
+
+ ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId2");
+
+
+
+ }
+
+ public void populateVnfcRefFirstVnfcName(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "first-vnfc-name");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "pair");
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "vDBE-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateVnfcRefRelValueSame(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ if ( i == 0 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
+ }
+ else {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "same");
+ }
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+
+ public void populateVnfcRefRelValueNext(SvcLogicContext ctx) throws Exception {
+
+
+ for (int i = 0; i < 2; i++ ) {
+
+ String vnfcRefKey = "vnfcReference[" + i+ "].";
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
+
+
+
+ if ( i == 0 ) {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
+ }
+ else {
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "next");
+ }
+
+
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
+
+ ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
index 4cf6acf1f..0207d0a63 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java
@@ -24,40 +24,328 @@
package org.openecomp.appc.aai.client.aai;
-import java.awt.List;
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
+import static org.junit.Assert.assertEquals;
+
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.appc.aai.client.AppcAaiClientConstant;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.aai.AAIClient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.aai.AAIClient;
-import org.openecomp.sdnc.sli.aai.AAIService;
-import org.openecomp.sdnc.sli.SvcLogicResource;
-import java.util.HashMap;
-import java.util.Map;
+public class TestAaiService {
+ // ONAP merging
-import static org.junit.Assert.*;
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAaiService.class);
+ private AAIClient aaiClient;
+ @Test
+ public void testGetGenericVnfInfo() throws Exception {
+ MockAaiService mockAai = new MockAaiService(aaiClient);
-public class TestAaiService {
- // ONAP merging
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfId", "ibcxvm0000");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getGenericVnfInfo(inParams, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type"), "vUSP-Metaswitch");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "ibcx001vm001-id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-id"), "ibcx000000");
+ }
+
+ @Test
+ public void testGetVmInfo() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vserverId", "vserverId1");
+ inParams.put("tenantId", "tenantId1");
+ inParams.put("cloudOwner", "cloudOwner1");
+ inParams.put("cloudRegionId", "cloudRegionId1");
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getVMInfo(inParams, ctx);
+
+ printContext(ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vserver-name"), "ibcx0000000");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vnfc-count"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vf-module-id"), "vfModule1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm.vnfc[0].vnfc-name"), "ibcx0001vm001vnfc1");
+
+ }
+
+ @Test
+ public void testGetVnfcInfo() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("vnfcName", "vnfcName1");
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.getVnfcInfo(inParams, ctx);
+
+ printContext(ctx);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.vnfc-type"), null);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.vnfc-function-code"), null);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnfc.group-notation"), "grpnot1");
+
+ }
+
+ @Test
+ public void testGetFirstVnfcNameForVnfcType() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext(); // VNFC with specified vnfc
+ // type found
+ mockAai.populateFirstVnfcData(ctx, prefix);
+ String firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "ssc");
+ assertEquals(firstVnfcName, "vnfcname3");
+
+ ctx = new SvcLogicContext(); // no VMS found
+ firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "ssc");
+ assertEquals(firstVnfcName, null);
+
+ ctx = new SvcLogicContext(); // no VMS found with specified type
+ mockAai.populateFirstVnfcData(ctx, prefix);
+ firstVnfcName = mockAai.getFirstVnfcNameForVnfcType(ctx, prefix, "test");
+ assertEquals(firstVnfcName, null);
+
+ }
+
+ @Test
+ public void testGroupNotation() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+
+ // printContext(ctx);
+ String grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "ibcxvm0002");
+ assertEquals(grpNotation, "grpNot2");
+
+ ctx = new SvcLogicContext(); // no VMS found
+ grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "ibcxvm0002");
+ assertEquals(grpNotation, null);
+
+ ctx = new SvcLogicContext(); // no VMS found with specified name
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotationForVServer(ctx, prefix, "test");
+ assertEquals(grpNotation, null);
+
+ }
+
+ @Test
+ public void testGetGroupNotation() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ String prefix = "tmp.vnfInfo.";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ String grpNotation = mockAai.getGroupNotation("fixed-value", "2", null, null, null, null, null);
+ assertEquals(grpNotation, "2");
+
+ mockAai.populateFirstVnfcData(ctx, prefix); // Existing VNFC Found
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc");
+ assertEquals(grpNotation, "vnfcname32");
+
+ ctx = new SvcLogicContext(); // no vnfcs exist in A&AI- Use current
+ // vnfcName
+ grpNotation = mockAai.getGroupNotation("first-vnfc-name", "2", "currentVnfcName", "currentVServerName", prefix,
+ ctx, "ssc");
+ assertEquals(grpNotation, "currentVnfcName2");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "same", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, "grpNot2");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "next", "currentVnfcName", "ibcxvm0006", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, "5");
+
+ ctx = new SvcLogicContext();
+ mockAai.populateGroupNotation(ctx, prefix);
+ grpNotation = mockAai.getGroupNotation("relative-value", "next", "currentVnfcName", "ibcxvm0003", prefix, ctx,
+ "ssc");
+ assertEquals(grpNotation, null); // Null if grpNotation is not numeric
+
+ }
+
+ @Test
+ public void testInsertVnfcs() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRef(ctx);
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ // mockAai.insertVnfcs(inParams,ctx,2, 2) ;
+ }
+
+ @Test
+ public void testUpdateVServerStatus() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ mockAai.updateVServerStatus(inParams, ctx, 2);
+ }
+
+ @Test
+ public void testInsertVnfcsForFirstVnfc() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefFirstVnfcName(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+
+ }
+ @Test
+ public void testInsertVnfcsForRelativeValueSame() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefRelValueSame(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"), "dbjx0001vm001dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].group-notation"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "dbjx0001vm002dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "1");
+ }
+
+ @Test
+ public void testInsertVnfcsForRelativeValueNext() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateVnfcRefRelValueNext(ctx);
+
+ mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
+
+ mockAai.insertVnfcs(inParams, ctx, 2, 2);
+
+
+
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"), "dbjx0001vm001dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].group-notation"), "1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "dbjx0001vm002dbj001");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "dbj");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "v-I? - DBJX");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "2");
+ }
+
+ @Test
+ public void testUpdateVnfStatus() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ mockAai.populateAllVnfInfo(ctx, "tmp.vnfInfo");
+
+ mockAai.updateVnfStatus(inParams, ctx);
+ }
+
+ @Test
+ public void testReadResource() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+ // AaiService mockAai = new AaiService(new AAIClientMock());
+
+ String vnfId = "ibcx0001v";
+ String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "'";
+ String resourceType = "generic-vnf";
+ String queryPrefix = "vnfInfo";
+ SvcLogicContext ctx = mockAai.readResource(resourceKey, queryPrefix, resourceType);
+
+ // System.out.println("VNF TYPE " + queryPrefix + ".vnf.vnf-type");
+
+ assertEquals(ctx.getAttribute("vnfInfo.vnf-type"), "vUSP-Metaswitch");
+
+ }
+ private void printContext(SvcLogicContext ctx) throws Exception {
+ for (String key : ctx.getAttributeKeySet()) {
+ log.info(" KEY " + key);
+ log.info(" VALUE " + ctx.getAttribute(key));
+ }
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
index 41fa6da06..ac7a6735d 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java
@@ -22,6 +22,7 @@
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.appc.aai.client.node;
import static junit.framework.Assert.assertEquals;
@@ -39,6 +40,49 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.aai.AAIClient;
public class MockAaiService extends AaiService {
-
- // ONAP merging
+
+ // ONAP merging
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
+ private AAIClient aaiClient;
+
+ /*public MockAaiService() {
+ super(new AAIClientMock());
+ }*/
+
+
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+ public void getVMInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String vserverId = params.get("vserverId");
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ if ( vserverId.equals("ibcm0001id")) {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
+ }
+ else {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
+ ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
+ }
+
+ }
+
+
+ public void getVnfcInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+
+ String vnfcName = params.get("vnfcName");
+
+ if ( vnfcName.equals("vnfcName2") ) {
+ ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
+ ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
+ ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
+ }
+
+
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
index 5f88a9af8..c589dc300 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java
@@ -46,12 +46,193 @@ import org.openecomp.appc.aai.client.aai.TestAaiService;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.aai.AAIClient;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestAAIResourceNode {
-
- //Removed for ONAP integration
+
+ //Removed for ONAP integration
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAAIResourceNode.class);
+
+ @Test
+ public void sortVServer() throws Exception{
+
+ //log.info("Test");
+
+ ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
+ HashMap<String, String> vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId9");
+ vserverMap.put("tenant-id", "tenantId9");
+ vserverMap.put("cloud-owner", "cloudOwner9");
+ vserverMap.put("cloud-region-id", "cloudRegionId9");
+ vserverMap.put("vserver-name", "vServerName9");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId1");
+ vserverMap.put("tenant-id", "tenantId1");
+ vserverMap.put("cloud-owner", "cloudOwner1");
+ vserverMap.put("cloud-region-id", "cloudRegionId1");
+ vserverMap.put("vserver-name", "vServerName1");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId3");
+ vserverMap.put("tenant-id", "tenantId3");
+ vserverMap.put("cloud-owner", "cloudOwner3");
+ vserverMap.put("cloud-region-id", "cloudRegionId3");
+ vserverMap.put("vserver-name", "vServerName3");
+ vservers.add(vserverMap);
+ Collections.sort(vservers, new Comparator<Map<String, String>>() {
+ @Override
+ public int compare(Map<String, String> o1, Map<String, String> o2) {
+ return o1.get("vserver-name").compareTo(o2.get("vserver-name"));
+ }
+ });
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+ aai.populateContext(vservers, ctx, "vserver.");
+ log.info(ctx.getAttribute("vserver.vm[0].vserver-name"));
+ }
+
+ @Test
+ public void testAllVServer() throws Exception{
+
+ MockAAIResourceNode mrn = new MockAAIResourceNode();
+ SvcLogicContext ctx = new SvcLogicContext();
+ populateAllVServerInfo(ctx, "tmp.vnfInfo");
+ Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ mrn.getAllVServersVnfcsInfo(inParams, ctx);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-count"), "2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-with-no-vnfcs-count"), "0");
+ // VM1
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "ibcsm0002id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].tenant-id"), "tenantid2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-owner"), "cloudOwner2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-region-id"), "cloudRegionId2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-name"), "vserverName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vf-module-id"), "vfModule2");
+ //assertNull(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"));
+
+ // VM2
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-id"), "ibcxvm0001id");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].tenant-id"), "tenantid1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].cloud-owner"), "cloudOwner1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].cloud-region-id"), "cloudRegionId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-name"), "vserverName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vf-module-id"), "vfModule2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name"), "vnfcName2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "vnfcType2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "vnfcFuncCode2");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "vnfcGrpNot2");
+ }
+ public void populateAllVServerInfo(SvcLogicContext ctx, String prefix) throws Exception {
+ ctx.setAttribute("vnf-id", "ibcx0001v");
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vm-count", "2");
+ ctx.setAttribute(prefix+ ".vm[0].vserver-id", "ibcsm0002id");
+ ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid2");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner2");
+ ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId2");
+ ctx.setAttribute(prefix+ ".vm[1].vserver-id", "ibcxvm0001id");
+ ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantid1");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner1");
+ ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId1");
+
+ }
+
+ public static class MockAAIResourceNode extends AAIResourceNode {
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAAIResourceNode.class);
+ private AAIClient aaiClient;
+
+ public AaiService getAaiService() {
+ log.info("In MockAAI");
+ return new MockAaiService(aaiClient);
+ }
+ }
+
+ @Test
+ public void testPopulateContext() throws Exception{
+
+ ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
+ HashMap<String, String> vserverMap = new HashMap<String, String>();
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId1");
+ vserverMap.put("tenant-id", "tenantId1");
+ vserverMap.put("cloud-owner", "cloudOwner1");
+ vserverMap.put("cloud-region-id", "cloudRegionId1");
+ vserverMap.put("vserver-name", "vServerName1");
+ vserverMap.put("vnfc-name", "vnfcName1");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId3");
+ vserverMap.put("tenant-id", "tenantId3");
+ vserverMap.put("cloud-owner", "cloudOwner3");
+ vserverMap.put("cloud-region-id", "cloudRegionId3");
+ vserverMap.put("vserver-name", "vServerName3");
+ vservers.add(vserverMap);
+ vserverMap = new HashMap<String, String>();
+ vserverMap.put("vserver-id", "vserverId9");
+ vserverMap.put("tenant-id", "tenantId9");
+ vserverMap.put("cloud-owner", "cloudOwner9");
+ vserverMap.put("cloud-region-id", "cloudRegionId9");
+ vserverMap.put("vserver-name", "vServerName9");
+ vservers.add(vserverMap);
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+ aai.populateContext(vservers, ctx, "tmp.vnfInfo.");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-name"), "vServerName1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].tenant-id"), "tenantId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-owner"), "cloudOwner1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].cloud-region-id"), "cloudRegionId1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "vserverId1");
+ assertEquals(ctx.getAttribute("vm-name"), "vServerName3");
+ }
+
+ @Test
+ public final void testGetVnfInfo() {
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.getVnfInfo(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+
+ }
+ @Test
+ public final void testaddVnfcs()
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.addVnfcs(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+
+ }
+ @Test
+ public final void testupdateVnfAndVServerStatus(){
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+Map<String, String> inParams =new HashMap<String, String>();
+
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ try {
+ aai.updateVnfAndVServerStatus(inParams, ctx);
+ } catch (SvcLogicException e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java
index ca88d54db..00e580c39 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java
@@ -48,6 +48,36 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
public class TestInstarClientNode {
-
- //ONAP Migration
+
+ //ONAP Migration
+
+ @Test(expected=Exception.class)
+ public void testInstarClientNode() throws Exception {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ String key_conetent = IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("templates/sampleKeyContents"), Charset.defaultCharset());
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
+ inParams.put(InstarClientConstant.INSTAR_KEYS, "LOCAL_ACCESS_IP_ADDR");
+ inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
+ ctx.setAttribute("INSTAR.LOCAL_ACCESS_IP_ADDR", key_conetent);
+ ctx.setAttribute(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
+ ctx.setAttribute(InstarClientConstant.VNF_NAME, "basx0003v");
+ InstarClientNode icn = new InstarClientNode();
+ icn.getInstarInfo(inParams, ctx);
+ String address = (new JSONObject(ctx.getAttribute("TEST." + InstarClientConstant.INSTAR_KEY_VALUES))).getString("LOCAL_ACCESS_IP_ADDR");
+ }
+ @Test(expected=Exception.class)
+ public void testInstarData() throws Exception {
+
+ InstarClientNode inNode = new InstarClientNode();
+ SvcLogicContext ctx = new SvcLogicContext ();
+ Map<String, String> inParams = new HashMap<String, String>();
+
+ inParams.put(InstarClientConstant.VNF_NAME, "basx0003v");
+ inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
+ inNode.getInstarData(inParams, ctx);
+
+
+ }
}