Merge "Add NodeConfiguratorImpl enqueue trace"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightFlowStatisticsServiceImpl3Test.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.statistics.services;
10
11 import org.junit.Test;
12 import org.mockito.Mock;
13 import org.mockito.Mockito;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
26
27 /**
28  * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods.
29  */
30 public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsServiceTest {
31
32     @Mock
33     private OpendaylightFlowStatisticsService flowStatisticsDelegate;
34
35     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
36
37     public void setUp() {
38         final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
39         flowStatisticsService =
40                 OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
41         flowStatisticsService.setDelegate(flowStatisticsDelegate);
42     }
43
44     @Test
45     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() {
46         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input =
47                 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
48                 .setNode(createNodeRef("unitProt:123"))
49                 .setTableId(new TableId((short) 1))
50                 .build();
51
52         flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
53         Mockito.verify(flowStatisticsDelegate).getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
54     }
55
56     @Test
57     public void testGetAllFlowStatisticsFromFlowTable() {
58         GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
59                 .setNode(createNodeRef("unitProt:123"))
60                 .setTableId(new TableId((short) 1))
61                 .build();
62
63         flowStatisticsService.getAllFlowStatisticsFromFlowTable(input);
64         Mockito.verify(flowStatisticsDelegate).getAllFlowStatisticsFromFlowTable(input);
65     }
66
67     @Test
68     public void testGetAllFlowsStatisticsFromAllFlowTables() {
69         GetAllFlowsStatisticsFromAllFlowTablesInput input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
70                 .setNode(createNodeRef("unitProt:123"))
71                 .build();
72
73         flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input);
74         Mockito.verify(flowStatisticsDelegate).getAllFlowsStatisticsFromAllFlowTables(input);
75     }
76
77     @Test
78     public void testGetFlowStatisticsFromFlowTable() {
79         GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder()
80                 .setNode(createNodeRef("unitProt:123"))
81                 .setPriority(5)
82                 .build();
83
84         flowStatisticsService.getFlowStatisticsFromFlowTable(input);
85         Mockito.verify(flowStatisticsDelegate).getFlowStatisticsFromFlowTable(input);
86     }
87 }