diff options
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/test/java/org/onap')
6 files changed, 658 insertions, 0 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java new file mode 100644 index 000000000..4c44e0d86 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java @@ -0,0 +1,172 @@ +/*-
+ * ============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.onap.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.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+import org.onap.ccsdk.sli.adaptors.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);
+
+ }
+
+
+ @Ignore("Test is taking 60 seconds")
+ @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);
+
+
+
+
+ }
+
+ @Ignore("Test is taking 60 seconds")
+ @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);;
+
+
+ }
+
+ @Ignore("Test is taking 60 seconds")
+ @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);
+
+ }
+
+ @Ignore("Test is taking 60 seconds")
+ @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/onap/appc/flow/executor/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java new file mode 100644 index 000000000..f29628dcc --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java @@ -0,0 +1,165 @@ +/*-
+ * ============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.onap.appc.flow.executor.node;
+
+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.Ignore;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.data.Transactions;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.node.FlowControlNode;
+import org.onap.appc.flow.controller.utils.FlowControllerConstants;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.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();
+ }
+ @Ignore("Test is taking 60 seconds")
+ @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);
+
+ }
+ @Ignore("Test is taking 60 seconds")
+ @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);
+
+ }
+ @Ignore("Test is taking 60 seconds")
+ @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/onap/appc/flow/executor/node/RestExecutorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/RestExecutorTest.java new file mode 100644 index 000000000..11ddbe024 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/RestExecutorTest.java @@ -0,0 +1,103 @@ +/*-
+ * ============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.onap.appc.flow.executor.node;
+
+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.onap.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/onap/appc/flow/executor/node/TestFlowExecutorNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestFlowExecutorNode.java new file mode 100644 index 000000000..3fe545334 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestFlowExecutorNode.java @@ -0,0 +1,79 @@ +/*- + * ============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========================================================= + */ + +package org.onap.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.onap.appc.flow.controller.node.FlowControlNode; +import org.onap.appc.flow.controller.utils.FlowControllerConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestFlowExecutorNode { + + private final Logger logger = LoggerFactory.getLogger(TestFlowExecutorNode.class); + + + //@Before + public void setUp() { + Properties props = new Properties(); + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + if (propStr == null) { + } + try { + props.load(propStr); + propStr.close(); + } catch (Exception e) { + e.printStackTrace(); + } + // Add properties to global properties + + Enumeration propNames = props.keys(); + + while (propNames.hasMoreElements()) { + + String propName = (String) propNames.nextElement(); + System.setProperty(propName, props.getProperty(propName)); + } + + } + + @Ignore("Test is taking 60 seconds") + @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/onap/appc/flow/executor/node/TestParsingNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestParsingNode.java new file mode 100644 index 000000000..ca84ca56a --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestParsingNode.java @@ -0,0 +1,52 @@ +/*- + * ============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========================================================= + */ + +package org.onap.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.appc.flow.controller.node.FlowControlNode; +import org.onap.appc.flow.controller.node.JsonParsingNode; +import org.onap.appc.flow.controller.node.RestServiceNode; +import org.onap.appc.flow.controller.utils.FlowControllerConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +public class TestParsingNode { + + @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/onap/appc/flow/executor/node/TestRestServiceNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestRestServiceNode.java new file mode 100644 index 000000000..ef661e3db --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/TestRestServiceNode.java @@ -0,0 +1,87 @@ +/*- + * ============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========================================================= + */ + +package org.onap.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.appc.flow.controller.data.Transaction; +import org.onap.appc.flow.controller.executorImpl.RestExecutor; +import org.onap.appc.flow.controller.interfaceData.ActionIdentifier; +import org.onap.appc.flow.controller.interfaceData.InventoryInfo; +import org.onap.appc.flow.controller.interfaceData.RequestInfo; +import org.onap.appc.flow.controller.interfaceData.Vm; +import org.onap.appc.flow.controller.interfaceData.VnfInfo; +import org.onap.appc.flow.controller.interfaceData.Vnfcslist; +import org.onap.appc.flow.controller.node.FlowControlNode; +import org.onap.appc.flow.controller.node.RestServiceNode; +import org.onap.appc.flow.controller.utils.FlowControllerConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +public class TestRestServiceNode { + + @Test(expected=Exception.class) + public void testRestServiceNode() throws Exception { + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB"); + ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck"); + ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF"); + ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK"); + ctx.setAttribute("host-ip-address","127.0.0.1"); + ctx.setAttribute("port-number","8888"); + ctx.setAttribute("request-action-type","GET"); + ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check"); + + HashMap<String, String> inParams = new HashMap<String, String>(); + RestServiceNode rsn = new RestServiceNode(); + inParams.put("output-state", "state"); + inParams.put("responsePrefix", "healthcheck"); + rsn.sendRequest(inParams, ctx); + + for (Object key : ctx.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + } + + + } + + + @Test(expected=Exception.class) + public void testInputParamsRestServiceNode() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("vnf-id", "test"); + ctx.setAttribute("tmp.vnfInfo.vm-count", "1"); + ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1"); + RestExecutor restExe = new RestExecutor(); + Transaction transaction = new Transaction(); + + FlowControlNode node = new FlowControlNode(); + HashMap<String,String>flowSeq= restExe.execute(transaction, ctx); + String flowSequnce=flowSeq.get("restResponse"); + + } +} |