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;
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 {
@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 {
}
/**
- * 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
+}