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=f9c510df33d66ff7e8d6330cbb9fefb97e2f26c2;hb=05f8db12159673d0e0a95642fe86e62c14b7dc7b;hp=0aa5cee7966124ae41666b6333016cf13c372ee8;hpb=939378c3ca5ecc7866615bc624c0ebfff78d08d2;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 0aa5cee796..f9c510df33 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, @@ -10,32 +10,25 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import static org.mockito.Mockito.doReturn; -import com.google.common.util.concurrent.Futures; 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; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link FlowWriterSequential}. */ @RunWith(MockitoJUnitRunner.class) public class FlowWriterSequentialTest { - - private static final Logger LOG = LoggerFactory.getLogger(FlowWriterSequentialTest.class); private static final int FLOWS_PER_DPN = 100; @Mock @@ -43,36 +36,36 @@ public class FlowWriterSequentialTest { @Mock private ExecutorService mockFlowPusher; @Mock - private WriteTransaction wTx; + private WriteTransaction writeTransaction; private FlowWriterSequential flowWriterSequential; @Before - public void setUp() throws Exception { + public void setUp() { - doReturn(wTx).when(mockDataBroker).newWriteOnlyTransaction(); - Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(writeTransaction).when(mockDataBroker).newWriteOnlyTransaction(); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); - 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, true); - Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).put(Matchers.any(), Matchers.>any(), Matchers.any(), Matchers.anyBoolean()); + public void testAddFlows() { + flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short) 0, (short) 1, true); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any()); } @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()); + public void testDeleteFlows() { + 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 +}