Fix checkstyle violations in applications
[openflowplugin.git] / applications / forwardingrules-sync / src / test / java / org / opendaylight / openflowplugin / applications / frsync / impl / clustering / DeviceMastershipTest.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.impl.clustering;
10
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.Mock;
16 import org.mockito.Mockito;
17 import org.mockito.runners.MockitoJUnitRunner;
18 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
19 import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
21
22 /**
23  * Test for {@link DeviceMastership}.
24  */
25 @RunWith(MockitoJUnitRunner.class)
26 public class DeviceMastershipTest {
27     private static final NodeId NODE_ID = new NodeId("testNode");
28     private DeviceMastership deviceMastership;
29
30     @Mock
31     private DeviceMastershipManager deviceMastershipManager;
32     @Mock
33     private ReconciliationRegistry reconciliationRegistry;
34
35     @Before
36     public void setUp() throws Exception {
37         deviceMastership = new DeviceMastership(NODE_ID, reconciliationRegistry,
38                 Mockito.mock(ClusterSingletonServiceProvider.class));
39     }
40
41     @Test
42     public void testInstantiateServiceInstance() {
43         deviceMastership.instantiateServiceInstance();
44         Mockito.verify(reconciliationRegistry).register(NODE_ID);
45         Assert.assertTrue(deviceMastership.isDeviceMastered());
46     }
47
48     @Test
49     public void testCloseServiceInstance() {
50         deviceMastership.closeServiceInstance();
51         Mockito.verify(reconciliationRegistry).unregisterIfRegistered(NODE_ID);
52         Assert.assertFalse(deviceMastership.isDeviceMastered());
53     }
54
55 }