X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2FStatisticsGatheringUtilsTest.java;h=ead35ef8a1c59d1265b0190f4bdbb0fc91629167;hb=cfe3a97837951ebbedb337dc988027f10c49f714;hp=5eda472bd06517c5b6df15d252f603da4b24f557;hpb=84e9a29a401256b949527776c345153aaab2b6d1;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java old mode 100644 new mode 100755 index 5eda472bd0..ead35ef8a1 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java @@ -1,57 +1,56 @@ /* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * - * * Copyright (c) 2015 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, - * * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; + import com.google.common.collect.Lists; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; +import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; -import org.opendaylight.openflowplugin.api.openflow.device.TxFacade; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; +import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey; import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry; import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer; -import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory; -import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; @@ -131,12 +130,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - @RunWith(MockitoJUnitRunner.class) public class StatisticsGatheringUtilsTest { @@ -156,46 +154,41 @@ public class StatisticsGatheringUtilsTest { @Mock private DeviceMeterRegistry deviceMeterRegistry; @Mock + private FlowDescriptor flowDescriptor; + @Mock + private FlowId flowId; + @Mock private GetFeaturesOutput features; @Mock - private ReadOnlyTransaction readTx; + private ReadTransaction readTx; @Mock private ConnectionContext connectionAdapter; @Mock - private StatisticsGatherer statisticsService; + private StatisticsGatherer statisticsService; @Mock private DeviceInfo deviceInfo; - @Mock - private TxFacade txFacade; - public StatisticsGatheringUtilsTest() { - OpenflowPortsUtil.init(); - } + private MultipartWriterProvider provider; @Before public void setUp() throws Exception { - when(deviceContext.getDeviceState()).thenReturn(deviceState); when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry); when(deviceContext.getDeviceGroupRegistry()).thenReturn(deviceGroupRegistry); when(deviceContext.getDeviceMeterRegistry()).thenReturn(deviceMeterRegistry); + when(deviceFlowRegistry.retrieveDescriptor(any(FlowRegistryKey.class))).thenReturn(flowDescriptor); + when(deviceContext.getReadTransaction()).thenReturn(readTx); when(deviceContext.getReadTransaction()).thenReturn(readTx); - when(txFacade.getReadTransaction()).thenReturn(readTx); when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionAdapter); - when(connectionAdapter.getNodeId()).thenReturn(DUMMY_NODE_ID); + when(deviceContext.isTransactionsEnabled()).thenReturn(Boolean.TRUE); when(connectionAdapter.getFeatures()).thenReturn(features); when(features.getDatapathId()).thenReturn(BigInteger.ONE); when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); - when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE); when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodePath); when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID); - } - - @After - public void tearDown() throws Exception { - + provider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext); } @Test @@ -204,14 +197,13 @@ public class StatisticsGatheringUtilsTest { final ArgumentCaptor flowPath = ArgumentCaptor.forClass(InstanceIdentifier.class); final ArgumentCaptor flow = ArgumentCaptor.forClass(Flow.class); - StatisticsGatheringUtils.writeFlowStatistics(prepareFlowStatisticsData(), - deviceInfo, deviceContext.getDeviceFlowRegistry(), deviceContext); + provider.lookup(MultipartType.OFPMPFLOW).get().write(prepareFlowStatisticsData().iterator().next(), false); Mockito.verify(deviceContext).writeToTransaction( dataStoreType.capture(), flowPath.capture(), flow.capture()); Assert.assertEquals(LogicalDatastoreType.OPERATIONAL, dataStoreType.getValue()); final InstanceIdentifier flowCapableNodePath = flowPath.getValue(); - Assert.assertEquals(DUMMY_NODE_ID, flowCapableNodePath.firstKeyOf(Node.class, NodeKey.class).getId()); + Assert.assertEquals(DUMMY_NODE_ID, flowCapableNodePath.firstKeyOf(Node.class).getId()); Assert.assertEquals(42, flow.getValue().getTableId().intValue()); } @@ -251,11 +243,12 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); final InstanceIdentifier groupPath = dummyNodePath.augmentation(FlowCapableNode.class) - .child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue))) + .child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn + .opendaylight.group.types.rev131018.GroupId(groupIdValue))) .augmentation(NodeGroupStatistics.class) .child(GroupStatistics.class); - verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), - Matchers.eq(groupPath), Matchers.any(GroupStatistics.class)); + verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), + eq(groupPath), any(GroupStatistics.class)); } @Test @@ -279,14 +272,16 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); - final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue); - final KeyedInstanceIdentifier groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId)); + final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId = + new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue); + final KeyedInstanceIdentifier groupPath = + dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId)); - verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.> any()); - verify(deviceGroupRegistry).removeMarked(); + verify(deviceContext, Mockito.never()).addDeleteToTxChain(eq(LogicalDatastoreType.OPERATIONAL), + ArgumentMatchers.>any()); verify(deviceGroupRegistry).store(storedGroupId); - verify(txFacade).writeToTransaction( - Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(Group.class)); + verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), + eq(groupPath), any(Group.class)); } @Test @@ -316,11 +311,12 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); final InstanceIdentifier meterPath = dummyNodePath.augmentation(FlowCapableNode.class) - .child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue))) + .child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn + .opendaylight.meter.types.rev130918.MeterId(meterIdValue))) .augmentation(NodeMeterStatistics.class) .child(MeterStatistics.class); - verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), - Matchers.eq(meterPath), Matchers.any(MeterStatistics.class)); + verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), + eq(meterPath), any(MeterStatistics.class)); } @Test @@ -340,13 +336,14 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); final InstanceIdentifier portPath = dummyNodePath - .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))) + .child(NodeConnector.class, + new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))) .augmentation(FlowCapableNodeConnectorStatisticsData.class) .child(FlowCapableNodeConnectorStatistics.class); - verify(txFacade).writeToTransaction( - Matchers.eq(LogicalDatastoreType.OPERATIONAL), - Matchers.eq(portPath), - Matchers.any(FlowCapableNodeConnectorStatistics.class)); + verify(deviceContext).writeToTransaction( + eq(LogicalDatastoreType.OPERATIONAL), + eq(portPath), + any(FlowCapableNodeConnectorStatistics.class)); } @Test @@ -373,10 +370,10 @@ public class StatisticsGatheringUtilsTest { .child(Table.class, new TableKey((short) 0)) .augmentation(FlowTableStatisticsData.class) .child(FlowTableStatistics.class); - verify(txFacade).writeToTransaction( - Matchers.eq(LogicalDatastoreType.OPERATIONAL), - Matchers.eq(tablePath), - Matchers.any(FlowTableStatistics.class)); + verify(deviceContext).writeToTransaction( + eq(LogicalDatastoreType.OPERATIONAL), + eq(tablePath), + any(FlowTableStatistics.class)); } @Test @@ -404,32 +401,34 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); final KeyedInstanceIdentifier queuePath = dummyNodePath - .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))) + .child(NodeConnector.class, + new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))) .augmentation(FlowCapableNodeConnector.class) .child(Queue.class, new QueueKey(new QueueId(queueIdValue))); - verify(txFacade).writeToTransaction( - Matchers.eq(LogicalDatastoreType.OPERATIONAL), - Matchers.eq(queuePath), - Matchers.any(Queue.class)); + verify(deviceContext).writeToTransaction( + eq(LogicalDatastoreType.OPERATIONAL), + eq(queuePath), + any(Queue.class)); } @Test public void testGatherStatistics_flow() throws Exception { final short tableId = 0; final MultipartType type = MultipartType.OFPMPFLOW; - when(deviceFlowRegistry.storeIfNecessary(Matchers.any(FlowRegistryKey.class), Matchers.anyShort())) - .thenReturn(new FlowId("openflow:21")); - final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); + final InstanceIdentifier nodePath = + deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final TableBuilder tableDataBld = new TableBuilder(); tableDataBld.setId(tableId); final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt); - when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture); + doReturn(FluentFutures.immediateFluentFuture(flowNodeOpt)).when(readTx) + .read(LogicalDatastoreType.OPERATIONAL, nodePath); + when(flowDescriptor.getFlowId()).thenReturn(flowId); - final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld = + final org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder() .setMatchEntry(Collections.emptyList()); final FlowStatsBuilder flowStatsBld = new FlowStatsBuilder() @@ -453,12 +452,17 @@ public class StatisticsGatheringUtilsTest { final FlowBuilder flowBld = new FlowBuilder() .setTableId((short) 0) .setMatch(new MatchBuilder().build()); - final KeyedInstanceIdentifier flowPath = dummyNodePath.augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey((short) 0)) - .child(Flow.class, new FlowKey(new FlowId("openflow:21"))); - verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.>any()); - verify(deviceFlowRegistry).storeIfNecessary(FlowRegistryKeyFactory.create(flowBld.build()), (short) 0); - verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(flowPath), Matchers.any(Flow.class)); + final KeyedInstanceIdentifier tablePath = dummyNodePath.augmentation(FlowCapableNode.class) + .child(Table.class, new TableKey((short) 0)); + final KeyedInstanceIdentifier flowPath = tablePath.child(Flow.class, new FlowKey(flowId)); + + verify(deviceContext, Mockito.never()).addDeleteToTxChain(eq(LogicalDatastoreType.OPERATIONAL), + ArgumentMatchers.>any()); + + final InOrder inOrder = Mockito.inOrder(deviceContext); + inOrder.verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), + any(), + any()); } @Test @@ -473,7 +477,8 @@ public class StatisticsGatheringUtilsTest { final MultipartReplyMeterConfigBuilder mpReplyMeterConfigBld = new MultipartReplyMeterConfigBuilder(); mpReplyMeterConfigBld.setMeterConfig(Lists.newArrayList(meterConfigBld.build())); - final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld = new MultipartReplyMeterConfigCaseBuilder(); + final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld = + new MultipartReplyMeterConfigCaseBuilder(); mpReplyMeterConfigCaseBld.setMultipartReplyMeterConfig(mpReplyMeterConfigBld.build()); final MultipartReply meterConfigUpdated = assembleMPReplyMessage(type, mpReplyMeterConfigCaseBld.build()); @@ -485,27 +490,34 @@ public class StatisticsGatheringUtilsTest { new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue); final KeyedInstanceIdentifier meterPath = dummyNodePath.augmentation(FlowCapableNode.class) .child(Meter.class, new MeterKey(meterId)); - verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.>any()); + verify(deviceContext, Mockito.never()).addDeleteToTxChain(eq(LogicalDatastoreType.OPERATIONAL), + ArgumentMatchers.>any()); verify(deviceMeterRegistry).store(meterId); - verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class)); + verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), + eq(meterPath), any(Meter.class)); } - private void fireAndCheck(final MultipartType type, final List statsData) throws InterruptedException, ExecutionException, TimeoutException { - when(statisticsService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.eq(type))) + private void fireAndCheck(final MultipartType type, final List statsData) + throws InterruptedException, ExecutionException, TimeoutException { + when(statisticsService.getStatisticsOfType(any(EventIdentifier.class),eq(type))) .thenReturn(Futures.immediateFuture(RpcResultBuilder.success(statsData).build())); final ListenableFuture gatherStatisticsResult = StatisticsGatheringUtils.gatherStatistics( - statisticsService, - deviceInfo, - type, - txFacade, - deviceContext, - false); - Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS).booleanValue()); - verify(txFacade).submitTransaction(); + statisticsService, + deviceInfo, + type, + deviceContext, + deviceContext, + ConvertorManagerFactory.createDefaultManager(), + provider, + MoreExecutors.newDirectExecutorService()); + + Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS)); + verify(deviceContext).submitTransaction(); } - private static MultipartReplyMessage assembleMPReplyMessage(final MultipartType type, final MultipartReplyBody mpReplyGroupCaseBld) { + private static MultipartReplyMessage assembleMPReplyMessage(final MultipartType type, + final MultipartReplyBody mpReplyGroupCaseBld) { return new MultipartReplyMessageBuilder() .setMultipartReplyBody(mpReplyGroupCaseBld) .setType(type) @@ -515,30 +527,27 @@ public class StatisticsGatheringUtilsTest { } private static BucketStats createBucketStat(final long byteCount, final long packetCount) { - return new BucketStatsBuilder().setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build(); + return new BucketStatsBuilder() + .setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build(); } @Test public void testDeleteAllKnownFlows() throws Exception { final short tableId = 0; - when(deviceState.deviceSynchronized()).thenReturn(true); - final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); + final InstanceIdentifier nodePath = + deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final TableBuilder tableDataBld = new TableBuilder(); tableDataBld.setId(tableId); final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt); - when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture); - final KeyedInstanceIdentifier tablePath = deviceInfo.getNodeInstanceIdentifier() - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)); - - StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, - deviceContext.getDeviceFlowRegistry(), txFacade); - - verify(txFacade).writeToTransaction( - LogicalDatastoreType.OPERATIONAL, - tablePath, - tableDataBld.setFlow(Collections.emptyList()).build()); + doReturn(FluentFutures.immediateFluentFuture(flowNodeOpt)).when(readTx) + .read(LogicalDatastoreType.OPERATIONAL, nodePath); + StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext, deviceInfo.getNodeInstanceIdentifier() + .augmentation(FlowCapableNode.class), deviceFlowRegistry); + + verify(deviceContext).isTransactionsEnabled(); + verify(deviceContext).getReadTransaction(); + verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); } }