X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2Fdirect%2FAbstractDirectStatisticsServiceTest.java;h=1df959a2cc3e30427da82e1ef3104b02b6de9a34;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=ac20355da025133340165830708bff5620a7dc60;hpb=6e2627630ebabb37526133a13deeb62adcc85d35;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java old mode 100644 new mode 100755 index ac20355da0..1df959a2cc --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java @@ -8,6 +8,11 @@ package org.opendaylight.openflowplugin.impl.statistics.services.direct; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.when; + +import java.math.BigInteger; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,9 +28,15 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary; import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; +import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; +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.MessageSpy; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; -import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; @@ -37,21 +48,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -import java.math.BigInteger; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - @RunWith(MockitoJUnitRunner.class) public abstract class AbstractDirectStatisticsServiceTest { protected static final Long PORT_NO = 1L; protected static final BigInteger DATAPATH_ID = BigInteger.TEN; protected static final short OF_VERSION = OFConstants.OFP_VERSION_1_3; - protected static final String NODE_ID = "openflow:1"; + protected static final String NODE_ID = "openflow:10"; @Mock protected RequestContextStack requestContextStack; @Mock + protected DeviceFlowRegistry deviceFlowRegistry; + @Mock + protected DeviceGroupRegistry deviceGroupRegistry; + @Mock + protected DeviceMeterRegistry deviceMeterRegistry; + @Mock protected DeviceContext deviceContext; @Mock protected ConnectionContext connectionContext; @@ -69,9 +81,13 @@ public abstract class AbstractDirectStatisticsServiceTest { protected DeviceState deviceState; @Mock protected DeviceInfo deviceInfo; + @Mock + protected GetFeaturesOutput getFeaturesOutput; protected NodeConnectorId nodeConnectorId; protected KeyedInstanceIdentifier nodeInstanceIdentifier; + protected ConvertorManager convertorManager; + protected MultipartWriterProvider multipartWriterProvider; protected static NodeRef createNodeRef(String nodeIdValue) { InstanceIdentifier nodePath = InstanceIdentifier.create(Nodes.class) @@ -82,8 +98,6 @@ public abstract class AbstractDirectStatisticsServiceTest { @Before public void init() throws Exception { - OpenflowPortsUtil.init(); - nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo( DATAPATH_ID, PORT_NO, OpenflowVersion.get(OF_VERSION)); @@ -91,20 +105,27 @@ public abstract class AbstractDirectStatisticsServiceTest { .create(Nodes.class) .child(Node.class, new NodeKey(new NodeId(NODE_ID))); + convertorManager = ConvertorManagerFactory.createDefaultManager(); + lenient().when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry); + lenient().when(deviceContext.getDeviceGroupRegistry()).thenReturn(deviceGroupRegistry); + lenient().when(deviceContext.getDeviceMeterRegistry()).thenReturn(deviceMeterRegistry); when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext); when(deviceContext.getMessageSpy()).thenReturn(messageSpy); - when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector); - when(deviceContext.oook()).thenReturn(translatorLibrary); - when(deviceContext.getDeviceState()).thenReturn(deviceState); + lenient().when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector); + lenient().when(deviceContext.oook()).thenReturn(translatorLibrary); + lenient().when(deviceContext.getDeviceState()).thenReturn(deviceState); when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier); - when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID)); + lenient().when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID)); when(deviceInfo.getVersion()).thenReturn(OF_VERSION); when(deviceInfo.getDatapathId()).thenReturn(DATAPATH_ID); + lenient().when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION); + lenient().when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID); when(connectionContext.getFeatures()).thenReturn(features); - when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider); - when(features.getVersion()).thenReturn(OF_VERSION); - when(features.getDatapathId()).thenReturn(DATAPATH_ID); + lenient().when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider); + lenient().when(features.getVersion()).thenReturn(OF_VERSION); + lenient().when(features.getDatapathId()).thenReturn(DATAPATH_ID); + multipartWriterProvider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext); setUp(); } @@ -118,4 +139,4 @@ public abstract class AbstractDirectStatisticsServiceTest { @Test public abstract void testStoreStatistics() throws Exception; -} \ No newline at end of file +}