Merge "Bug 5591 - Changed DeviceContext to DeviceState in translate methods of Messag...
[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.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
24
25 /**
26  * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods
27  */
28 public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsServiceTest {
29
30     @Mock
31     private OpendaylightFlowStatisticsService flowStatisticsDelegate;
32
33     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
34
35     public void setUp() {
36         flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext);
37         flowStatisticsService.setDelegate(flowStatisticsDelegate);
38     }
39
40     @Test
41     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
42         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
43                 .setNode(createNodeRef("unitProt:123"))
44                 .setTableId(new TableId((short) 1))
45                 .build();
46
47         flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
48         Mockito.verify(flowStatisticsDelegate).getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
49     }
50
51     @Test
52     public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
53         GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
54                 .setNode(createNodeRef("unitProt:123"))
55                 .setTableId(new TableId((short) 1))
56                 .build();
57
58         flowStatisticsService.getAllFlowStatisticsFromFlowTable(input);
59         Mockito.verify(flowStatisticsDelegate).getAllFlowStatisticsFromFlowTable(input);
60     }
61
62     @Test
63     public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
64         GetAllFlowsStatisticsFromAllFlowTablesInput input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
65                 .setNode(createNodeRef("unitProt:123"))
66                 .build();
67
68         flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input);
69         Mockito.verify(flowStatisticsDelegate).getAllFlowsStatisticsFromAllFlowTables(input);
70     }
71
72     @Test
73     public void testGetFlowStatisticsFromFlowTable() throws Exception {
74         GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder()
75                 .setNode(createNodeRef("unitProt:123"))
76                 .setPriority(5)
77                 .build();
78
79         flowStatisticsService.getFlowStatisticsFromFlowTable(input);
80         Mockito.verify(flowStatisticsDelegate).getFlowStatisticsFromFlowTable(input);
81     }
82 }