2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.statistics;
11 import static org.mockito.Mockito.verify;
12 import static org.mockito.Mockito.when;
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import java.util.function.Supplier;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mock;
21 import org.mockito.runners.MockitoJUnitRunner;
23 @RunWith(MockitoJUnitRunner.class)
24 public class StatisticsPollingServiceTest {
26 private TimeCounter timeCounter;
28 private Supplier<ListenableFuture<Boolean>> gatheringSupplier;
30 private StatisticsPollingService statisticsPollingService;
33 public void setUp() throws Exception {
34 when(timeCounter.getAverageTimeBetweenMarks()).thenReturn(15000L);
35 when(gatheringSupplier.get()).thenReturn(Futures.immediateFuture(true));
36 statisticsPollingService = new StatisticsPollingService(
37 timeCounter, 10000, 12000,
42 public void startUp() throws Exception {
43 statisticsPollingService.startUp();
44 verify(timeCounter).markStart();
48 public void runOneIteration() throws Exception {
49 statisticsPollingService.runOneIteration();
50 verify(gatheringSupplier).get();
51 verify(timeCounter).addTimeMark();
55 public void scheduler() throws Exception {
56 statisticsPollingService.scheduler();
57 verify(timeCounter).getAverageTimeBetweenMarks();