Bug 4105: Remove candidates on PeerDown
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / entityownership / EntityOwnerChangeListenerTest.java
index 9bd0ccf2c0e4715e8530038007e18a50adf7a27b..8b80d6b9e76ecceaec30993d7e42496466aae578 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
+;
 
 /**
  * Unit tests for EntityOwnerChangeListener.
@@ -85,9 +86,21 @@ public class EntityOwnerChangeListenerTest {
         reset(mockListenerSupport);
         writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, LOCAL_MEMBER_NAME));
         verify(mockListenerSupport).notifyEntityOwnershipListeners(ENTITY2, false, true);
+
+        reset(mockListenerSupport);
+        writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, LOCAL_MEMBER_NAME));
+        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(), anyBoolean());
+
+        reset(mockListenerSupport);
+        writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, null));
+        verify(mockListenerSupport).notifyEntityOwnershipListeners(ENTITY2, true, false);
     }
 
     private void writeNode(YangInstanceIdentifier path, NormalizedNode<?, ?> node) throws DataValidationFailedException {
         AbstractEntityOwnershipTest.writeNode(path, node, shardDataTree);
     }
+
+    private void deleteNode(YangInstanceIdentifier path) throws DataValidationFailedException {
+        AbstractEntityOwnershipTest.deleteNode(path, shardDataTree);
+    }
 }