import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.mdsal.eos.binding.api.Entity;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
private ContextChainHolderImpl contextChainHolder;
private ReconciliationFrameworkRegistration registration;
- private MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
+ private final MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
@Before
public void setUp() throws Exception {
- Mockito.doAnswer(invocation -> {
- invocation.getArgumentAt(0, Runnable.class).run();
- return null;
- }).when(executorService).submit(Mockito.<Runnable>any());
-
-
Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
Mockito.when(deviceManager.createContext(connectionContext)).thenReturn(deviceContext);
Mockito.when(rpcManager.createContext(deviceContext)).thenReturn(rpcContext);
@Test
public void reconciliationFrameworkSuccessButNotSubmit() throws Exception {
contextChainHolder.createContextChain(connectionContext);
- Mockito.when(reconciliationFrameworkEvent.onDevicePrepared(deviceInfo))
- .thenReturn(Futures.immediateFuture(ResultState.DONOTHING));
+ // TODO when if (future != null) check in MastershipChangeServiceManagerImpl's becomeSlaveOrDisconnect() is rm
+ // Mockito.when(reconciliationFrameworkEvent.onDevicePrepared(deviceInfo))
+ // .thenReturn(Futures.immediateFuture(null));
contextChainHolder.createContextChain(connectionContext);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_FLOW_REGISTRY_FILL);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
EntityOwnershipChange ownershipChange = new EntityOwnershipChange(
new Entity(ENTITY_TEST, OPENFLOW_TEST),
- true,
- false,
- false
+ EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER
);
contextChainHolder.ownershipChanged(ownershipChange);
Mockito.verify(deviceManager).removeDeviceFromOperationalDS(Mockito.any());
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
EntityOwnershipChange ownershipChange = new EntityOwnershipChange(
new Entity(ENTITY_TEST, OPENFLOW_TEST),
- true,
- false,
- true
+ EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NEW_OWNER
);
contextChainHolder.ownershipChanged(ownershipChange);
Mockito.verify(deviceManager,Mockito.never()).removeDeviceFromOperationalDS(Mockito.any());