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%2FEntityOwnershipStatisticsTest.java;h=d15111210b892c09440e362309779ce3c46f4b6f;hb=f899094ab7c5ac2a8bfe141b27ba11c5b9e34b02;hp=a621ac65abd448693b2d5108617c01f1bd5774a8;hpb=43aab07cdbc80eda69e84a26085afe1b37f4002e;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatisticsTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatisticsTest.java index a621ac65ab..d15111210b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatisticsTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipStatisticsTest.java @@ -13,10 +13,13 @@ 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 java.util.Map; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.AbstractActorTest; +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.yangtools.yang.common.QName; @@ -35,7 +38,9 @@ public class EntityOwnershipStatisticsTest extends AbstractActorTest { private static final YangInstanceIdentifier ENTITY_ID2 = YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "entity2")); - private final ShardDataTree shardDataTree = new ShardDataTree(SchemaContextHelper.entityOwners(), + private final Shard mockShard = Mockito.mock(Shard.class); + + private final ShardDataTree shardDataTree = new ShardDataTree(mockShard, SchemaContextHelper.entityOwners(), TreeType.OPERATIONAL); private EntityOwnershipStatistics ownershipStatistics; @@ -47,7 +52,6 @@ public class EntityOwnershipStatisticsTest extends AbstractActorTest { @Test public void testOnDataTreeChanged() throws Exception { - Map> statistics = null; writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, LOCAL_MEMBER_NAME)); writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID2, LOCAL_MEMBER_NAME)); @@ -64,7 +68,7 @@ public class EntityOwnershipStatisticsTest extends AbstractActorTest { // Change owner to remote member 1 for entity 1 writeNode(entityPath(ENTITY_TYPE, ENTITY_ID1), entityEntryWithOwner(ENTITY_ID1, REMOTE_MEMBER_NAME1)); - statistics = ownershipStatistics.all(); + Map> statistics = ownershipStatistics.all(); assertStatistics(statistics, LOCAL_MEMBER_NAME, 0L); assertStatistics(statistics, REMOTE_MEMBER_NAME1, 1L); @@ -132,11 +136,13 @@ public class EntityOwnershipStatisticsTest extends AbstractActorTest { } - private static void assertStatistics(Map> statistics, String memberName, long val) { + private static void assertStatistics(final Map> statistics, final String memberName, + final long val) { assertEquals(val, statistics.get(ENTITY_TYPE).get(memberName).longValue()); } - 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); } -} \ No newline at end of file +}