fc5792b4d45e267c59f4f084f2363d3b044d4da6
[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 org.testng.annotations.Test;
20
21 import java.util.UUID;
22
23 import static org.testng.Assert.*;
24
25 /**
26  * @author EVITALIY
27  * @since 31 Dec 17
28  */
29 public class NotificationEntityTest {
30
31     @Test
32     public void testUninitializedEquals() {
33         assertEquals(new NotificationEntity(), new NotificationEntity());
34     }
35
36     @Test
37     public void testEquals() {
38         UUID random = UUID.randomUUID();
39         assertEquals(createNotificationEntity(random), createNotificationEntity(random));
40     }
41
42     @Test
43     public void testOwnerNotEquals() {
44         UUID random = UUID.randomUUID();
45         NotificationEntity mutant = createNotificationEntity(random);
46         mutant.setOwnerId(UUID.randomUUID().toString());
47         assertNotEquals(mutant, createNotificationEntity(random));
48     }
49
50     @Test
51     public void testEventIdNotEquals() {
52         UUID random = UUID.randomUUID();
53         NotificationEntity mutant = createNotificationEntity(random);
54         mutant.setEventId(UUID.randomUUID());
55         assertNotEquals(mutant, createNotificationEntity(random));
56     }
57
58     @Test
59     public void testEventTypeNotEquals() {
60         UUID random = UUID.randomUUID();
61         NotificationEntity mutant = createNotificationEntity(random);
62         mutant.setEventType(UUID.randomUUID().toString());
63         assertNotEquals(mutant, createNotificationEntity(random));
64     }
65
66     @Test
67     public void testOriginatorNotEquals() {
68         UUID random = UUID.randomUUID();
69         NotificationEntity mutant = createNotificationEntity(random);
70         mutant.setOriginatorId(UUID.randomUUID().toString());
71         assertNotEquals(mutant, createNotificationEntity(random));
72     }
73
74     @Test
75     public void testReadNotEquals() {
76         UUID random = UUID.randomUUID();
77         NotificationEntity mutant = createNotificationEntity(random);
78         mutant.setRead(false);
79         assertNotEquals(mutant, createNotificationEntity(random));
80     }
81
82     @Test
83     public void testAttributesNotEquals() {
84         UUID random = UUID.randomUUID();
85         NotificationEntity mutant = createNotificationEntity(random);
86         mutant.setEventAttributes(UUID.randomUUID().toString());
87         assertNotEquals(mutant, createNotificationEntity(random));
88     }
89
90     @Test
91     public void testHashCode() {
92         UUID random = UUID.randomUUID();
93         assertEquals(createNotificationEntity(random).hashCode(), createNotificationEntity(random).hashCode());
94     }
95
96     private NotificationEntity createNotificationEntity(UUID random) {
97         return new NotificationEntity("owner-" + random, random, "type-" + random,
98                 "originator-" + random, true, "attributes-" + random);
99     }
100 }