2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.applications.frsync.impl.clustering;
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.mockito.Mock;
15 import org.mockito.Mockito;
16 import org.mockito.junit.MockitoJUnitRunner;
17 import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
18 import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
22 * Test for {@link DeviceMastership}.
24 @RunWith(MockitoJUnitRunner.class)
25 public class DeviceMastershipTest {
26 private static final NodeId NODE_ID = new NodeId("testNode");
27 private DeviceMastership deviceMastership;
30 private DeviceMastershipManager deviceMastershipManager;
32 private ReconciliationRegistry reconciliationRegistry;
36 deviceMastership = new DeviceMastership(NODE_ID, reconciliationRegistry,
37 Mockito.mock(ClusterSingletonServiceProvider.class));
41 public void testInstantiateServiceInstance() {
42 deviceMastership.instantiateServiceInstance();
43 Mockito.verify(reconciliationRegistry).register(NODE_ID);
44 Assert.assertTrue(deviceMastership.isDeviceMastered());
48 public void testCloseServiceInstance() {
49 deviceMastership.closeServiceInstance();
50 Mockito.verify(reconciliationRegistry).unregisterIfRegistered(NODE_ID);
51 Assert.assertFalse(deviceMastership.isDeviceMastered());