aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPResourceTest.java39
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java58
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPExceptionMapperTest.java41
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java116
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java58
5 files changed, 312 insertions, 0 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPResourceTest.java
new file mode 100644
index 00000000..7d8fa6df
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/VTPResourceTest.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.vtp;
+
+import org.junit.Test;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.*;
+
+public class VTPResourceTest {
+ @Test(expected = Exception.class)
+ public void testGetStorePath() throws Exception
+ {
+ VTPResource vtpResource= new VTPResource();
+ String requestId = UUID.randomUUID().toString();
+ List<String> args= new ArrayList<>();
+ args.add("open-cli");
+ args.add("abc");
+ args.add("abc");
+ args.add(requestId);
+ vtpResource.makeRpc(args);
+ }
+
+} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java
new file mode 100644
index 00000000..6a06a62f
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPErrorTest.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.onap.vtp.error;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class VTPErrorTest
+{
+ VTPError vtpError;
+ @Before
+ public void setUp()
+ {
+ vtpError =new VTPError();
+ }
+ @Test
+ public void testCode()
+ {
+ vtpError.setCode("0xc002");
+ assertEquals(vtpError.getCode(),"0xc002");
+ }
+ @Test
+ public void testmessage()
+ {
+ vtpError.setMessage("0xc002 ::error found");
+ assertEquals(vtpError.getMessage(),"error found");
+ }
+ @Test
+ public void testHttpStatus()
+ {
+ vtpError.setHttpStatus(200);
+ assertEquals(vtpError.getHttpStatus(),200);
+ }
+ @Test
+ public void testInnerClassMethods()
+ {
+ VTPError.VTPException vtpException=new VTPError.VTPException(vtpError);
+ assertNotNull(vtpException.getMessage());
+ assertNotNull(vtpException.getVTPError());
+ }
+
+} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPExceptionMapperTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPExceptionMapperTest.java
new file mode 100644
index 00000000..4447bb8f
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/error/VTPExceptionMapperTest.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.vtp.error;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class VTPExceptionMapperTest {
+
+ VTPExceptionMapper vtpExceptionMapper;
+
+ @Before
+ public void setUp() throws Exception {
+ vtpExceptionMapper = new VTPExceptionMapper();
+ }
+
+ @Test
+ public void testToResponse() {
+ VTPError error = new VTPError();
+ error.setHttpStatus(200);
+ error.setMessage("0xc002:: error found");
+ error.setCode("0xc002");
+ assertNotNull(vtpExceptionMapper.toResponse(new Exception()));
+ assertNotNull(vtpExceptionMapper.toResponse(new VTPError.VTPException(error)));
+ }
+} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java
new file mode 100644
index 00000000..c4a3ef4c
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/execution/VTPExecutionResourceTest.java
@@ -0,0 +1,116 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.vtp.execution;
+
+import com.fasterxml.jackson.core.*;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import com.fasterxml.jackson.databind.node.JsonNodeType;
+import org.glassfish.jersey.media.multipart.ContentDisposition;
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.vtp.execution.model.VTPTestExecution;
+
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.*;
+@RunWith(MockitoJUnitRunner.class)
+public class VTPExecutionResourceTest {
+
+ @Mock
+ FormDataBodyPart formDataBodyPart;
+ @Mock
+ ContentDisposition contentDisposition;
+ String requestId;
+ VTPExecutionResource vtpExecutionResource;
+ @Before
+ public void setUp() throws Exception {
+ vtpExecutionResource= new VTPExecutionResource();
+ requestId = UUID.randomUUID().toString();
+ }
+ @Test(expected = Exception.class)
+ public void testExecuteHandler() throws Exception
+ {
+ VTPTestExecution.VTPTestExecutionList executions= new VTPTestExecution.VTPTestExecutionList();
+ List<VTPTestExecution> list= new ArrayList<>();
+ ObjectMapper mapper = new ObjectMapper();
+ String jsonString = "{\"name\":\"Mahesh Kumar\", \"age\":\"nine\",\"verified\":\"false\"}";
+ JsonNode rootNode = mapper.readTree(jsonString);
+
+ VTPTestExecution vtp=new VTPTestExecution();
+ vtp.setEndTime("2019-03-12T11:49:52.845");
+ vtp.setProfile("abc");
+ vtp.setStatus("pass");
+ vtp.setRequestId(requestId);
+ vtp.setExecutionId("executionid");
+ vtp.setParameters(rootNode);
+ vtp.setResults(rootNode);
+ vtp.setScenario("open-cli");
+ vtp.setStartTime("2019-04-12T11:49:52.845");
+ vtp.setTestCaseName("testcase");
+ vtp.setTestSuiteName("testsuite");
+ list.add(vtp);
+ executions.setExecutions(list);
+ //System.out.println(executions.getExecutions());
+ assertNotNull(executions.getExecutions());
+ vtpExecutionResource.executeHandler(executions,null);
+ // vtpExecutionResource.executeHandler(executions,requestId);
+
+ }
+ @Test(expected = Exception.class)
+ public void testListTestExecutionsHandler() throws Exception
+ {
+ vtpExecutionResource.listTestExecutionsHandler(requestId,"abc","abc","abc","abc","123","123");
+ }
+
+ @Test(expected = Exception.class)
+ public void testListTestExecutions() throws Exception
+ {
+ vtpExecutionResource.listTestExecutions(requestId,"abc","abc","abc","abc","123","123");
+ }
+ @Test(expected = Exception.class)
+ public void testGetTestExecution() throws Exception
+ {
+ //assertNotNull(vtpExecutionResource.getTestExecution("abc"));
+ assertNotNull(vtpExecutionResource.getTestExecution("1234"));
+ }
+ @Test(expected = Exception.class)
+ public void testGetTestExecutionHandler() throws Exception
+ {
+ //assertNotNull(vtpExecutionResource.getTestExecution("abc"));
+ assertNotNull(vtpExecutionResource.getTestExecutionHandler("1234"));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testExecuteTestcases() throws Exception
+ {
+
+ List<FormDataBodyPart> bodyParts= new ArrayList<>();
+ formDataBodyPart.setName("abc");
+ formDataBodyPart.setValue("123");
+ formDataBodyPart.setContentDisposition(contentDisposition);
+ formDataBodyPart.getContentDisposition().getFileName();
+ bodyParts.add(formDataBodyPart);
+ vtpExecutionResource.executeTestcases(requestId,bodyParts,"exeJson") ;
+ }
+} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java
new file mode 100644
index 00000000..dec7b68f
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.vtp.scenario;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class VTPScenarioResourceTest {
+
+ VTPScenarioResource vtpScenarioResource;
+ @Before
+ public void setUp() throws Exception {
+ vtpScenarioResource=new VTPScenarioResource();
+ }
+ @Test(expected = Exception.class)
+ public void testListTestScenariosHandler() throws Exception{
+ vtpScenarioResource.listTestScenariosHandler();
+ }
+ @Test(expected = Exception.class)
+ public void testListTestSutiesHandler() throws Exception{
+ vtpScenarioResource.listTestSutiesHandler("open-cli");
+ }
+ @Test(expected = Exception.class)
+ public void testListTestcasesHandler() throws Exception
+ {
+ vtpScenarioResource.listTestcasesHandler("testsuite","open-cli");
+ }
+ @Test(expected = Exception.class)
+ public void testListTestcases() throws Exception
+ {
+ vtpScenarioResource.listTestcases("open-cli","testsuite");
+ }
+ @Test(expected = Exception.class)
+ public void testGetTestcase() throws Exception
+ {
+ vtpScenarioResource.getTestcase("open-cli","testsuit","testcase");
+ }
+ @Test(expected = Exception.class)
+ public void testGetTestcaseHandler() throws Exception
+ {
+ vtpScenarioResource.getTestcaseHandler("open-cli","testsuit","testcase");
+ }
+} \ No newline at end of file