*/
package org.opendaylight.openflowplugin.impl.mastership;
-import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.MasterChecker;
-import org.opendaylight.openflowplugin.api.openflow.mastership.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.*;
+import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeException;
+import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeRegistration;
+import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeService;
+import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
+import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkEvent;
+import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkRegistration;
@RunWith(MockitoJUnitRunner.class)
public class MastershipChangeServiceManagerImplTest {
@Mock
private DeviceInfo deviceInfo;
@Mock
- private FutureCallback<ResultState> resultStateFutureCallback;
- @Mock
private MasterChecker masterChecker;
@Mock
private ReconciliationFrameworkEvent event;
@Mock
private ReconciliationFrameworkEvent secondEvent;
- final private MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
+ private final MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
private MastershipChangeRegistration registration;
private ReconciliationFrameworkRegistration registrationRF;
public void setUp() throws Exception {
registration = manager.register(service);
registrationRF = manager.reconciliationFrameworkRegistration(event);
+
+ Mockito.when(event.onDeviceDisconnected(Mockito.any())).thenReturn(Futures.immediateFuture(null));
}
@Test
- public void register() throws Exception {
+ public void register() {
Assert.assertNotNull(registration);
}
@Test
- public void registerTwice() throws Exception {
+ public void registerTwice() {
MastershipChangeRegistration registration2;
registration2 = manager.register(secondService);
Assert.assertNotNull(registration);
}
@Test
- public void reconciliationFrameworkRegistration() throws Exception {
+ public void reconciliationFrameworkRegistration() {
Assert.assertNotNull(registrationRF);
}
}
@Test
- public void becomeMaster() throws Exception {
+ public void becomeMaster() {
manager.becomeMaster(deviceInfo);
Mockito.verify(service).onBecomeOwner(deviceInfo);
manager.becomeSlaveOrDisconnect(deviceInfo);
}
@Test
- public void becomeMasterBeforeDS() throws Exception {
- manager.becomeMasterBeforeSubmittedDS(deviceInfo, resultStateFutureCallback);
- Mockito.verify(event).onDevicePrepared(deviceInfo, resultStateFutureCallback);
+ public void becomeMasterBeforeDS() {
+ manager.becomeMasterBeforeSubmittedDS(deviceInfo);
+ Mockito.verify(event).onDevicePrepared(deviceInfo);
}
@Test
}
@Test
- public void evokeEventAfterRegistration() throws Exception {
+ public void evokeEventAfterRegistration() {
List<DeviceInfo> deviceInfos = new ArrayList<>();
deviceInfos.add(deviceInfo);
manager.setMasterChecker(masterChecker);