2 * Copyright © 2016-2017 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.sdc.notification.dao.types;
19 import org.testng.annotations.Test;
21 import java.util.Collections;
22 import java.util.HashSet;
24 import java.util.UUID;
26 import static org.testng.Assert.assertEquals;
27 import static org.testng.Assert.assertNotEquals;
33 public class SubscribersEntityTest {
35 private static final Set<String> SUBSCRIBERS;
38 Set<String> subs = new HashSet<>(2);
39 subs.add(UUID.randomUUID().toString());
40 subs.add(UUID.randomUUID().toString());
41 SUBSCRIBERS = Collections.unmodifiableSet(subs);
45 public void testUninitializedEquals() {
46 assertEquals(new SubscribersEntity(), new SubscribersEntity());
50 public void testEquals() {
51 String entity = UUID.randomUUID().toString();
52 assertEquals(new SubscribersEntity(entity, SUBSCRIBERS), new SubscribersEntity(entity, SUBSCRIBERS));
56 public void testEntityNotEquals() {
57 assertNotEquals(new SubscribersEntity(UUID.randomUUID().toString(), SUBSCRIBERS),
58 new SubscribersEntity(UUID.randomUUID().toString(), SUBSCRIBERS));
62 public void testSubscribersNotEquals() {
63 String entity = UUID.randomUUID().toString();
64 assertNotEquals(new SubscribersEntity(entity, SUBSCRIBERS),
65 // not using Collections.emptySet() to use the the same implementation class
66 new SubscribersEntity(entity, Collections.unmodifiableSet(new HashSet<>(0))));
70 public void testHashCode() {
71 String entity = UUID.randomUUID().toString();
72 assertEquals(new SubscribersEntity(entity, SUBSCRIBERS).hashCode(),
73 new SubscribersEntity(entity, SUBSCRIBERS).hashCode());