X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2FStatisticsContextImplTest.java;h=7154e7742312d8a020eb8afb1567bd91267fd279;hb=ccd98d1fef61f9adf810e117e090560f16a8e3c4;hp=05cd073993a75c3e41d917ab122b48574183a81c;hpb=18dc690ea2106eea6c2111d998581e8ded03231c;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java index 05cd073993..7154e77423 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java @@ -1,19 +1,15 @@ /* + * 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.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -32,9 +28,9 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -48,16 +44,19 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio private static final Long TEST_XID = 55L; private StatisticsContextImpl statisticsContext; + private ConvertorManager convertorManager; @Before public void setUp() throws Exception { - when(mockedDeviceContext.reserveXidForDeviceMessage()).thenReturn(TEST_XID); - when(mockConductor.getDeviceContext(Mockito.any())).thenReturn(mockedDeviceContext); + convertorManager = ConvertorManagerFactory.createDefaultManager(); + when(mockedDeviceInfo.reserveXidForDeviceMessage()).thenReturn(TEST_XID); + Mockito.when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext); + Mockito.when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); initStatisticsContext(); } private void initStatisticsContext() { - statisticsContext = new StatisticsContextImpl(mockedDeviceContext.getDeviceState().getNodeId(), false, mockConductor); + statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, lifecycleService, convertorManager, mockedStatisticsManager); statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService); statisticsContext.setStatisticsGatheringOnTheFlyService(mockedStatisticsOnFlyGatheringService); } @@ -75,7 +74,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio */ @Test public void testClose() throws Exception { - final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceContext.getDeviceState().getNodeId(), false, mockConductor); + final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, lifecycleService, convertorManager, mockedStatisticsManager); final RequestContext requestContext = statisticsContext.createRequestContext(); statisticsContext.close(); try { @@ -100,14 +99,13 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio @Test public void testGatherDynamicData_all() throws Exception { Mockito.reset(mockedDeviceState); - when(mockedDeviceState.getFeatures()).thenReturn(mock(GetFeaturesOutput.class)); when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE); when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(Boolean.TRUE); when(mockedDeviceState.isGroupAvailable()).thenReturn(Boolean.TRUE); when(mockedDeviceState.isMetersAvailable()).thenReturn(Boolean.TRUE); when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE); when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE); - when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII); + when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodeII); initStatisticsContext(); when(mockedStatisticsGatheringService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.any(MultipartType.class)))