Merge "Bug 6088 - Threads problem on gathering statistics"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / MultipartRequestOnTheFlyCallbackTest.java
index 8d41070cbddac264106e1c63822d298ffd5cbd83..7b3bcd26615e29838ce4bd00e9b56e03f9b68950 100644 (file)
@@ -8,6 +8,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -28,6 +29,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 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.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -88,6 +90,8 @@ public class MultipartRequestOnTheFlyCallbackTest {
     @Mock
     private DeviceState mockedDeviceState;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private GetFeaturesOutput mocketGetFeaturesOutput;
     @Mock
     private DeviceFlowRegistry mockedFlowRegistry;
@@ -109,15 +113,20 @@ public class MultipartRequestOnTheFlyCallbackTest {
         when(mockedFeaturesReply.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
 
         when(mocketGetFeaturesOutput.getTables()).thenReturn(tableId);
+        when(mocketGetFeaturesOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        when(mocketGetFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
-        when(mockedDeviceState.getFeatures()).thenReturn(mocketGetFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
         when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
+        when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
+
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(mockedFlowRegistry);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         flowNodeBuilder.setTable(Collections.<Table> emptyList());
         final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
@@ -132,7 +141,9 @@ public class MultipartRequestOnTheFlyCallbackTest {
                 //NOOP
             }
         };
-        multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class, mockedDeviceContext, dummyEventIdentifier);
+        multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class,
+                mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceInfo,
+                mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext);
     }
 
 
@@ -199,7 +210,7 @@ public class MultipartRequestOnTheFlyCallbackTest {
                 .setMultipartReplyBody(multipartReplyFlowCaseBuilder.build())
                 .setXid(21L);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier()
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         final TableBuilder tableDataBld = new TableBuilder();