OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / MultipartRequestCallbackTest.java
index 12f5de2af3d296d1cd7730cade2ccc24b66e2d7a..c752535ca0303406eab4d6296a315f631dcc11bc 100644 (file)
@@ -14,16 +14,18 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Captor;
-import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.OngoingStubbing;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerMultipartRequestCallback;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
@@ -32,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 /**
- * Test for {@link MultipartRequestCallback}.
+ * Test for {@link org.opendaylight.openflowplugin.impl.services.AbstractMultipartRequestCallback}.
  */
 @RunWith(MockitoJUnitRunner.class)
 public class MultipartRequestCallbackTest {
@@ -44,35 +46,37 @@ public class MultipartRequestCallbackTest {
     @Mock
     private MessageSpy spy;
     @Mock
-    private MultiMsgCollector multiMsgCollector;
+    private MultiMsgCollector<MultipartReply> multiMsgCollector;
     @Captor
     private ArgumentCaptor<RpcResult<List<MultipartReply>>> rpcResultCapt;
 
-    private MultipartRequestCallback multipartRequestCallback;
+    private AbstractMultipartRequestCallback<MultipartReply> multipartRequestCallback;
 
     @Before
     public void setUp() throws Exception {
         Mockito.doNothing().when(requestContext).setResult(rpcResultCapt.capture());
         Mockito.when(deviceContext.getMessageSpy()).thenReturn(spy);
-        Mockito.when(deviceContext.getMultiMsgCollector(Matchers.<RequestContext>any())).thenReturn(multiMsgCollector);
-        multipartRequestCallback = new MultipartRequestCallback(requestContext, MultipartRequestInput.class, deviceContext);
+
+        final OngoingStubbing<MultiMsgCollector<MultipartReply>> when =
+            Mockito.when(deviceContext.getMultiMsgCollector(ArgumentMatchers.any()));
+        when.thenReturn(multiMsgCollector);
+        multipartRequestCallback = new MultiLayerMultipartRequestCallback<>(requestContext,
+                                                                            MultipartRequestInput.class,
+                                                                            deviceContext,
+                                                                            null);
     }
 
     /**
-     * end collecting
-     *
-     * @throws Exception
+     * End collecting.
      */
     @Test
     public void testOnSuccess1() throws Exception {
         multipartRequestCallback.onSuccess(null);
-        Mockito.verify(multiMsgCollector).endCollecting(Matchers.<EventIdentifier>any());
+        Mockito.verify(multiMsgCollector).endCollecting(ArgumentMatchers.<EventIdentifier>any());
     }
 
     /**
-     * fail adding to collection
-     *
-     * @throws Exception
+     * Fail adding to collection.
      */
     @Test
     public void testOnSuccess2() throws Exception {
@@ -83,14 +87,13 @@ public class MultipartRequestCallbackTest {
     }
 
     /**
-     * successfully added to collection
-     *
-     * @throws Exception
+     * Successfully added to collection.
      */
     @Test
     public void testOnSuccess3() throws Exception {
         final MultipartReplyMessage replyMessage = new MultipartReplyMessageBuilder().build();
         multipartRequestCallback.onSuccess(replyMessage);
-        Mockito.verify(multiMsgCollector).addMultipartMsg(Matchers.eq(replyMessage), Matchers.<EventIdentifier>any());
+        Mockito.verify(multiMsgCollector)
+                .addMultipartMsg(ArgumentMatchers.eq(replyMessage), ArgumentMatchers.eq(false), ArgumentMatchers.any());
     }
-}
\ No newline at end of file
+}