eff4d249956df1d2abe19e1d755c1a9312b9e889
[sdc.git] /
1 /*
2  * Copyright © 2016-2017 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.notification.dao.types;
18
19 import static org.testng.Assert.assertEquals;
20 import static org.testng.Assert.assertNotEquals;
21
22 import java.util.UUID;
23
24 import org.testng.annotations.Test;
25
26 /**
27  * @author EVITALIY
28  * @since 31 Dec 17
29  */
30 public class NotificationEntityTest {
31
32     @Test
33     public void testUninitializedEquals() {
34         assertEquals(new NotificationEntity(), new NotificationEntity());
35     }
36
37     @Test
38     public void testEquals() {
39         UUID random = UUID.randomUUID();
40         assertEquals(createNotificationEntity(random), createNotificationEntity(random));
41     }
42
43     @Test
44     public void testOwnerNotEquals() {
45         UUID random = UUID.randomUUID();
46         NotificationEntity mutant = createNotificationEntity(random);
47         mutant.setOwnerId(UUID.randomUUID().toString());
48         assertNotEquals(mutant, createNotificationEntity(random));
49     }
50
51     @Test
52     public void testEventIdNotEquals() {
53         UUID random = UUID.randomUUID();
54         NotificationEntity mutant = createNotificationEntity(random);
55         mutant.setEventId(UUID.randomUUID());
56         assertNotEquals(mutant, createNotificationEntity(random));
57     }
58
59     @Test
60     public void testEventTypeNotEquals() {
61         UUID random = UUID.randomUUID();
62         NotificationEntity mutant = createNotificationEntity(random);
63         mutant.setEventType(UUID.randomUUID().toString());
64         assertNotEquals(mutant, createNotificationEntity(random));
65     }
66
67     @Test
68     public void testOriginatorNotEquals() {
69         UUID random = UUID.randomUUID();
70         NotificationEntity mutant = createNotificationEntity(random);
71         mutant.setOriginatorId(UUID.randomUUID().toString());
72         assertNotEquals(mutant, createNotificationEntity(random));
73     }
74
75     @Test
76     public void testReadNotEquals() {
77         UUID random = UUID.randomUUID();
78         NotificationEntity mutant = createNotificationEntity(random);
79         mutant.setRead(false);
80         assertNotEquals(mutant, createNotificationEntity(random));
81     }
82
83     @Test
84     public void testAttributesNotEquals() {
85         UUID random = UUID.randomUUID();
86         NotificationEntity mutant = createNotificationEntity(random);
87         mutant.setEventAttributes(UUID.randomUUID().toString());
88         assertNotEquals(mutant, createNotificationEntity(random));
89     }
90
91     @Test
92     public void testHashCode() {
93         UUID random = UUID.randomUUID();
94         assertEquals(createNotificationEntity(random).hashCode(), createNotificationEntity(random).hashCode());
95     }
96
97     private NotificationEntity createNotificationEntity(UUID random) {
98         return new NotificationEntity("owner-" + random, true, random, "type-" + random, "attributes-" + random,
99                 "originator-" + random);
100     }
101 }