aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider/src/test
diff options
context:
space:
mode:
authorDilip kumar Pampana <dilip.kumar.pampana@ibm.com>2018-07-30 16:41:19 -0400
committerTakamune Cho <tc012c@att.com>2018-07-31 15:24:14 +0000
commitbfbb6d5ab8b95b1c6790ea5a25c698cdbbc135e0 (patch)
tree7fdf9a948be50e41b064cecca641a05e9fa36865 /appc-inbound/appc-design-services/provider/src/test
parent2f1fafa9ba653e80bc2194e8aead62eef4cc3d1c (diff)
Junits for Inbound/designServices
Added new test class files for code coverage of DesignDBServices and removed version for mockito-core as it is overriding existing one in pom.xml file in design services provide. Issue-ID: APPC-1117 Change-Id: I9eddf30c7e3c72467f4bf5f5850c22c083f51a9f Signed-off-by: Dilip kumar Pampana <dilip.kumar.pampana@ibm.com>
Diffstat (limited to 'appc-inbound/appc-design-services/provider/src/test')
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java253
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesignDBServices.java180
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestRequestValidator.java94
3 files changed, 274 insertions, 253 deletions
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java
deleted file mode 100644
index 071c4b24d..000000000
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * ================================================================================
- * Copyright (C) 2018 IBM
- * =============================================================================
- * 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.design.validator;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Properties;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.design.dbervices.DbService;
-import org.onap.appc.design.dbervices.DesignDBService;
-import org.onap.appc.design.propertyServices.PropertyUpdateService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import junit.framework.Assert;
-import org.powermock.reflect.Whitebox;
-
-public class TestDBService {
-
- private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class);
-
- @Ignore("Test is taking 60 seconds")
- @Test
- public void testGetDesigns() {
- try {
- String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }";
- DesignDBService dbservice = DesignDBService.initialise();
- dbservice.execute("getDesigns", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testGetStatus() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } ";
- DesignDBService dbservice = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- dbservice.execute("getStatus", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testUploadArtifact() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } ";
- DesignDBService dbservice = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- dbservice.execute("uploadArtifact", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testGetArtifact() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("getArtifact", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testSetIncart() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"inCart\":\"Y\",\"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("setInCart", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testSetProtocolReference() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("setProtocolReference", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testSetStatus() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("setStatus", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testGetArtifactReference() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("getArtifactReference", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Ignore("Test is taking 120 seconds")
- @Test
- public void testGetGuiReference() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- DbService db = new DbService();
- Whitebox.invokeMethod(db, "getDbLibService");
- design.execute("getGuiReference", payload, "1234");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testPropertyUpdateService() {
- PropertyUpdateService ps = new PropertyUpdateService();
- }
-
- @Test
- public void testLinkstatusRelationShip() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload);
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testGetSDCReferenceID() {
-
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "getSDCReferenceID", payload);
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testGetDataFromActionStatus() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testSetActionStatus() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testGetSDCArtifactIDbyRequestID() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "getSDCArtifactIDbyRequestID", "0");
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testCreateArtifactTrackingRecord() {
- try {
- String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
- String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } ";
- DesignDBService design = DesignDBService.initialise();
- Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1);
- } catch (Exception e) {
- }
- }
- @Test
- public void testGetAppcTimestampUTC() throws Exception {
- String requestId = "1234";
- DesignDBService design = DesignDBService.initialise();
- String result = Whitebox.invokeMethod(design, "getAppcTimestampUTC",requestId);
- assertTrue(result.endsWith("Z"));
- }
-
-}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesignDBServices.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesignDBServices.java
new file mode 100644
index 000000000..98414964b
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesignDBServices.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 IBM
+ * =============================================================================
+ * 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.design.validator;
+
+import static org.junit.Assert.*;
+
+import java.sql.ResultSet;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import static org.mockito.Mockito.when;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.appc.design.dbervices.DbService;
+import org.onap.appc.design.dbervices.DesignDBService;
+import org.onap.appc.design.services.util.ArtifactHandlerClient;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.reflect.Whitebox;
+
+@RunWith(MockitoJUnitRunner.class)
+@PrepareForTest(DesignDBService.class)
+public class TestDesignDBServices {
+
+ private DesignDBService designDbService;
+
+ private DesignDBService spyDesign;
+
+ @Mock
+ private DbService dbservice;
+
+ @Mock
+ private ResultSet rs;
+
+ @Mock
+ private ArtifactHandlerClient artifactHandlerClient;
+
+ @Before
+ public void setUp() throws Exception {
+ Map<String, String> outputMessage = new HashMap<>();
+ designDbService = DesignDBService.initialise();
+ Whitebox.setInternalState(designDbService, "dbservice", dbservice);
+ // Whitebox.setInternalState(designDbService, "ac",
+ // artifactHandlerClient);
+ Mockito.doReturn(outputMessage).when(artifactHandlerClient).execute(Mockito.anyString(), Mockito.anyString());
+ when(dbservice.getDBData(Mockito.anyString(), Mockito.anyList())).thenReturn(rs);
+ when(rs.next()).thenReturn(true, true, false);
+ Mockito.doReturn(true).when(dbservice).updateDBData(Mockito.anyString(), Mockito.anyList());
+
+ spyDesign = Mockito.spy(designDbService);
+ }
+
+ @Test
+ public void testSetStatus() throws Exception {
+ String payload = "{\"userID\": \"1234\", \"vnf-type\" : \"DesigTest-VNF\",\"artifact_status\":\"TestArtifactStatus\",\"action_status\":\"TestAction\",\"vnfc-type\":\"TestVnfc\" }";
+ String json = Whitebox.invokeMethod(spyDesign, "setStatus", payload, "1234");
+ assertEquals(true, json.contains("1234"));
+ }
+
+ @Test
+ public void testGetDesigns() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"artifact_status\":\"TestArtifactStatus\",\"action_status\":\"TestAction\" }";
+ String result = Whitebox.invokeMethod(spyDesign, "getDesigns", payload, "1234");
+ assertEquals(true, result.contains("0000"));
+ }
+
+ @Test
+ public void testGetDesignsWithFilter() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"filter\":\"TestFilter\" }";
+ String result = Whitebox.invokeMethod(spyDesign, "getDesigns", payload, "1234");
+ assertEquals(true, result.contains("0000"));
+ }
+
+ @Test
+ public void testSetInCartr() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"inCart\":\"TestInCart\",\"vnfc-type\":\"TestVnfc\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "setInCart", payload, "1234");
+ assertEquals(true, result.contains("success"));
+ }
+
+ @Test
+ public void testSetProtocolReference() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"template\":\"TestTemplate\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "setProtocolReference", payload, "1234");
+ assertEquals(true, result.contains("success"));
+ }
+
+ @Ignore
+ @Test(expected = ExceptionInInitializerError.class)
+ public void TestUploadArtifact() throws Exception {
+ String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": \"TestContents\"} ";
+ Whitebox.invokeMethod(spyDesign, "uploadArtifact", payload, "1234");
+ }
+
+ @Test
+ public void testLinkstatusRelationShip() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"template\":\"TestTemplate\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "linkstatusRelationShip", 0, 0, payload);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testGetSDCReferenceID() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"artifact-type\" :\"DESIGNTOOL-TEST\", \"artifact-name\":\"DesignRestArtifact_reference\"}";
+ int result = Whitebox.invokeMethod(spyDesign, "getSDCReferenceID", payload);
+ assertEquals(0, result);
+ }
+
+ @Test
+ public void testgetDataFromActionStatus() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"artifact-type\" :\"DESIGNTOOL-TEST\", \"artifact-name\":\"DesignRestArtifact_reference\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "getDataFromActionStatus", payload, "Data");
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testsetActionStatus() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"template\":\"TestTemplate\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "setActionStatus", payload, "Status");
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testcreateArtifactTrackingRecord() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"technology\":\"TestTech\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"template\":\"TestTemplate\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "createArtifactTrackingRecord", payload, "1234", 0, 0);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testgetSDCArtifactIDbyRequestID() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"artifact-type\" :\"DESIGNTOOL-TEST\", \"artifact-name\":\"DesignRestArtifact_reference\"}";
+ int result = Whitebox.invokeMethod(spyDesign, "getSDCArtifactIDbyRequestID", payload);
+ assertEquals(0, result);
+ }
+
+ @Test(expected = Exception.class)
+ public void testgetArtifact() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"artifact-type\" :\"DESIGNTOOL-TEST\", \"artifact-name\":\"DesignRestArtifact_reference\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "getArtifact", payload, "1234");
+ }
+
+ @Test
+ public void testgetStatus() throws Exception {
+ String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\",\"action\":\"TestAction\",\"action-level\":\"TestLevel\",\"protocol\":\"TestProtocol\",\"vnfc-type\":\"TestVnfc\",\"artifact-type\" :\"DESIGNTOOL-TEST\", \"artifact-name\":\"DesignRestArtifact_reference\"}";
+ String result = Whitebox.invokeMethod(spyDesign, "getStatus", payload, "1234");
+ assertEquals(true, result.contains("0000"));
+ }
+
+ @Test
+ public void testGetAppcTimestampUTC() throws Exception {
+ String requestId = "1234";
+ DesignDBService design = DesignDBService.initialise();
+ String result = Whitebox.invokeMethod(design, "getAppcTimestampUTC",requestId);
+ assertTrue(result.endsWith("Z"));
+ }
+} \ No newline at end of file
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestRequestValidator.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestRequestValidator.java
new file mode 100644
index 000000000..d5e54a576
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestRequestValidator.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 IBM
+ * =============================================================================
+ * 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.design.validator;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.appc.design.dbervices.RequestValidator;
+import org.powermock.reflect.Whitebox;
+
+public class TestRequestValidator {
+
+ @Test
+ public void TestExecuteGetDesigns() throws Exception {
+ String action = "getDesigns";
+ String payload = "{\"userID\":\"0000\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test(expected = Exception.class)
+ public void TestExecuteGetArtifactException() throws Exception {
+ String action = "getArtifact";
+ String payload = "{\"userID\":\"0000\",\"vnf-type\":\"TestVnfType\",\"artifact-name\":\"TestArtifactName\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test
+ public void TestExecuteGetArtifact() throws Exception {
+ String action = "getArtifact";
+ String payload = "{\"userID\":\"0000\",\"vnf-type\":\"TestVnfType\",\"artifact-name\":\"TestArtifactName\",\"artifact-type\":\"TestArtifactType\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test
+ public void TestExecuteGetStatus() throws Exception {
+ String action = "getStatus";
+ String payload = "{\"userID\":\"0000\",\"vnf-type\":\"TestVnfType\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test
+ public void TestExecuteSetStatus() throws Exception {
+ String action = "setStatus";
+ String payload = "{\"userID\":\"0000\",\"vnf-type\":\"TestVnfType\",\"artifact-type\":\"TestArtifactType\",\"action\":\"TestAction\",\"status\":\"TestStatus\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test
+ public void TestExecuteUploadArtifact() throws Exception {
+ String action = "uploadArtifact";
+ String payload = "{\"artifact-name\":\"TestArtifactName\",\"vnf-type\":\"TestVnfType\",\"artifact-type\":\"TestArtifactType\",\"action\":\"TestAction\",\"artifact-version\":\"TestVersion\",\"artifact-contents\":\"TestContents\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+
+ @Test
+ public void TestExecuteSetInCart() throws Exception {
+ String action = "setInCart";
+ String payload = "{\"vnf-type\":\"TestVnfType\",\"action\":\"TestAction\",\"action-level\":\"TestActionLevel\",\"protocol\":\"TestProtocol\"}";
+ // RequestValidator.validate(action, payload);
+ String s = Whitebox.invokeMethod(RequestValidator.class, "validate", action, payload);
+ assertEquals(null, s);
+ }
+}