Reduce number of parameters in constructor
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / transport / RemoteRoleV1Test.java
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright © 2017-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.portalapp.portal.transport;
39
40 //@RunWith(PowerMockRunner.class)
41 import static org.junit.Assert.assertEquals;
42 import static org.junit.Assert.assertFalse;
43 import static org.junit.Assert.assertNotNull;
44 import static org.junit.Assert.assertTrue;
45
46 import org.junit.Before;
47 import org.junit.Test;
48
49 public class RemoteRoleV1Test {
50         RemoteRoleV1 remoteRoleV1;
51         private String NAME = "test";
52     private Long ID = 12L;
53     
54         @Before
55         public void setUp() {
56                 remoteRoleV1 = new RemoteRoleV1();
57                 remoteRoleV1.setName(NAME);
58                 remoteRoleV1.setId(ID);
59         }
60         
61         
62         @Test
63         public void testNotNull() {
64                 assertNotNull(remoteRoleV1);
65         }
66         
67         @Test
68         public void testRemoteRoleV1Properties() {
69                 assertEquals(ID, remoteRoleV1.getId());
70                 assertEquals(NAME, remoteRoleV1.getName());
71         }
72         
73         @Test
74         public void testRemoteRole() {
75                 RemoteRoleV1 remoteRoleV1=buildRemoteRoleV1();
76                 RemoteRoleV1 remoteRole=new RemoteRoleV1();
77                 RemoteRoleV1 remoteRoleV2=remoteRoleV1;
78                 remoteRole.setId(ID);
79                 remoteRole.setName(NAME);
80                 
81                 assertEquals(remoteRole.hashCode(), remoteRoleV1.hashCode());   
82                 remoteRole.compareTo(remoteRoleV1);
83                 assertTrue(remoteRole.equals(remoteRoleV1));
84                 assertFalse(remoteRole.equals(null));
85                 remoteRole.setName(null);
86                 assertFalse(remoteRole.equals(remoteRoleV1));
87                 remoteRole.setId(null);
88                 assertFalse(remoteRole.equals(remoteRoleV1));
89                 assertTrue(remoteRoleV2.equals(remoteRoleV1));
90                 
91         }
92         
93         private RemoteRoleV1 buildRemoteRoleV1() {
94                 
95                 RemoteRoleV1 remoteRole=new RemoteRoleV1();
96                 remoteRole.setId(ID);
97                 remoteRole.setName(NAME);
98                 return remoteRole;
99         }
100         
101         
102         
103         @Test
104         public void remoteRoleV1Test(){
105                 
106                 RemoteRoleV1 remoteRoleV11 = new RemoteRoleV1();
107                 RemoteRoleV1 remoteRoleV12 = new RemoteRoleV1();
108                 RemoteRoleV1 remoteRoleV13 = new RemoteRoleV1();
109                 remoteRoleV13.setId(12L);
110                 remoteRoleV13.setName("test");
111                 
112                 assertEquals(new Long(12), remoteRoleV1.getId());
113                 assertEquals(remoteRoleV1.getName(), "test");
114                 assertEquals(remoteRoleV1.hashCode(), remoteRoleV13.hashCode());
115                 
116                 assertTrue(remoteRoleV11.equals(new RemoteRoleV1()));
117                 assertTrue(remoteRoleV12.equals(new RemoteRoleV1()));
118         }
119         
120         @Test
121         public void testcompareTo() {
122                 assertEquals(0, remoteRoleV1.compareTo(remoteRoleV1));
123         }
124         
125 }