Migrate from JavaTestKit to javadsl.TestKit
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / RpcBrokerTest.java
index 6ecd7dac3adc48630540c64e7f14effa6adc915b..d588736f61b0f0aa2e5436abccd23f3e5da3968e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,18 +8,16 @@
 
 package org.opendaylight.controller.remote.rpc;
 
-
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.when;
 
 import akka.actor.Status.Failure;
-import akka.testkit.JavaTestKit;
+import akka.testkit.javadsl.TestKit;
 import com.google.common.util.concurrent.Futures;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
@@ -33,7 +31,7 @@ public class RpcBrokerTest extends AbstractRpcTest {
 
     @Test
     public void testExecuteRpc() {
-        new JavaTestKit(node1) {
+        new TestKit(node1) {
             {
 
                 final ContainerNode invokeRpcResult = makeRPCOutput("bar");
@@ -43,37 +41,31 @@ public class RpcBrokerTest extends AbstractRpcTest {
 
                 final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
 
-                rpcBroker1.tell(executeMsg, getRef());
+                rpcInvoker1.tell(executeMsg, getRef());
 
                 final RpcResponse rpcResponse = expectMsgClass(duration("5 seconds"), RpcResponse.class);
 
-                assertEquals(rpcResult.getResult(),
-                        NormalizedNodeSerializer.deSerialize(rpcResponse.getResultNormalizedNode()));
+                assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode());
             }
         };
     }
 
     @Test
     public void testExecuteRpcFailureWithException() {
-
-        new JavaTestKit(node1) {
+        new TestKit(node1) {
             {
-
                 when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.<NormalizedNode<?, ?>>any()))
-                        .thenReturn(
-                                Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException(
-                                        "NOT FOUND")));
+                        .thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
+                                new DOMRpcImplementationNotAvailableException("NOT FOUND")));
 
                 final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
 
-                rpcBroker1.tell(executeMsg, getRef());
+                rpcInvoker1.tell(executeMsg, getRef());
 
                 final Failure rpcResponse = expectMsgClass(duration("5 seconds"), akka.actor.Status.Failure.class);
 
                 Assert.assertTrue(rpcResponse.cause() instanceof DOMRpcException);
             }
         };
-
     }
-
 }