summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGao Weitao <victor.gao@huawei.com>2018-09-24 12:25:55 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-24 12:25:55 +0000
commitfb03123c2cab61036b11de6d5e5714412f31e03f (patch)
tree73aeb799f81041755e991b975133c9d2680c77a3
parentfd27d0e60bf7e7d48c7c1b7a20d98a221cb31426 (diff)
parente45d082c80fbe95646a8c249aa03a66a3e77c938 (diff)
Merge "VTP: Improve the UT for run and list of tests"
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java66
1 files changed, 66 insertions, 0 deletions
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 4dfd5811..19fba962 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
@@ -62,6 +62,24 @@ public class VTPResourceTest {
}
@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 testVtpRunTests() throws Exception {
new MockUp<OpenRemoteCli>() {
@@ -109,4 +127,52 @@ public class VTPResourceTest {
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());
+ }
}