summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src/test
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-21 10:42:45 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-21 11:18:46 +0530
commitd51c6871dc5cad267fa4acf8e0e9a70717a6c106 (patch)
treee8264bf7aeb749b8fa503790e2978da7d5074bc1 /vnfmarket-be/vnf-sdk-marketplace/src/test
parent7c8dcee452164e07feff118325c244e2a10b6213 (diff)
VTP: Make VTP separate REST controller
Issue-ID: VNFSDK-304 Change-Id: I7fbe7d4dbb7a97b594fd893734408ecca0c1765c Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java74
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java112
2 files changed, 112 insertions, 74 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 0728e3ac..6ec0406a 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
@@ -21,15 +21,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
@@ -37,9 +34,6 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import javax.servlet.ReadListener;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
@@ -787,74 +781,6 @@ public class PackageResourceTest {
}
@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 = packageResource.listTests();
- assertEquals(200, 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 = packageResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(200, result.getStatus());
- }
-
- @Test
public void testGetOnBoardingStepsSuccess() {
new MockUp<org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil>() {
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
new file mode 100644
index 00000000..4dfd5811
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java
@@ -0,0 +1,112 @@
+/**
+ * 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 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());
+ }
+}