import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
-import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
+import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImplTest.class);
- private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
- private static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3;
public static final NodeId NODE_ID = new NodeId("ofp-unit-dummy-node-id");
@Mock
@Mock
private DeviceManager deviceManager;
@Mock
- private LifecycleConductor conductor;
- @Mock
private GetFeaturesOutput featuresOutput;
@Mock
private DeviceInitializationPhaseHandler deviceInitializationPhaseHandler;
private DeviceInfo deviceInfo;
@Mock
private DataBroker dataBroker;
+ @Mock
+ private LifecycleService lifecycleService;
private RequestContext<List<MultipartReply>> currentRequestContext;
private StatisticsManagerImpl statisticsManager;
when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
- when(mockedDeviceInfo.getNodeId()).thenReturn(new NodeId("ofp-unit-dummy-node-id"));
+ when(mockedDeviceInfo.getNodeId()).thenReturn(NODE_ID);
when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
Matchers.<StatisticsManagerControlService>any())).thenReturn(serviceControlRegistration);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor, convertorManager);
+ statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, new HashedWheelTimer(), convertorManager);
statisticsManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
- when(conductor.getDeviceContext(deviceInfo)).thenReturn(mockedDeviceContext);
}
@Test
}).when(outboundQueue)
.commitEntry(Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
+ Mockito.when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+ Mockito.when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+
statisticsManager.setDeviceInitializationPhaseHandler(mockedDevicePhaseHandler);
- statisticsManager.onDeviceContextLevelUp(deviceInfo);
- verify(mockedDevicePhaseHandler).onDeviceContextLevelUp(deviceInfo);
+ statisticsManager.onDeviceContextLevelUp(deviceInfo, lifecycleService);
+ verify(mockedDevicePhaseHandler).onDeviceContextLevelUp(deviceInfo, lifecycleService);
}
@Test
when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
Collections.<ItemLifeCycleSource>emptyList());
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
new ChangeStatisticsWorkModeInputBuilder()
.setMode(StatisticsWorkMode.FULLYDISABLED);
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
new ChangeStatisticsWorkModeInputBuilder()
.setMode(StatisticsWorkMode.FULLYDISABLED);
statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
verify(mockedDeviceContext).getDeviceState();
- when(mockedDeviceContext.getDeviceState().isValid()).thenReturn(true);
statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
- when(mockedDeviceContext.getDeviceState().isStatisticsPollingEnabled()).thenReturn(true);
statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
when(statisticsContext.gatherDynamicData()).thenReturn(Futures.immediateCheckedFuture(Boolean.TRUE));