X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fsharding%2FDistributedShardFrontendTest.java;h=795705ea67fabb942e95f501dfa72bbeab27fd62;hp=fb701de3ab6517a912322f281fbe5fd4d3ec411d;hb=cd5f6c81892dea24e9bceed6218a3f5e4529f12b;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java index fb701de3ab..795705ea67 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.sharding; +import static org.hamcrest.CoreMatchers.hasItems; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; @@ -20,6 +21,7 @@ import static org.mockito.Mockito.verify; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -42,8 +44,8 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -53,7 +55,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo public class DistributedShardFrontendTest { private static final DOMDataTreeIdentifier ROOT = - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); private static final ListenableFuture SUCCESS_FUTURE = Futures.immediateFuture(null); private ShardedDOMDataTree shardedDOMDataTree; @@ -64,12 +66,12 @@ public class DistributedShardFrontendTest { private DOMDataTreeWriteCursor cursor; private static final YangInstanceIdentifier OUTER_LIST_YID = TestModel.OUTER_LIST_PATH.node( - new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)); + NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)); private static final DOMDataTreeIdentifier OUTER_LIST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, OUTER_LIST_YID); @Captor - private ArgumentCaptor pathArgumentCaptor; + private ArgumentCaptor pathArgumentCaptor; @Captor private ArgumentCaptor> nodeCaptor; @@ -108,7 +110,6 @@ public class DistributedShardFrontendTest { @Test public void testClientTransaction() throws Exception { - final DistributedDataStore distributedDataStore = mock(DistributedDataStore.class); final ActorUtils context = mock(ActorUtils.class); doReturn(context).when(distributedDataStore).getActorUtils(); @@ -157,19 +158,15 @@ public class DistributedShardFrontendTest { //check the lower shard got the correct modification verify(outerListCursor, times(2)).write(pathArgumentCaptor.capture(), nodeCaptor.capture()); - final YangInstanceIdentifier.PathArgument expectedYid = new NodeIdentifier(TestModel.ID_QNAME); - final YangInstanceIdentifier.PathArgument actualIdYid = pathArgumentCaptor.getAllValues().get(0); - assertEquals(expectedYid, actualIdYid); - - final YangInstanceIdentifier.PathArgument expectedInnerYid = new NodeIdentifier(TestModel.INNER_LIST_QNAME); - final YangInstanceIdentifier.PathArgument actualInnerListYid = pathArgumentCaptor.getAllValues().get(1); - assertEquals(expectedInnerYid, actualInnerListYid); - - final LeafNode actualIdNode = (LeafNode) nodeCaptor.getAllValues().get(0); - assertEquals(ImmutableNodes.leafNode(TestModel.ID_QNAME, 1), actualIdNode); + final List capturedArgs = pathArgumentCaptor.getAllValues(); + assertEquals(2, capturedArgs.size()); + assertThat(capturedArgs, + hasItems(new NodeIdentifier(TestModel.ID_QNAME), new NodeIdentifier(TestModel.INNER_LIST_QNAME))); - final MapNode actualInnerListNode = (MapNode) nodeCaptor.getAllValues().get(1); - assertEquals(createInnerMapNode(1), actualInnerListNode); + final List> capturedValues = nodeCaptor.getAllValues(); + assertEquals(2, capturedValues.size()); + assertThat(capturedValues, + hasItems(ImmutableNodes.leafNode(TestModel.ID_QNAME, 1), createInnerMapNode(1))); txCursor.close(); tx.commit().get();