VTP: Validate Throw exception while VTP-TC failed 03/68603/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 24 Sep 2018 05:16:14 +0000 (10:46 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 24 Sep 2018 05:16:14 +0000 (10:46 +0530)
Issue-ID: VNFSDK-304

Change-Id: I8c9a67687ddaa62149035b3b55fba1f846b923c1
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java

index 19fba96..2d2bed0 100644 (file)
@@ -79,6 +79,20 @@ public class VTPResourceTest {
         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>() {
@@ -175,4 +189,48 @@ public class VTPResourceTest {
         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());
+    }
 }