Fix NPE triggered after disabling SG on a port
[netvirt.git] / openstack / net-virt / src / test / java / org / opendaylight / netvirt / openstack / netvirt / NodeCacheManagerEventTest.java
1 /*
2  * Copyright (c) 2015 Inocybe and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.openstack.netvirt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.mockito.Mockito.mock;
15
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.mockito.InjectMocks;
19 import org.mockito.runners.MockitoJUnitRunner;
20 import org.opendaylight.netvirt.openstack.netvirt.api.Action;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
22
23 /**
24  * Unit test for {@link NodeCacheManagerEvent}
25  */
26
27 @RunWith(MockitoJUnitRunner.class)
28 public class NodeCacheManagerEventTest {
29
30     @InjectMocks private NodeCacheManagerEvent nodeCacheManagerEvent;
31
32     @Test
33     public void testToString() {
34         Node node = mock(Node.class);
35         nodeCacheManagerEvent = new NodeCacheManagerEvent(node, Action.ADD);
36         assertEquals("Error, toString() did not return the correct string", "NodeCacheManagerEvent [action=ADD, node=" + node + "]", nodeCacheManagerEvent.toString());
37     }
38
39     @Test
40     public void testHashCode() {
41         assertNotNull("Error, hashCode shouldn't be null", nodeCacheManagerEvent.hashCode());
42     }
43
44     @Test
45     public void testEquals() {
46         assertTrue("Error, the two object should be equal", nodeCacheManagerEvent.equals(nodeCacheManagerEvent));
47         assertFalse("Error, the two object should not be equal", nodeCacheManagerEvent.equals("dummy"));
48     }
49 }