BUG-4118: Li:backward compatibility - rpcs - stats services
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightFlowStatisticsServiceImpl1Test.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 java.util.concurrent.Future;
12 import org.junit.Test;
13 import org.mockito.ArgumentCaptor;
14 import org.mockito.Captor;
15 import org.mockito.Mockito;
16 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
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.GetAllFlowStatisticsFromFlowTableInputBuilder;
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.GetFlowStatisticsFromFlowTableInputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
24 import org.opendaylight.yangtools.yang.common.RpcResult;
25
26 /**
27  * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing)
28  */
29 public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsServiceTest {
30
31     @Captor
32     private ArgumentCaptor<MultipartRequestInput> requestInput;
33
34     private AbstractRequestContext<Object> rqContext;
35
36     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
37
38     public void setUp() {
39         flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(rqContextStack, deviceContext);
40
41         rqContext = new AbstractRequestContext<Object>(42L) {
42             @Override
43             public void close() {
44                 //NOOP
45             }
46         };
47         Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
48     }
49
50     @Test(expected = IllegalAccessError.class)
51     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
52         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
53                 .setNode(createNodeRef("unitProt:123"))
54                 .setTableId(new TableId((short) 1));
55
56         flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
57     }
58
59     @Test(expected = IllegalAccessError.class)
60     public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
61         GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
62                 .setNode(createNodeRef("unitProt:123"))
63                 .setTableId(new TableId((short) 1));
64
65         flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
66     }
67
68     @Test(expected = IllegalAccessError.class)
69     public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
70         GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
71                 .setNode(createNodeRef("unitProt:123"));
72
73         flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
74     }
75
76     @Test(expected = IllegalAccessError.class)
77     public void testGetFlowStatisticsFromFlowTable() throws Exception {
78         GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
79                 .setNode(createNodeRef("unitProt:123"))
80                 .setPriority(5);
81
82         final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
83                 = flowStatisticsService.getFlowStatisticsFromFlowTable(input.build());
84     }
85 }