From ec5e47d58ebbc95d56ea98d84ca2fc2290b4b398 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 24 Sep 2018 10:46:14 +0530 Subject: VTP: Validate Throw exception while VTP-TC failed Issue-ID: VNFSDK-304 Change-Id: I8c9a67687ddaa62149035b3b55fba1f846b923c1 Signed-off-by: Kanagaraj Manickam k00365106 --- .../marketplace/resource/VTPResourceTest.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test/java') 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 index 19fba962..2d2bed08 100644 --- 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 @@ -79,6 +79,20 @@ public class VTPResourceTest { assertEquals(500, result.getStatus()); } + @Test + public void testVtpGetTestsFailure2() throws Exception { + new MockUp() { + + @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() { @@ -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() { + + @Mock + public Result run(String[] args) throws Exception { + throw new Exception(); + } + }; + + MockUp mockReq = new MockUp() { + + @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()); + } } -- cgit 1.2.3-korg