aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-20 10:09:01 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-20 11:04:46 +0530
commit7c8dcee452164e07feff118325c244e2a10b6213 (patch)
tree647f944bb4a4dc5814b5aec81b3a523a32f0f48b /vnfmarket-be/vnf-sdk-marketplace
parent133c98d03806116906835ea12474806d73df6eca (diff)
VTP: Improve the UT
Issue-ID: VNFSDK-305 Change-Id: Iff281647c1a974b8911bae8bcf84764599b631b2 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java74
1 files changed, 74 insertions, 0 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 6ec0406a..0728e3ac 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,12 +21,15 @@ 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;
@@ -34,6 +37,9 @@ 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;
@@ -781,6 +787,74 @@ 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>() {