import org.opendaylight.controller.cluster.access.commands.ConnectClientRequest;
import org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess;
import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
-import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
private AbstractDataStoreClientBehavior behavior;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
system = ActorSystem.apply();
clientActorProbe = new TestProbe(system, "client");
actorContextProbe = new TestProbe(system, "actor-context");
- final ActorContext context = createActorContextMock(system, actorContextProbe.ref());
+ final ActorUtils context = createActorContextMock(system, actorContextProbe.ref());
clientContext =
AccessClientUtil.createClientActorContext(system, clientActorProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
behavior = createBehavior(clientContext, context);
@SuppressWarnings("checkstyle:hiddenField")
protected abstract AbstractDataStoreClientBehavior createBehavior(ClientActorContext clientContext,
- ActorContext context);
+ ActorUtils context);
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
TestKit.shutdownActorSystem(system);
}
@Test
- public void testResolveShardForPath() throws Exception {
+ public void testResolveShardForPath() {
Assert.assertEquals(0L, behavior.resolveShardForPath(YangInstanceIdentifier.EMPTY).longValue());
}
@Test
- public void testHaltClient() throws Exception {
+ public void testHaltClient() {
behavior.haltClient(new RuntimeException());
}
@Test
- public void testOnCommand() throws Exception {
+ public void testOnCommand() {
final TestProbe probe = new TestProbe(system);
final GetClientRequest request = new GetClientRequest(probe.ref());
final AbstractDataStoreClientBehavior nextBehavior = behavior.onCommand(request);
}
@Test
- public void testOnCommandUnhandled() throws Exception {
+ public void testOnCommandUnhandled() {
final AbstractDataStoreClientBehavior nextBehavior = behavior.onCommand("unhandled");
Assert.assertSame(behavior, nextBehavior);
}
@Test
- public void testCreateLocalHistory() throws Exception {
+ public void testCreateLocalHistory() {
final ClientLocalHistory history = behavior.createLocalHistory();
Assert.assertEquals(behavior.getIdentifier(), history.getIdentifier().getClientId());
}
@Test
- public void testCreateTransaction() throws Exception {
+ public void testCreateTransaction() {
final ClientTransaction transaction = behavior.createTransaction();
Assert.assertEquals(behavior.getIdentifier(), transaction.getIdentifier().getHistoryId().getClientId());
}
@Test
- public void testCreateSnapshot() throws Exception {
+ public void testCreateSnapshot() {
final ClientSnapshot snapshot = behavior.createSnapshot();
Assert.assertEquals(behavior.getIdentifier(), snapshot.getIdentifier().getHistoryId().getClientId());
}
@Test
- public void testClose() throws Exception {
+ public void testClose() {
behavior.close();
final InternalCommand<ShardBackendInfo> internalCommand =
clientActorProbe.expectMsgClass(InternalCommand.class);
}
@Test
- public void testGetIdentifier() throws Exception {
+ public void testGetIdentifier() {
Assert.assertEquals(CLIENT_ID, behavior.getIdentifier());
}
@Test
- public void testGetConnection() throws Exception {
+ public void testGetConnection() {
//set up data tree mock
final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.empty());
verify(modification).readNode(YangInstanceIdentifier.EMPTY);
}
- private static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
- final ActorContext mock = mock(ActorContext.class);
+ private static ActorUtils createActorContextMock(final ActorSystem system, final ActorRef actor) {
+ final ActorUtils mock = mock(ActorUtils.class);
final Promise<PrimaryShardInfo> promise = new scala.concurrent.impl.Promise.DefaultPromise<>();
final ActorSelection selection = system.actorSelection(actor.path());
final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);