b565c379a61438d48cfa4ae1032af2e572dc1d16
[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 = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
40         flowStatisticsService.setDelegate(flowStatisticsDelegate);
41     }
42
43     @Test
44     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
45         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
46                 .setNode(createNodeRef("unitProt:123"))
47                 .setTableId(new TableId((short) 1))
48                 .build();
49
50         flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
51         Mockito.verify(flowStatisticsDelegate).getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
52     }
53
54     @Test
55     public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
56         GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
57                 .setNode(createNodeRef("unitProt:123"))
58                 .setTableId(new TableId((short) 1))
59                 .build();
60
61         flowStatisticsService.getAllFlowStatisticsFromFlowTable(input);
62         Mockito.verify(flowStatisticsDelegate).getAllFlowStatisticsFromFlowTable(input);
63     }
64
65     @Test
66     public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
67         GetAllFlowsStatisticsFromAllFlowTablesInput input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
68                 .setNode(createNodeRef("unitProt:123"))
69                 .build();
70
71         flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input);
72         Mockito.verify(flowStatisticsDelegate).getAllFlowsStatisticsFromAllFlowTables(input);
73     }
74
75     @Test
76     public void testGetFlowStatisticsFromFlowTable() throws Exception {
77         GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder()
78                 .setNode(createNodeRef("unitProt:123"))
79                 .setPriority(5)
80                 .build();
81
82         flowStatisticsService.getFlowStatisticsFromFlowTable(input);
83         Mockito.verify(flowStatisticsDelegate).getFlowStatisticsFromFlowTable(input);
84     }
85 }