Merge "Logs are added to identify the flows and groups being added in the node for...
[openflowplugin.git] / applications / forwardingrules-manager / src / test / java / org / opendaylight / openflowplugin / applications / frm / impl / DeviceMastershipTest.java
1 /**
2  * Copyright (c) 2016, 2017 Pantheon Technologies s.r.o. 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.frm.impl;
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.runners.MockitoJUnitRunner;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
19
20 /**
21  * Test for {@link DeviceMastership}.
22  */
23 @RunWith(MockitoJUnitRunner.class)
24 public class DeviceMastershipTest {
25     private static final NodeId NODE_ID = new NodeId("testNode");
26     private DeviceMastership deviceMastership;
27     @Mock
28     private RoutedRpcRegistration routedRpcRegistration;
29
30     @Before
31     public void setUp() throws Exception {
32         deviceMastership = new DeviceMastership(NODE_ID, routedRpcRegistration);
33     }
34
35     @Test
36     public void testInstantiateServiceInstance() {
37         deviceMastership.instantiateServiceInstance();
38         Assert.assertTrue(deviceMastership.isDeviceMastered());
39     }
40
41     @Test
42     public void testCloseServiceInstance() {
43         deviceMastership.closeServiceInstance();
44         Assert.assertFalse(deviceMastership.isDeviceMastered());
45     }
46 }