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