e3ddf0cf6e2eadbc9dbbd5f0ddcf6b6f93a93b79
[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 package org.opendaylight.openflowplugin.impl.statistics.services;
9
10 import java.util.concurrent.Future;
11 import org.junit.Test;
12 import org.mockito.ArgumentCaptor;
13 import org.mockito.Captor;
14 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
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 import org.opendaylight.yangtools.yang.common.Uint16;
26 import org.opendaylight.yangtools.yang.common.Uint32;
27 import org.opendaylight.yangtools.yang.common.Uint8;
28
29 /**
30  * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing).
31  */
32 public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsServiceTest {
33
34     @Captor
35     private ArgumentCaptor<MultipartRequestInput> requestInput;
36
37     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
38
39     @Override
40     public void setUp() {
41         final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
42         flowStatisticsService =
43                 OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
44
45         AbstractRequestContext<Object> rqContext = new AbstractRequestContext<>(Uint32.valueOf(42)) {
46             @Override
47             public void close() {
48                 //NOOP
49             }
50         };
51         //Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
52     }
53
54     @Test(expected = IllegalAccessError.class)
55     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() {
56         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
57                 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
58                 .setNode(createNodeRef("unitProt:123"))
59                 .setTableId(new TableId(Uint8.ONE));
60
61         flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
62     }
63
64     @Test(expected = IllegalAccessError.class)
65     public void testGetAllFlowStatisticsFromFlowTable() {
66         GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
67                 .setNode(createNodeRef("unitProt:123"))
68                 .setTableId(new TableId(Uint8.ONE));
69
70         flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
71     }
72
73     @Test(expected = IllegalAccessError.class)
74     public void testGetAllFlowsStatisticsFromAllFlowTables() {
75         GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
76                 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
77                 .setNode(createNodeRef("unitProt:123"));
78
79         flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
80     }
81
82     @Test(expected = IllegalAccessError.class)
83     public void testGetFlowStatisticsFromFlowTable() {
84         GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
85                 .setNode(createNodeRef("unitProt:123"))
86                 .setPriority(Uint16.valueOf(5));
87
88         final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
89                 = flowStatisticsService.getFlowStatisticsFromFlowTable(input.build());
90     }
91 }