Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / applications / forwardingrules-sync / src / test / java / org / opendaylight / openflowplugin / applications / frsync / util / ReconciliationRegistryTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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 package org.opendaylight.openflowplugin.applications.frsync.util;
9
10 import java.util.Date;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.mockito.junit.MockitoJUnitRunner;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
17
18 /**
19  * Test for {@link ReconciliationRegistry}.
20  */
21 @RunWith(MockitoJUnitRunner.class)
22 public class ReconciliationRegistryTest {
23
24     private static final NodeId NODE_ID = new NodeId("testNode");
25     private ReconciliationRegistry reconciliationRegistry;
26
27     @Before
28     public void setUp() {
29         reconciliationRegistry = new ReconciliationRegistry();
30     }
31
32     @Test
33     public void testRegister() {
34         Date timestamp = reconciliationRegistry.register(NODE_ID);
35         Assert.assertEquals(true, reconciliationRegistry.isRegistered(NODE_ID));
36         Assert.assertNotNull(timestamp);
37     }
38
39     @Test
40     public void testUnregisterIfRegistered() {
41         reconciliationRegistry.register(NODE_ID);
42         Date timestamp = reconciliationRegistry.unregisterIfRegistered(NODE_ID);
43         Assert.assertEquals(false, reconciliationRegistry.isRegistered(NODE_ID));
44         Assert.assertNotNull(timestamp);
45     }
46
47     @Test
48     public void testUnregisterIfNotRegistered() {
49         Date timestamp = reconciliationRegistry.unregisterIfRegistered(NODE_ID);
50         Assert.assertEquals(false, reconciliationRegistry.isRegistered(NODE_ID));
51         Assert.assertNull(timestamp);
52     }
53
54 }