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;
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.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;
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;
@Mock
protected DeviceState deviceState;
@Mock
+ protected DeviceInfo deviceInfo;
+ @Mock
protected GetFeaturesOutput getFeaturesOutput;
protected NodeConnectorId nodeConnectorId;
protected KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
+ protected ConvertorManager convertorManager;
+ protected MultipartWriterProvider multipartWriterProvider;
protected static NodeRef createNodeRef(String nodeIdValue) {
InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
@Before
public void init() throws Exception {
- OpenflowPortsUtil.init();
-
nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(
DATAPATH_ID, PORT_NO, OpenflowVersion.get(OF_VERSION));
.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);
- when(deviceContext.getDeviceState()).thenReturn(deviceState);
- when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
- when(deviceState.getNodeId()).thenReturn(new NodeId(NODE_ID));
- when(deviceState.getVersion()).thenReturn(OF_VERSION);
- when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
- when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION);
- when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID);
+ 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);
+ 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();
}
@Test
public abstract void testStoreStatistics() throws Exception;
-}
\ No newline at end of file
+}