aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config')
-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
13 files changed, 739 insertions, 118 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);
}
}