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%2Futils%2FActorUtilsTest.java;h=daef2143a2df5c88b893b72701499457001a391a;hb=HEAD;hp=919b49f305ad6707792553b721eb33c1d22d222a;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtilsTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtilsTest.java index 919b49f305..daef2143a2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtilsTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtilsTest.java @@ -5,7 +5,6 @@ * 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.datastore.utils; import static org.junit.Assert.assertEquals; @@ -30,13 +29,13 @@ import akka.japi.Creator; import akka.testkit.TestActorRef; import akka.testkit.javadsl.TestKit; import akka.util.Timeout; -import com.google.common.base.Optional; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.typesafe.config.ConfigFactory; import java.time.Duration; import java.util.Arrays; +import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Test; @@ -60,7 +59,7 @@ import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShard import org.opendaylight.controller.cluster.raft.utils.EchoActor; import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; @@ -68,17 +67,16 @@ import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; public class ActorUtilsTest extends AbstractActorTest { - static final Logger LOG = LoggerFactory.getLogger(ActorUtilsTest.class); - private static class TestMessage { + private static final class TestMessage { + } private static final class MockShardManager extends UntypedAbstractActor { - + private final Map findPrimaryResponses = new HashMap<>(); private final boolean found; private final ActorRef actorRef; - private final Map findPrimaryResponses = Maps.newHashMap(); private MockShardManager(final boolean found, final ActorRef actorRef) { @@ -87,8 +85,7 @@ public class ActorUtilsTest extends AbstractActorTest { } @Override public void onReceive(final Object message) { - if (message instanceof FindPrimary) { - FindPrimary fp = (FindPrimary)message; + if (message instanceof FindPrimary fp) { Object resp = findPrimaryResponses.get(fp.getShardName()); if (resp == null) { LOG.error("No expected FindPrimary response found for shard name {}", fp.getShardName()); @@ -111,11 +108,11 @@ public class ActorUtilsTest extends AbstractActorTest { } private static Props props(final boolean found, final ActorRef actorRef) { - return Props.create(new MockShardManagerCreator(found, actorRef)); + return Props.create(MockShardManager.class, new MockShardManagerCreator(found, actorRef)); } private static Props props() { - return Props.create(new MockShardManagerCreator()); + return Props.create(MockShardManager.class, new MockShardManagerCreator()); } @SuppressWarnings("serial") @@ -124,8 +121,8 @@ public class ActorUtilsTest extends AbstractActorTest { final ActorRef actorRef; MockShardManagerCreator() { - this.found = false; - this.actorRef = null; + found = false; + actorRef = null; } MockShardManagerCreator(final boolean found, final ActorRef actorRef) { @@ -151,9 +148,7 @@ public class ActorUtilsTest extends AbstractActorTest { ActorUtils actorUtils = new ActorUtils(getSystem(), shardManagerActorRef, mock(ClusterWrapper.class), mock(Configuration.class)); - Optional out = actorUtils.findLocalShard("default"); - - assertEquals(shardActorRef, out.get()); + assertEquals(Optional.of(shardActorRef), actorUtils.findLocalShard("default")); testKit.expectNoMessage(); return null; @@ -381,7 +376,7 @@ public class ActorUtilsTest extends AbstractActorTest { assertNotNull(actual); assertTrue("LocalShardDataTree present", actual.getLocalShardDataTree().isPresent()); - assertSame("LocalShardDataTree", mockDataTree, actual.getLocalShardDataTree().get()); + assertSame("LocalShardDataTree", mockDataTree, actual.getLocalShardDataTree().orElseThrow()); assertTrue("Unexpected PrimaryShardActor path " + actual.getPrimaryShardActor().path(), expPrimaryPath.endsWith(actual.getPrimaryShardActor().pathString())); assertEquals("getPrimaryShardVersion", DataStoreVersions.CURRENT_VERSION, actual.getPrimaryShardVersion());