2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
7 * Modifications Copyright © 2018 IBM.
8 * ================================================================================
10 * Unless otherwise specified, all software contained herein is licensed
11 * under the Apache License, Version 2.0 (the "License");
12 * you may not use this software except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * Unless otherwise specified, all documentation contained herein is licensed
24 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 * you may not use this documentation except in compliance with the License.
26 * You may obtain a copy of the License at
28 * https://creativecommons.org/licenses/by/4.0/
30 * Unless required by applicable law or agreed to in writing, documentation
31 * distributed under the License is distributed on an "AS IS" BASIS,
32 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
36 * ============LICENSE_END============================================
40 package org.onap.portalapp.portal.domain;
42 import static org.junit.Assert.*;
44 import org.junit.Test;
45 import org.onap.portalapp.portal.domain.EPApp;
46 import org.onap.portalapp.portal.domain.EPRole;
47 import org.onap.portalapp.portal.domain.EPUserApp;
49 public class EPUserAppTest {
51 public EPUserApp mockEPUserApp(){
53 EPApp epApp = new EPApp();
54 epApp.setName("test");
55 epApp.setImageUrl("test");
56 epApp.setDescription("test");
57 epApp.setNotes("test");
59 epApp.setAlternateUrl("test");
60 epApp.setAppRestEndpoint("test");
61 epApp.setMlAppName("test");
62 epApp.setMlAppAdminId("test");
63 epApp.setMotsId((long)1);
64 epApp.setUsername("test");
65 epApp.setAppPassword("test");
69 EPRole epRole = new EPRole();
70 epRole.setName("test");
71 epRole.setActive(false);
72 epRole.setPriority(1);
73 epRole.setAppId((long)1);
74 epRole.setAppRoleId((long)1);
76 EPUserApp user = new EPUserApp();
77 user.setUserId((long)1);
80 user.setPriority((Integer)32767);
87 public void userTest(){
88 EPUserApp user = mockEPUserApp();
90 EPApp epApp = new EPApp();
91 epApp.setName("test");
92 epApp.setImageUrl("test");
93 epApp.setDescription("test");
94 epApp.setNotes("test");
96 epApp.setAlternateUrl("test");
97 epApp.setAppRestEndpoint("test");
98 epApp.setMlAppName("test");
99 epApp.setMlAppAdminId("test");
100 epApp.setMotsId((long)1);
101 epApp.setUsername("test");
102 epApp.setAppPassword("test");
106 EPRole epRole = new EPRole();
107 epRole.setName("test");
108 epRole.setActive(false);
109 epRole.setPriority(1);
110 epRole.setAppId((long)1);
111 epRole.setAppRoleId((long)1);
114 assertEquals(user.getUserId(),Long.valueOf(1));
115 assertEquals(user.getApp(), epApp);
116 assertEquals(user.getPriority().getClass(), Integer.class);
118 assertEquals(user.toString(), "[u: 1; a: null, r: null; appRoleId: 1]");
120 assertEquals(user.hashCode(), user.hashCode());
126 public void testEquals(){
127 EPRole epRole = new EPRole();
128 epRole.setId((long) 12345);
129 epRole.setName("test");
130 epRole.setActive(false);
131 epRole.setPriority(1);
132 epRole.setAppId((long)1);
133 epRole.setAppRoleId((long)1);
135 EPUserApp user1 = mockEPUserApp();
136 user1.setApp(mockEPApp());
137 user1.setRole(epRole);
139 EPUserApp user2 = mockEPUserApp();
140 user2.setApp(mockEPApp());
141 user2.setRole(epRole);
143 EPUserApp nullUser = null;
145 assertTrue(user1.equals(user1));
146 assertFalse(user1.equals(nullUser));
147 assertFalse(user1.equals(Long.valueOf(1)));
148 assertTrue(user1.equals(user2));
150 private EPApp mockEPApp() {
151 EPApp epApp = new EPApp();
152 epApp.setId((long) 12345);
153 epApp.setName("test");
154 epApp.setImageUrl("test");
155 epApp.setDescription("test");
156 epApp.setNotes("test");
157 epApp.setUrl("test");
158 epApp.setAlternateUrl("test");
159 epApp.setAppRestEndpoint("test");
160 epApp.setMlAppName("test");
161 epApp.setMlAppAdminId("test");
162 epApp.setMotsId((long)1);
163 epApp.setUsername("test");
164 epApp.setAppPassword("test");