List of Input Parameters for VSP
[sdc.git] / openecomp-be / lib / openecomp-sdc-externaltesting-lib / openecomp-sdc-externaltesting-api / src / test / java / org / openecomp / core / externaltesting / api / ExecutionRequestTests.java
1 /*
2  * Copyright © 2019 iconectiv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.core.externaltesting.api;
18
19 import com.fasterxml.jackson.databind.ObjectMapper;
20 import org.junit.Assert;
21 import org.junit.Test;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.util.Map;
26 import java.util.UUID;
27
28 public class ExecutionRequestTests {
29
30   @Test
31   public void testTestCase() throws Exception {
32     ObjectMapper mapper = new ObjectMapper();
33     VtpTestCase req = mapper.readValue(new File("src/test/data/testcase.json"), VtpTestCase.class);
34
35     Assert.assertEquals("Scenario must match", "compliance", req.getScenario());
36     Assert.assertEquals("Suite name must match", "compliancetests", req.getTestSuiteName());
37     Assert.assertEquals("Test case name must match", "sriov", req.getTestCaseName());
38     Assert.assertEquals("Description must match", "SR-IOV Test", req.getDescription());
39     Assert.assertEquals("Author must match", "Jim", req.getAuthor());
40     Assert.assertEquals("Endpoint must match", "vtp", req.getEndpoint());
41     Assert.assertEquals("Test must contain two inputs", 3, req.getInputs().size());
42     Assert.assertEquals("Test must contain one outputs", 1, req.getOutputs().size());
43
44     VtpTestCaseInput input1 = req.getInputs().get(0);
45     Assert.assertEquals("Name match", "vspId", input1.getName());
46     Assert.assertEquals("Description match", "VSP ID", input1.getDescription());
47     Assert.assertEquals("Input type match", "text", input1.getType());
48     Assert.assertEquals("Input default match", "", input1.getDefaultValue());
49     Assert.assertFalse("Input optional match", input1.getIsOptional());
50
51     VtpTestCaseOutput output1 = req.getOutputs().get(0);
52     Assert.assertEquals("Name match", "something", output1.getName());
53     Assert.assertEquals("Description match", "is produced", output1.getDescription());
54     Assert.assertEquals("Output type match", "integer", output1.getType());
55
56
57     Map<String,Object> meta = input1.getMetadata();
58     Assert.assertEquals("Metadata count", 3, meta.size());
59
60     VtpTestCase req2 = mapper.readValue(new File("src/test/data/testcase.json"), VtpTestCase.class);
61
62     Assert.assertEquals("test equality", req, req2);
63
64   }
65
66   @Test
67   public void testExecutionRequest() throws IOException {
68     ObjectMapper mapper = new ObjectMapper();
69     VtpTestExecutionRequest req = mapper.readValue(new File("src/test/data/executionrequest.json"), VtpTestExecutionRequest.class);
70     Assert.assertEquals("compliance", req.getScenario());
71     Assert.assertEquals("compliance", req.getProfile());
72     Assert.assertEquals("sriov", req.getTestCaseName());
73     Assert.assertEquals("compliancetests", req.getTestSuiteName());
74     Assert.assertEquals("repository", req.getEndpoint());
75
76     Assert.assertEquals(3, req.getParameters().size());
77   }
78
79   @Test
80   public void testExecutionResponse() throws IOException {
81     ObjectMapper mapper = new ObjectMapper();
82     VtpTestExecutionResponse rsp = mapper.readValue(new File("src/test/data/priorexecution.json"), VtpTestExecutionResponse.class);
83     Assert.assertEquals("compliance", rsp.getScenario());
84     Assert.assertEquals("computeflavors", rsp.getTestCaseName());
85     Assert.assertEquals("compliancetests", rsp.getTestSuiteName());
86     Assert.assertTrue(UUID.fromString(rsp.getExecutionId()).getLeastSignificantBits() != 0);
87     Assert.assertEquals("parameters", 6, rsp.getParameters().size());
88     Assert.assertNotNull(rsp.getResults());
89     Assert.assertEquals("COMPLETED", rsp.getStatus());
90     Assert.assertNotNull(rsp.getStartTime());
91     Assert.assertNotNull(rsp.getEndTime());
92   }
93
94   @Test
95   public void testTree() throws IOException {
96     ObjectMapper mapper = new ObjectMapper();
97     TestTreeNode tree = mapper.readValue(new File("src/test/data/testtree.json"), TestTreeNode.class);
98
99     Assert.assertEquals(2, tree.getChildren().size());
100     Assert.assertEquals(0, tree.getTests().size());
101
102     TestTreeNode manual = new TestTreeNode("root", "Root");
103
104     manual.addChild(new TestTreeNode("child", "child"));
105     manual.addTest(new VtpTestCase());
106     Assert.assertEquals(1, manual.getChildren().size());
107     Assert.assertEquals(1, manual.getTests().size());
108
109   }
110 }