Change code in appc dispatcher for new LCMs in R6
[appc.git] / appc-inbound / appc-design-services / provider / src / test / java / org / onap / appc / design / validator / TestDesigndata.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.appc.design.validator;
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import org.junit.Assert;
28 import org.junit.Test;
29 import org.onap.appc.design.data.ArtifactInfo;
30 import org.onap.appc.design.data.DesignInfo;
31 import org.onap.appc.design.data.DesignRequest;
32 import org.onap.appc.design.data.DesignResponse;
33 import org.onap.appc.design.data.StatusInfo;
34 import org.onap.appc.design.data.UserPermissionInfo;
35
36 public class TestDesigndata {
37
38     DesignResponse dr = new DesignResponse();
39
40     @Test
41     public void testSetUserID() {
42         String userId = "0000";
43         dr.setUserId(userId);
44         Assert.assertEquals("Unexpected getUserId value", userId, dr.getUserId());
45     }
46
47     @Test
48     public void testSetDesignInfoList() {
49         DesignInfo di = new DesignInfo();
50         List<DesignInfo> li = new ArrayList<DesignInfo>();
51         String action = "TestAction";
52         di.setAction(action);
53         Assert.assertEquals("Unexpected getAction value", action, di.getAction());
54         String artifact_name = "TestName";
55         di.setArtifact_name(artifact_name);
56         Assert.assertEquals("Unexpected getArtifact_name value", artifact_name, di.getArtifact_name());
57         String artifact_type = "TestType";
58         di.setArtifact_type(artifact_type);
59         Assert.assertEquals("Unexpected getArtifact_type value", artifact_type, di.getArtifact_type());
60         String inCart = "TestCart";
61         di.setInCart(inCart);
62         Assert.assertEquals("Unexpected getInCart value", inCart, di.getInCart());
63         String protocol = "TestProtocol";
64         di.setProtocol(protocol);
65         Assert.assertEquals("Unexpected getProtocol value", protocol, di.getProtocol());
66         String vnf_type = "TestVNF";
67         di.setVnf_type(vnf_type);
68         Assert.assertEquals("Unexpected getVnf_type value", vnf_type, di.getVnf_type());
69         String vnfc_type = "TestVNFC";
70         di.setVnfc_type(vnfc_type);
71         Assert.assertEquals("Unexpected getVnfc_type value", vnfc_type, di.getVnfc_type());
72         li.add(di);
73         dr.setDesignInfoList(li);
74         Assert.assertEquals("Unexpected getDesignInfoList value", li, dr.getDesignInfoList());
75     }
76
77     @Test
78     public void testSetArtifactInfo() {
79         ArtifactInfo ai = new ArtifactInfo();
80         List<ArtifactInfo> li = new ArrayList<ArtifactInfo>();
81         String artifact_content = "TestContent";
82         ai.setArtifact_content(artifact_content);
83         Assert.assertEquals("Unexpected getArtifact_content value", artifact_content, ai.getArtifact_content());
84         li.add(ai);
85         dr.setArtifactInfo(li);
86         Assert.assertEquals("Unexpected getArtifactInfo value", li, dr.getArtifactInfo());
87     }
88
89     @Test
90     public void testStatusInfo() {
91         StatusInfo si = new StatusInfo();
92         List<StatusInfo> li = new ArrayList<StatusInfo>();
93         String action = "TestAction";
94         si.setAction(action);
95         Assert.assertEquals("Unexpected getAction value", action, si.getAction());
96         String action_status = "TestActionStatus";
97         si.setAction_status(action_status);
98         Assert.assertEquals("Unexpected getAction_status value", action_status, si.getAction_status());
99         String artifact_status = "TestArtifactStatus";
100         si.setArtifact_status(artifact_status);
101         Assert.assertEquals("Unexpected getArtifact_status value", artifact_status, si.getArtifact_status());
102         String vnf_type = "TestVNF";
103         si.setVnf_type(vnf_type);
104         Assert.assertEquals("Unexpected getVnf_type value", vnf_type, si.getVnf_type());
105         String vnfc_type = "TestVNFC";
106         si.setVnfc_type(vnfc_type);
107         Assert.assertEquals("Unexpected getVnfc_type value", vnfc_type, si.getVnfc_type());
108         li.add(si);
109         dr.setStatusInfoList(li);
110         Assert.assertEquals("Unexpected getStatusInfoList value", li, dr.getStatusInfoList());
111     }
112
113     @Test
114     public void testDesignRequest() {
115         DesignRequest dreq = new DesignRequest();
116         String action = "TestAction";
117         dreq.setAction(action);
118         Assert.assertEquals("Unexpected getAction value", action, dreq.getAction());
119         String artifact_contents = "TestContent";
120         dreq.setArtifact_contents(artifact_contents);
121         Assert.assertEquals("Unexpected getArtifact_contents value", artifact_contents, dreq.getArtifact_contents());
122         String artifact_name = "TestName";
123         dreq.setArtifact_name(artifact_name);
124         Assert.assertEquals("Unexpected getArtifact_name value", artifact_name, dreq.getArtifact_name());
125         String protocol = "TestProtocol";
126         dreq.setProtocol(protocol);
127         Assert.assertEquals("Unexpected getProtocol value", protocol, dreq.getProtocol());
128         String userId = "0000";
129         dreq.setUserId(userId);
130         Assert.assertEquals("Unexpected getUserId value", userId, dreq.getUserId());
131         String vnf_type = "testvnf";
132         dreq.setVnf_type(vnf_type);
133         Assert.assertEquals("Unexpected getVnf_type value", vnf_type, dreq.getVnf_type());
134         String vnfc_type = "testvnfc";
135         dreq.setVnfc_type(vnfc_type);
136         Assert.assertEquals("Unexpected getVnfc_type value", vnfc_type, dreq.getVnfc_type());
137         String expecting =
138                 "DesignRequest [userId=" + userId + ", vnf_type=" + vnf_type + ", vnfc_type=" + vnfc_type + ", protocol="
139                 + protocol + ", action=" + action + ", artifact_name=" + artifact_name + ", artifact_contents="
140                 + artifact_contents + "]";
141         Assert.assertEquals("Unexpected toString value", expecting, dreq.toString());
142     }
143
144     @Test
145     public void testUserPermissionInfo() {
146         UserPermissionInfo upi = new UserPermissionInfo();
147         List<UserPermissionInfo> li = new ArrayList<UserPermissionInfo>();
148         String userId = "uu1234";
149         upi.setUserID(userId);
150         Assert.assertEquals("Unexpected getUserId value", userId, upi.getUserID());
151         String permission = "owner";
152         upi.setPermission(permission);
153         Assert.assertEquals("Unexpected getPermission value", permission, upi.getPermission());
154         li.add(upi);
155         dr.setUsers(li);
156         Assert.assertEquals("Unexpected getUsers value", li, dr.getUsers());
157     }
158
159 }