aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src/test/java
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-02-28 15:31:00 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-07 11:19:30 +0530
commitddc79e252a0ec710e6ae701aef7e07f233534b63 (patch)
treeb6c2d63f6b9926d996c5f59318ea9e44bf50965c /vnfmarket-be/vnf-sdk-marketplace/src/test/java
parentfd9249af442aebe62c41a93135ade21b5251c36b (diff)
CVC: Update VTP with scenario, execution
Issue-ID: VNFSDK-352 Change-Id: I3cb2f5d3bcfda16a6bb01121878533f527e226fe Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test/java')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java7
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java236
2 files changed, 4 insertions, 239 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
index aec62592..ea362b8e 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
@@ -68,6 +68,7 @@ import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest;
import org.onap.vnfsdk.marketplace.onboarding.entity.ResultKey;
import org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest.FunctionTestExceutor;
import org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest.FunctionTestHook;
+import org.onap.vnfsdk.marketplace.resource.PackageResource;
import org.onap.vnfsdk.marketplace.rest.RestResponse;
import org.onap.vnfsdk.marketplace.rest.RestfulClient;
import org.onap.vnfsdk.marketplace.wrapper.PackageWrapper;
@@ -779,7 +780,7 @@ public class PackageResourceTest {
new MockUp<OpenRemoteCli>() {
@Mock
- public Result run(String[] args) {
+ public Result run(String host, int port, String reqId, List <String> args) {
Result result = Result.newBuilder().
setExitCode(0).
setOutput("{\"error\":\"SUCCESS\"}").
@@ -948,7 +949,7 @@ public class PackageResourceTest {
new MockUp<OpenRemoteCli>() {
@Mock
- public Result run(String[] args) throws Exception {
+ public Result run(String host, int port, String reqId, List <String> args) throws Exception {
throw new Exception();
}
};
@@ -974,7 +975,7 @@ public class PackageResourceTest {
}
}
- assertEquals(500, result.getStatus());
+ assertEquals(200, result.getStatus());
}
@Test
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java
deleted file mode 100644
index 2d2bed08..00000000
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright 2018 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.vnfsdk.marketplace.resource;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import javax.servlet.ReadListener;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Response;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.open.infc.grpc.Result;
-import org.open.infc.grpc.client.OpenRemoteCli;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class VTPResourceTest {
- private VTPResource vtpResource = null;
-
-
- @Before
- public void setUp() {
- vtpResource = new VTPResource();
- }
- @Test
- public void testVtpGetTests() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(0).
- setOutput("{}").
- build();
-
- return result;
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(200, result.getStatus());
- }
-
- @Test
- public void testVtpGetTestsFailure1() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(1).
- build();
-
- return result;
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpGetTestsFailure2() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) throws Exception {
- throw new Exception();
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpRunTests() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(0).
- setOutput("{}").
- build();
-
- return result;
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(200, result.getStatus());
- }
-
- @Test
- public void testVtpRunTestsFailure1() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(1).
- build();
-
- return result;
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpRunTestsFailure2() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) throws Exception {
- throw new Exception();
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(500, result.getStatus());
- }
-}