2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.appc.design.validator;
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;
36 public class TestDesigndata {
38 DesignResponse dr = new DesignResponse();
41 public void testSetUserID() {
42 String userId = "0000";
44 Assert.assertEquals("Unexpected getUserId value", userId, dr.getUserId());
48 public void testSetDesignInfoList() {
49 DesignInfo di = new DesignInfo();
50 List<DesignInfo> li = new ArrayList<DesignInfo>();
51 String action = "TestAction";
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";
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());
73 dr.setDesignInfoList(li);
74 Assert.assertEquals("Unexpected getDesignInfoList value", li, dr.getDesignInfoList());
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());
85 dr.setArtifactInfo(li);
86 Assert.assertEquals("Unexpected getArtifactInfo value", li, dr.getArtifactInfo());
90 public void testStatusInfo() {
91 StatusInfo si = new StatusInfo();
92 List<StatusInfo> li = new ArrayList<StatusInfo>();
93 String action = "TestAction";
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());
109 dr.setStatusInfoList(li);
110 Assert.assertEquals("Unexpected getStatusInfoList value", li, dr.getStatusInfoList());
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());
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());
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());
156 Assert.assertEquals("Unexpected getUsers value", li, dr.getUsers());