X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fentityownership%2FEntityOwnerChangeListenerTest.java;h=a8b3a677408c87554a20589f7b308298b20e2e3a;hb=cd3a0e09db5a1def00c46a4be245dbdf648b539c;hp=cc228a4c71572037b7c0a863133ad841e773850c;hpb=43aab07cdbc80eda69e84a26085afe1b37f4002e;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListenerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListenerTest.java index cc228a4c71..a8b3a67740 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListenerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListenerTest.java @@ -17,17 +17,20 @@ import static org.opendaylight.controller.cluster.datastore.entityownership.Enti import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityEntryWithOwner; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityOwnersWithCandidate; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityPath; + import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.datastore.Shard; import org.opendaylight.controller.cluster.datastore.ShardDataTree; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; -import org.opendaylight.controller.md.sal.common.api.clustering.Entity; +import org.opendaylight.mdsal.eos.dom.api.DOMEntity; 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; import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; -; /** * Unit tests for EntityOwnerChangeListener. @@ -43,17 +46,19 @@ public class EntityOwnerChangeListenerTest { YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "entity1")); private static final YangInstanceIdentifier ENTITY_ID2 = YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "entity2")); - private static final Entity ENTITY1 = new Entity(ENTITY_TYPE, ENTITY_ID1); - private static final Entity ENTITY2 = new Entity(ENTITY_TYPE, ENTITY_ID2); + private static final DOMEntity ENTITY1 = new DOMEntity(ENTITY_TYPE, ENTITY_ID1); + private static final DOMEntity ENTITY2 = new DOMEntity(ENTITY_TYPE, ENTITY_ID2); + + private final Shard mockShard = Mockito.mock(Shard.class); - private final ShardDataTree shardDataTree = new ShardDataTree(SchemaContextHelper.entityOwners(), + private final ShardDataTree shardDataTree = new ShardDataTree(mockShard, SchemaContextHelper.entityOwners(), TreeType.OPERATIONAL); private final EntityOwnershipListenerSupport mockListenerSupport = mock(EntityOwnershipListenerSupport.class); private EntityOwnerChangeListener listener; @Before public void setup() { - listener = new EntityOwnerChangeListener(LOCAL_MEMBER_NAME, mockListenerSupport); + listener = new EntityOwnerChangeListener(MemberName.forName(LOCAL_MEMBER_NAME), mockListenerSupport); listener.init(shardDataTree); } @@ -61,7 +66,7 @@ public class EntityOwnerChangeListenerTest { public void testOnDataTreeChanged() throws Exception { writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, LOCAL_MEMBER_NAME)); writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID2, LOCAL_MEMBER_NAME)); - verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(), + verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(), anyBoolean(), anyBoolean()); // Write local member as owner for entity 1 @@ -73,7 +78,7 @@ public class EntityOwnerChangeListenerTest { reset(mockListenerSupport); writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, REMOTE_MEMBER_NAME1)); - verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(), + verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(), anyBoolean(), anyBoolean()); // Change owner to remote member 1 for entity 1 @@ -115,7 +120,7 @@ public class EntityOwnerChangeListenerTest { reset(mockListenerSupport); writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, LOCAL_MEMBER_NAME)); - verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(), + verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(), anyBoolean(), anyBoolean()); // Clear the owner for entity 2 @@ -128,11 +133,12 @@ public class EntityOwnerChangeListenerTest { reset(mockListenerSupport); writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, null)); - verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(), + verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(), anyBoolean(), anyBoolean()); } - private void writeNode(YangInstanceIdentifier path, NormalizedNode node) throws DataValidationFailedException { + private void writeNode(final YangInstanceIdentifier path, final NormalizedNode node) + throws DataValidationFailedException { AbstractEntityOwnershipTest.writeNode(path, node, shardDataTree); } }