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%2Fpersisted%2FFrontendShardDataTreeSnapshotMetadataTest.java;h=db52111ad22199270bac587fd8ce10cbc476f84a;hb=HEAD;hp=25b5128dbaf08b0ab29c940b333b58190ac8cdbe;hpb=546cd1fd100dbaa36908b22c2f422320dbd8c4b2;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadataTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadataTest.java index 25b5128dba..556772456c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadataTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadataTest.java @@ -13,10 +13,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Range; -import com.google.common.collect.RangeSet; -import com.google.common.collect.TreeRangeSet; import com.google.common.primitives.UnsignedLong; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -27,12 +23,14 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import org.junit.Test; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendType; import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.datastore.utils.ImmutableUnsignedLongSet; +import org.opendaylight.controller.cluster.datastore.utils.MutableUnsignedLongSet; +import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongBitmap; public class FrontendShardDataTreeSnapshotMetadataTest { @@ -44,21 +42,21 @@ public class FrontendShardDataTreeSnapshotMetadataTest { @Test public void testCreateMetadataSnapshotEmptyInput() throws Exception { final FrontendShardDataTreeSnapshotMetadata emptyOrigSnapshot = createEmptyMetadataSnapshot(); - final FrontendShardDataTreeSnapshotMetadata emptyCopySnapshot = copy(emptyOrigSnapshot, 127); + final FrontendShardDataTreeSnapshotMetadata emptyCopySnapshot = copy(emptyOrigSnapshot, 86); testMetadataSnapshotEqual(emptyOrigSnapshot, emptyCopySnapshot); } @Test public void testSerializeMetadataSnapshotWithOneClient() throws Exception { final FrontendShardDataTreeSnapshotMetadata origSnapshot = createMetadataSnapshot(1); - final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 162); + final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 121); testMetadataSnapshotEqual(origSnapshot, copySnapshot); } @Test public void testSerializeMetadataSnapshotWithMoreClients() throws Exception { final FrontendShardDataTreeSnapshotMetadata origSnapshot = createMetadataSnapshot(5); - final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 314); + final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 273); testMetadataSnapshotEqual(origSnapshot, copySnapshot); } @@ -72,15 +70,15 @@ public class FrontendShardDataTreeSnapshotMetadataTest { final Map origIdent = new HashMap<>(); final Map copyIdent = new HashMap<>(); - origClientList.forEach(client -> origIdent.put(client.getIdentifier(), client)); - origClientList.forEach(client -> copyIdent.put(client.getIdentifier(), client)); + origClientList.forEach(client -> origIdent.put(client.clientId(), client)); + origClientList.forEach(client -> copyIdent.put(client.clientId(), client)); assertTrue(origIdent.keySet().containsAll(copyIdent.keySet())); assertTrue(copyIdent.keySet().containsAll(origIdent.keySet())); origIdent.values().forEach(client -> { - final FrontendClientMetadata copyClient = copyIdent.get(client.getIdentifier()); - testObject(client.getIdentifier(), copyClient.getIdentifier()); + final var copyClient = copyIdent.get(client.clientId()); + testObject(client.clientId(), copyClient.clientId()); assertEquals(client.getPurgedHistories(), copyClient.getPurgedHistories()); assertEquals(client.getCurrentHistories(), copyClient.getCurrentHistories()); }); @@ -104,15 +102,11 @@ public class FrontendShardDataTreeSnapshotMetadataTest { final FrontendIdentifier frontendIdentifier = FrontendIdentifier.create(MemberName.forName(indexName), FrontendType.forName(index)); final ClientIdentifier clientIdentifier = ClientIdentifier.create(frontendIdentifier, num); + final ImmutableUnsignedLongSet purgedHistories = MutableUnsignedLongSet.of(0).immutableCopy(); - final RangeSet purgedHistories = TreeRangeSet.create(); - purgedHistories.add(Range.closedOpen(UnsignedLong.ZERO, UnsignedLong.ONE)); - - final Set currentHistories = Set.of( - new FrontendHistoryMetadata(num, num, true, ImmutableMap.of(UnsignedLong.ZERO, Boolean.TRUE), - purgedHistories)); - - return new FrontendClientMetadata(clientIdentifier, purgedHistories, currentHistories); + return new FrontendClientMetadata(clientIdentifier, purgedHistories, List.of( + new FrontendHistoryMetadata(num, num, true, + UnsignedLongBitmap.copyOf(Map.of(UnsignedLong.ZERO, Boolean.TRUE)), purgedHistories))); } private static void testObject(final T object, final T equalObject) {