5e7505434b0c01e088579b00feb17328de148802
[portal/sdk.git] /
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal SDK
4  * ===================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software 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  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalsdk.external.authorization.domain;
39
40 import static org.junit.Assert.assertEquals;
41
42 import java.util.ArrayList;
43 import java.util.List;
44
45 import org.junit.Test;
46
47 public class ExternalAccessUserRoleDetailTest {
48
49         public ExternalAccessUserRoleDetail mockExternalAccessUserRoleDetailTest() {
50                 List<ExternalAccessPerms> mockPerms = new ArrayList<>();
51                 ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
52                 mockExtPermsTest.setAction("*");
53                 mockExtPermsTest.setDescription("test_name");
54                 mockExtPermsTest.setType("test_type");
55                 mockExtPermsTest.setInstance("test_instance");
56                 mockPerms.add(mockExtPermsTest);
57                 ExternalRoleDescription mockRoleDesc = new ExternalRoleDescription();
58                 mockRoleDesc.setActive("true");
59                 mockRoleDesc.setAppId("1");
60                 mockRoleDesc.setAppRoleId("1");
61                 mockRoleDesc.setId("1");
62                 mockRoleDesc.setPriority("1");
63                 mockRoleDesc.setName("test");
64                 mockRoleDesc.setPermissions(mockPerms);
65                 ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail();
66                 mockExtUserRoleDetailTest.setName("test");
67                 mockExtUserRoleDetailTest.setDescription(mockRoleDesc);
68                 return mockExtUserRoleDetailTest;
69         }
70
71         @Test
72         public void externalAccessPermsTest() {
73                 List<ExternalAccessPerms> perms = new ArrayList<>();
74                 ExternalAccessPerms extPermsTest = new ExternalAccessPerms();
75                 extPermsTest.setAction("*");
76                 extPermsTest.setDescription("test_name");
77                 extPermsTest.setType("test_type");
78                 extPermsTest.setInstance("test_instance");
79                 perms.add(extPermsTest);
80                 ExternalRoleDescription roleDesc = new ExternalRoleDescription();
81                 roleDesc.setActive("true");
82                 roleDesc.setAppId("1");
83                 roleDesc.setAppRoleId("1");
84                 roleDesc.setId("1");
85                 roleDesc.setPriority("1");
86                 roleDesc.setName("test");
87                 roleDesc.setPermissions(perms);
88                 ExternalAccessUserRoleDetail extUserRoleDetailTest = new ExternalAccessUserRoleDetail();
89                 extUserRoleDetailTest.setName("test");
90                 extUserRoleDetailTest.setDescription(roleDesc);
91                 ExternalAccessUserRoleDetail extUserRoleDetailTest2 = new ExternalAccessUserRoleDetail("test", roleDesc);
92                 assertEquals(extUserRoleDetailTest.getName(), mockExternalAccessUserRoleDetailTest().getName());
93                 assertEquals(extUserRoleDetailTest.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
94                 assertEquals(extUserRoleDetailTest2.getName(), mockExternalAccessUserRoleDetailTest().getName());
95                 assertEquals(extUserRoleDetailTest2.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
96                 assertEquals(true, new ExternalAccessUserRoleDetail("test",roleDesc)
97                                 .equals(new ExternalAccessUserRoleDetail("test",roleDesc)));
98         }
99 }