X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fbulk-o-matic%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Fbulk%2Fo%2Fmatic%2FFlowWriterSequentialTest.java;h=780fc4adb0115174b726b867f6365a5eb8cf3d33;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=5b570543556b9441434cefd7bbdffae948bfad1b;hpb=d40850b072f82e1cfdbae8b467ab268276727d55;p=openflowplugin.git diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java index 5b57054355..780fc4adb0 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2016, 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, @@ -15,12 +15,10 @@ import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -43,36 +41,37 @@ public class FlowWriterSequentialTest { @Mock private ExecutorService mockFlowPusher; @Mock - private WriteTransaction wTx; + private WriteTransaction writeTransaction; private FlowWriterSequential flowWriterSequential; @Before public void setUp() throws Exception { - doReturn(wTx).when(mockDataBroker).newWriteOnlyTransaction(); - Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(writeTransaction).when(mockDataBroker).newWriteOnlyTransaction(); + Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - ((Runnable)invocation.getArguments()[0]).run(); - return null; - } - }).when(mockFlowPusher).execute(Matchers.any()); + Mockito.doAnswer(invocation -> { + ((Runnable) invocation.getArguments()[0]).run(); + return null; + }).when(mockFlowPusher).execute(ArgumentMatchers.any()); flowWriterSequential = new FlowWriterSequential(mockDataBroker, mockFlowPusher); } + @Test public void testAddFlows() throws Exception { - flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short)0, (short)1); - Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).put(Matchers.any(), Matchers.>any(), Matchers.any(), Matchers.anyBoolean()); + flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short) 0, (short) 1, true); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(), + ArgumentMatchers.>any(), ArgumentMatchers.any(), + ArgumentMatchers.anyBoolean()); } @Test public void testDeleteFlows() throws Exception { - flowWriterSequential.deleteFlows(1, FLOWS_PER_DPN, 10, (short)0, (short)1); - Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).delete(Matchers.any(), Matchers.>any()); + flowWriterSequential.deleteFlows(1, FLOWS_PER_DPN, 10, (short) 0, (short) 1); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)) + .delete(ArgumentMatchers.any(), + ArgumentMatchers.>any()); } - -} \ No newline at end of file +}