93ebb905b6c214a842e1771d4667451cf1d055d8
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / ModelDrivenSwitchImplTest.java
1 /**
2  * Copyright (c) 2013 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.openflow.md.core.sal;
10
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.Set;
16 import java.util.concurrent.ExecutionException;
17 import java.util.concurrent.Executors;
18
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.mockito.Matchers;
23 import org.mockito.Mock;
24 import org.mockito.Mockito;
25 import org.mockito.runners.MockitoJUnitRunner;
26 import org.opendaylight.controller.sal.common.util.Rpcs;
27 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
28 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
29 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
30 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
31 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
32 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
33 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
34 import org.opendaylight.openflowplugin.statistics.MessageSpy;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort.PortNumber;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
137 import org.opendaylight.yangtools.yang.binding.DataContainer;
138 import org.opendaylight.yangtools.yang.common.RpcError;
139 import org.opendaylight.yangtools.yang.common.RpcResult;
140
141 import com.google.common.util.concurrent.Futures;
142 import com.google.common.util.concurrent.MoreExecutors;
143
144 /**
145  * simple NPE smoke test
146  */
147 @RunWith(MockitoJUnitRunner.class)
148 public class ModelDrivenSwitchImplTest {
149
150     private ModelDrivenSwitchImpl mdSwitchOF10;
151     private ModelDrivenSwitchImpl mdSwitchOF13;
152
153     @Mock
154     private SessionContext context;
155     @Mock
156     private ConnectionConductor conductor;
157     @Mock
158     private IMessageDispatchService messageDispatchService;
159     @Mock
160     private GetFeaturesOutput features;
161     @Mock
162     private MessageSpy<DataContainer> messageSpy;
163
164     /**
165      * @throws java.lang.Exception
166      */
167     @Before
168     public void setUp() throws Exception {
169         Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
170         Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
171         Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
172                 .thenReturn(OFConstants.OFP_VERSION_1_3);
173         Mockito.when(context.getFeatures()).thenReturn(features);
174         Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
175         
176         OFSessionUtil.getSessionManager().setRpcPool(MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)));
177         OFSessionUtil.getSessionManager().setMessageSpy(messageSpy);
178         OpenflowPortsUtil.init();
179
180         mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
181         mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
182     }
183
184     /**
185      * Test method for
186      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
187      * .
188      * @throws ExecutionException 
189      * @throws InterruptedException 
190      */
191     @Test
192     public void testAddFlow() throws InterruptedException, ExecutionException {
193         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
194         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
195         Set<RpcError> errorSet = Collections.emptySet();
196         RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
197         Mockito.when(
198                 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
199                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
200
201         AddFlowInputBuilder input = new AddFlowInputBuilder();
202         input.setMatch(createMatch());
203
204         Mockito.when(features.getVersion()).thenReturn((short)1);
205         mdSwitchOF10.addFlow(input.build()).get();
206         Mockito.when(features.getVersion()).thenReturn((short)4);
207         mdSwitchOF13.addFlow(input.build()).get();
208         Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
209                 Matchers.any(FlowModInput.class),
210                 Matchers.any(SwitchConnectionDistinguisher.class));
211     }
212
213     /**
214      * Test method for
215      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
216      * .
217      * @throws ExecutionException 
218      * @throws InterruptedException 
219      */
220     @Test
221     public void testRemoveFlow() throws InterruptedException, ExecutionException {
222         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
223         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
224         Set<RpcError> errorSet = Collections.emptySet();
225         RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
226         Mockito.when(
227                 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
228                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
229
230         RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
231         input.setMatch(createMatch());
232
233         Mockito.when(features.getVersion()).thenReturn((short)1);
234         mdSwitchOF10.removeFlow(input.build()).get();
235         Mockito.when(features.getVersion()).thenReturn((short)4);
236         mdSwitchOF13.removeFlow(input.build()).get();
237         Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
238                 Matchers.any(FlowModInput.class),
239                 Matchers.any(SwitchConnectionDistinguisher.class));
240         
241     }
242
243     /**
244      * Test method for
245      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
246      * .
247      * @throws ExecutionException 
248      * @throws InterruptedException 
249      */
250     @Test
251     public void testUpdateFlow() throws InterruptedException, ExecutionException {
252         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
253         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
254         Set<RpcError> errorSet = Collections.emptySet();
255         RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
256         Mockito.when(
257                 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
258                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
259
260         UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
261         UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
262         updatedFlow.setBarrier(false);
263         updatedFlow.setMatch(createMatch());
264         updatedFlow.setPriority(65);
265         updatedFlow.setFlags(new FlowModFlags(true, false, true, false, true));
266         input.setUpdatedFlow(updatedFlow.build());
267         OriginalFlowBuilder originalFlowBuilder = new OriginalFlowBuilder();
268         originalFlowBuilder.setMatch(createMatch());
269         originalFlowBuilder.setPriority(65);
270         originalFlowBuilder.setFlags(new FlowModFlags(true, false, true, false, true));
271         input.setOriginalFlow(originalFlowBuilder.build());
272         
273         Mockito.when(features.getVersion()).thenReturn((short)1);
274         mdSwitchOF10.updateFlow(input.build()).get();
275         Mockito.when(features.getVersion()).thenReturn((short)4);
276         mdSwitchOF13.updateFlow(input.build()).get();
277         Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
278                 Matchers.any(FlowModInput.class),
279                 Matchers.any(SwitchConnectionDistinguisher.class));
280     }
281     
282     /**
283      * Test method for
284      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
285      * addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
286      * AddGroupInput)}
287      * .
288      * @throws ExecutionException 
289      * @throws InterruptedException 
290      */
291     @Test
292     public void testAddGroup() throws InterruptedException, ExecutionException {
293         UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
294         updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
295         Set<RpcError> errorSet = Collections.emptySet();
296         RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
297         Mockito.when(
298                 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
299                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
300
301         AddGroupInputBuilder input = new AddGroupInputBuilder();
302         input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
303         input.setGroupId(new GroupId(789L));
304
305         mdSwitchOF10.addGroup(input.build()).get();
306         mdSwitchOF13.addGroup(input.build()).get();
307         Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
308                 Matchers.any(GroupModInput.class),
309                 Matchers.any(SwitchConnectionDistinguisher.class));
310     }
311     
312     /**
313      * Test method for
314      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
315      * updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
316      * UpdateGroupInput)}
317      * .
318      * @throws ExecutionException 
319      * @throws InterruptedException 
320      */
321     @Test
322     public void testUpdateGroup() throws InterruptedException, ExecutionException {
323         UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
324         updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
325         Set<RpcError> errorSet = Collections.emptySet();
326         RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
327         Mockito.when(
328                 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
329                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
330
331         UpdateGroupInputBuilder input = new UpdateGroupInputBuilder();
332         UpdatedGroupBuilder updatedGroupBuilder = new UpdatedGroupBuilder();
333         updatedGroupBuilder.setGroupId(new GroupId(789L));
334         updatedGroupBuilder.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
335         input.setUpdatedGroup(updatedGroupBuilder.build());
336
337         mdSwitchOF10.updateGroup(input.build()).get();
338         mdSwitchOF13.updateGroup(input.build()).get();
339         Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
340                 Matchers.any(GroupModInput.class),
341                 Matchers.any(SwitchConnectionDistinguisher.class));
342     }
343     
344     /**
345      * Test method for
346      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
347      * removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
348      * RemoveGroupInput)}
349      * .
350      * @throws ExecutionException 
351      * @throws InterruptedException 
352      */
353     @Test
354     public void testRemoveGroup() throws InterruptedException, ExecutionException {
355         UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
356         updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
357         Set<RpcError> errorSet = Collections.emptySet();
358         RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
359         Mockito.when(
360                 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
361                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
362
363         RemoveGroupInputBuilder input = new RemoveGroupInputBuilder();
364         input.setGroupId(new GroupId(789L));
365         input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
366
367         mdSwitchOF10.removeGroup(input.build()).get();
368         mdSwitchOF13.removeGroup(input.build()).get();
369         Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
370                 Matchers.any(GroupModInput.class),
371                 Matchers.any(SwitchConnectionDistinguisher.class));
372     }
373     
374     /**
375      * Test method for
376      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
377      * addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
378      * AddMeterInput)}
379      * .
380      * @throws ExecutionException 
381      * @throws InterruptedException 
382      */
383     @Test
384     public void testAddMeter() throws InterruptedException, ExecutionException {
385         UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
386         updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
387         Set<RpcError> errorSet = Collections.emptySet();
388         RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
389         Mockito.when(
390                 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
391                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
392
393         AddMeterInputBuilder input = new AddMeterInputBuilder();
394         input.setMeterId(new MeterId(78L));
395
396         mdSwitchOF10.addMeter(input.build()).get();
397         mdSwitchOF13.addMeter(input.build()).get();
398         Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
399                 Matchers.any(MeterModInput.class),
400                 Matchers.any(SwitchConnectionDistinguisher.class));
401     }
402     
403     /**
404      * Test method for
405      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
406      * updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
407      * UpdateMeterInput)}
408      * .
409      * @throws ExecutionException 
410      * @throws InterruptedException 
411      */
412     @Test
413     public void testUpdtateMeter() throws InterruptedException, ExecutionException {
414         UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
415         updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
416         Set<RpcError> errorSet = Collections.emptySet();
417         RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
418         Mockito.when(
419                 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
420                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
421
422         UpdateMeterInputBuilder input = new UpdateMeterInputBuilder();
423         UpdatedMeterBuilder updatedMeterBuilder = new UpdatedMeterBuilder();
424         updatedMeterBuilder.setMeterId(new MeterId(89L));
425         updatedMeterBuilder.setBarrier(false);
426         input.setUpdatedMeter(updatedMeterBuilder.build());
427
428         mdSwitchOF10.updateMeter(input.build()).get();
429         mdSwitchOF13.updateMeter(input.build()).get();
430         Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
431                 Matchers.any(MeterModInput.class),
432                 Matchers.any(SwitchConnectionDistinguisher.class));
433     }
434     
435     /**
436      * Test method for
437      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
438      * removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
439      * RemoveMeterInput)}
440      * .
441      * @throws ExecutionException 
442      * @throws InterruptedException 
443      */
444     @Test
445     public void testRemoveMeter() throws InterruptedException, ExecutionException {
446         UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
447         updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
448         Set<RpcError> errorSet = Collections.emptySet();
449         RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
450         Mockito.when(
451                 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
452                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
453
454         RemoveMeterInputBuilder input = new RemoveMeterInputBuilder();
455         input.setMeterId(new MeterId(89L));
456         
457         mdSwitchOF10.removeMeter(input.build()).get();
458         mdSwitchOF13.removeMeter(input.build()).get();
459         Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
460                 Matchers.any(MeterModInput.class),
461                 Matchers.any(SwitchConnectionDistinguisher.class));
462     }
463     
464     /**
465      * Test method for
466      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
467      * getAllGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
468      * GetAllGroupStatisticsInput)}
469      * .
470      * @throws ExecutionException 
471      * @throws InterruptedException 
472      */
473     @Test
474     public void testGetAllGroupStatistics() throws InterruptedException, ExecutionException {
475         GetAllGroupStatisticsOutputBuilder getAllGroupStatistcsOutput = new GetAllGroupStatisticsOutputBuilder();
476         getAllGroupStatistcsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
477         Set<RpcError> errorSet = Collections.emptySet();
478         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
479         Mockito.when(
480                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
481                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
482
483         GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
484
485         mdSwitchOF10.getAllGroupStatistics(input.build()).get();
486         mdSwitchOF13.getAllGroupStatistics(input.build()).get();
487         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
488                 Matchers.any(MultipartRequestInput.class),
489                 Matchers.any(SwitchConnectionDistinguisher.class));
490     }
491     
492     /**
493      * Test method for
494      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
495      * getGroupDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
496      * GetGroupDescriptionInput)}
497      * .
498      * @throws ExecutionException 
499      * @throws InterruptedException 
500      */
501     @Test
502     public void testGetGroupDescription() throws InterruptedException, ExecutionException {
503         GetGroupDescriptionOutputBuilder getGroupDescOutput = new GetGroupDescriptionOutputBuilder();
504         getGroupDescOutput.setTransactionId(new TransactionId(new BigInteger("42")));
505         Set<RpcError> errorSet = Collections.emptySet();
506         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
507         Mockito.when(
508                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
509                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
510
511         GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
512
513         mdSwitchOF10.getGroupDescription(input.build()).get();
514         mdSwitchOF13.getGroupDescription(input.build()).get();
515         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
516                 Matchers.any(MultipartRequestInput.class),
517                 Matchers.any(SwitchConnectionDistinguisher.class));
518     }
519     
520     /**
521      * Test method for
522      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
523      * getGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
524      * GetGroupFeaturesInput)}
525      * .
526      * @throws ExecutionException 
527      * @throws InterruptedException 
528      */
529     @Test
530     public void testGetGroupFeatures() throws InterruptedException, ExecutionException {
531         GetGroupFeaturesOutputBuilder getGroupFeaturesOutput = new GetGroupFeaturesOutputBuilder();
532         getGroupFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
533         Set<RpcError> errorSet = Collections.emptySet();
534         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
535         Mockito.when(
536                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
537                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
538
539         GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
540
541         mdSwitchOF10.getGroupFeatures(input.build()).get();
542         mdSwitchOF13.getGroupFeatures(input.build()).get();
543         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
544                 Matchers.any(MultipartRequestInput.class),
545                 Matchers.any(SwitchConnectionDistinguisher.class));
546     }
547     
548     /**
549      * Test method for
550      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
551      * getGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
552      * GetGroupStatisticsInput)}
553      * .
554      * @throws ExecutionException 
555      * @throws InterruptedException 
556      */
557     //TODO GetGroupStatistics why NPE?
558     @Test
559     public void testGetGroupStatistics() throws InterruptedException, ExecutionException {
560         GetGroupStatisticsOutputBuilder getGroupStatsOutput = new GetGroupStatisticsOutputBuilder();
561         getGroupStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
562         Set<RpcError> errorSet = Collections.emptySet();
563         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
564         Mockito.when(
565                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
566                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
567
568         GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder();
569         input.setGroupId(new GroupId(42L));
570
571         mdSwitchOF10.getGroupStatistics(input.build()).get();
572         mdSwitchOF13.getGroupStatistics(input.build()).get();
573         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
574                 Matchers.any(MultipartRequestInput.class),
575                 Matchers.any(SwitchConnectionDistinguisher.class));
576     }
577     
578     /**
579      * Test method for
580      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
581      * getAllMeterConfigStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
582      * GetAllMeterConfigStatisticsInput)}
583      * .
584      * @throws ExecutionException 
585      * @throws InterruptedException 
586      */
587     @Test
588     public void testGetAllMeterConfigStatistics() throws InterruptedException, ExecutionException {
589         GetAllMeterConfigStatisticsOutputBuilder getAllMeterConfigStatsOutput = 
590                 new GetAllMeterConfigStatisticsOutputBuilder();
591         getAllMeterConfigStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
592         Set<RpcError> errorSet = Collections.emptySet();
593         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
594         Mockito.when(
595                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
596                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
597
598         GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
599
600         mdSwitchOF10.getAllMeterConfigStatistics(input.build()).get();
601         mdSwitchOF13.getAllMeterConfigStatistics(input.build()).get();
602         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
603                 Matchers.any(MultipartRequestInput.class),
604                 Matchers.any(SwitchConnectionDistinguisher.class));
605     }
606     
607     /**
608      * Test method for
609      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
610      * getAllMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
611      * GetAllMeterStatisticsInput)}
612      * .
613      * @throws ExecutionException 
614      * @throws InterruptedException 
615      */
616     @Test
617     public void testGetAllMeterStatistics() throws InterruptedException, ExecutionException {
618         GetAllMeterStatisticsOutputBuilder getAllMeterStatisticsOutput = 
619                 new GetAllMeterStatisticsOutputBuilder();
620         getAllMeterStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
621         Set<RpcError> errorSet = Collections.emptySet();
622         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
623         Mockito.when(
624                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
625                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
626
627         GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
628
629         mdSwitchOF10.getAllMeterStatistics(input.build()).get();
630         mdSwitchOF13.getAllMeterStatistics(input.build()).get();
631         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
632                 Matchers.any(MultipartRequestInput.class),
633                 Matchers.any(SwitchConnectionDistinguisher.class));
634     }
635     
636     /**
637      * Test method for
638      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
639      * getMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
640      * GetMeterFeaturesInput)}
641      * .
642      * @throws ExecutionException 
643      * @throws InterruptedException 
644      */
645     @Test
646     public void testGetMeterFeatures() throws InterruptedException, ExecutionException {
647         GetMeterFeaturesOutputBuilder getMeterFeaturesOutput = 
648                 new GetMeterFeaturesOutputBuilder();
649         getMeterFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
650         Set<RpcError> errorSet = Collections.emptySet();
651         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
652         Mockito.when(
653                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
654                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
655
656         GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
657
658         mdSwitchOF10.getMeterFeatures(input.build()).get();
659         mdSwitchOF13.getMeterFeatures(input.build()).get();
660         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
661                 Matchers.any(MultipartRequestInput.class),
662                 Matchers.any(SwitchConnectionDistinguisher.class));
663     }
664     
665     /**
666      * Test method for
667      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
668      * getMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
669      * GetMeterStatisticsInput)}
670      * .
671      * @throws ExecutionException 
672      * @throws InterruptedException 
673      */
674     @Test
675     public void testGetMeterStatistics() throws InterruptedException, ExecutionException {
676         GetMeterStatisticsOutputBuilder getMeterStatsOutput = new GetMeterStatisticsOutputBuilder();
677         getMeterStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
678         Set<RpcError> errorSet = Collections.emptySet();
679         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
680         Mockito.when(
681                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
682                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
683
684         GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder();
685         input.setMeterId(new MeterId(42L));
686
687         mdSwitchOF10.getMeterStatistics(input.build()).get();
688         mdSwitchOF13.getMeterStatistics(input.build()).get();
689         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
690                 Matchers.any(MultipartRequestInput.class),
691                 Matchers.any(SwitchConnectionDistinguisher.class));
692     }
693     
694     /**
695      * Test method for
696      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
697      * getAllNodeConnectorsStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
698      * GetAllNodeConnectorsStatisticsInput)}
699      * .
700      * @throws ExecutionException 
701      * @throws InterruptedException 
702      */
703     @Test
704     public void testGetAllNodeConnectorsStatistics() throws InterruptedException, ExecutionException {
705         GetAllNodeConnectorsStatisticsOutputBuilder getAllNodeConnectorsStatsOutput = 
706                 new GetAllNodeConnectorsStatisticsOutputBuilder();
707         getAllNodeConnectorsStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
708         Set<RpcError> errorSet = Collections.emptySet();
709         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
710         Mockito.when(
711                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
712                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
713
714         GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
715
716         mdSwitchOF10.getAllNodeConnectorsStatistics(input.build()).get();
717         mdSwitchOF13.getAllNodeConnectorsStatistics(input.build()).get();
718         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
719                 Matchers.any(MultipartRequestInput.class),
720                 Matchers.any(SwitchConnectionDistinguisher.class));
721     }
722     
723     /**
724      * Test method for
725      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
726      * getNodeConnectorStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
727      * GetNodeConnectorStatisticsInput)}
728      * .
729      * @throws ExecutionException 
730      * @throws InterruptedException 
731      */
732     @Test
733     public void testGetNodeConnectorStatistics() throws InterruptedException, ExecutionException {
734         GetNodeConnectorStatisticsOutputBuilder getNodeConnectorStatsOutput = 
735                 new GetNodeConnectorStatisticsOutputBuilder();
736         getNodeConnectorStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
737         Set<RpcError> errorSet = Collections.emptySet();
738         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
739         Mockito.when(
740                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
741                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
742
743         GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder();
744         input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
745         
746         Mockito.when(features.getVersion()).thenReturn((short)1);
747         mdSwitchOF10.getNodeConnectorStatistics(input.build()).get();
748         Mockito.when(features.getVersion()).thenReturn((short)4);
749         mdSwitchOF13.getNodeConnectorStatistics(input.build()).get();
750         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
751                 Matchers.any(MultipartRequestInput.class),
752                 Matchers.any(SwitchConnectionDistinguisher.class));
753     }
754     
755     /**
756      * Test method for
757      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
758      * updatePort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.
759      * UpdatePortInput)}
760      * .
761      * @throws ExecutionException 
762      * @throws InterruptedException 
763      */
764     @Test
765     public void testUpdatePort() throws InterruptedException, ExecutionException {
766         UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder();
767         updatePortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
768         Set<RpcError> errorSet = Collections.emptySet();
769         RpcResult<UpdatePortOutput> result = Rpcs.getRpcResult(true, updatePortOutput.build(), errorSet);
770         Mockito.when(
771                 messageDispatchService.portMod(Matchers.any(PortModInput.class),
772                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
773
774         UpdatePortInputBuilder input = new UpdatePortInputBuilder();
775         
776         PortBuilder portBuilder = new PortBuilder();
777         List<Port> ports = new ArrayList<Port>();
778         ports.add(createPort()); 
779         portBuilder.setPort(ports);
780         UpdatedPortBuilder updatedPortBuilder = new UpdatedPortBuilder();
781         updatedPortBuilder.setPort(portBuilder.build());
782         input.setUpdatedPort(updatedPortBuilder.build());
783
784         mdSwitchOF10.updatePort(input.build()).get();
785         mdSwitchOF13.updatePort(input.build()).get();
786         Mockito.verify(messageDispatchService, Mockito.times(2)).portMod(
787                 Matchers.any(PortModInput.class),
788                 Matchers.any(SwitchConnectionDistinguisher.class));
789     }
790     
791     private static Port createPort() {
792         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder port = 
793                 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
794         
795         port.setPortName("TestingPort01");
796         port.setMask(new PortConfig(true, true, true, true));
797         port.setConfiguration(new PortConfig(true, true, true, true));
798         port.setAdvertisedFeatures(new PortFeatures(true, true, true, true, 
799                                                     false, false, false, false, 
800                                                     true, true, true, true,
801                                                     false, false, false, false));
802         port.setPortNumber(new PortNumber(42L));
803         port.setHardwareAddress(new MacAddress("01:23:45:67:89:ab"));
804         port.setBarrier(true);
805         port.setContainerName("TestContainer");
806         port.setPortModOrder(25L);
807         port.setKey(new PortKey(25L));
808         return port.build();
809     }
810     
811     /**
812      * Test method for
813      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
814      * updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.
815      * UpdateTableInput)}
816      * .
817      * @throws ExecutionException 
818      * @throws InterruptedException 
819      */
820     @Test
821     public void testUpdateTable() throws InterruptedException, ExecutionException {
822         UpdateTableOutputBuilder updateTableOutput = new UpdateTableOutputBuilder();
823         updateTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
824         Set<RpcError> errorSet = Collections.emptySet();
825         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
826         Mockito.when(
827                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
828                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
829
830         UpdateTableInputBuilder input = new UpdateTableInputBuilder();
831         input.setUpdatedTable(createUpdateTable());
832
833         mdSwitchOF10.updateTable(input.build()).get();
834         mdSwitchOF13.updateTable(input.build()).get();
835         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
836                 Matchers.any(MultipartRequestInput.class),
837                 Matchers.any(SwitchConnectionDistinguisher.class));
838     }
839     
840     private static UpdatedTable createUpdateTable() {
841         UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
842         TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
843         tableFeaturesBuilder.setConfig(new TableConfig(true));
844         tableFeaturesBuilder.setKey(new TableFeaturesKey((short) 42));
845         tableFeaturesBuilder.setMaxEntries(42L);
846         tableFeaturesBuilder.setMetadataMatch(new BigInteger("42424242"));
847         tableFeaturesBuilder.setMetadataWrite(new BigInteger("42424242"));
848         tableFeaturesBuilder.setName("testTableFeatures");
849         tableFeaturesBuilder.setTableId((short) 41);
850         
851         TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
852         TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
853         tableFeaturePropertiesBuilder.setKey(new TableFeaturePropertiesKey(45));
854         tableFeaturePropertiesBuilder.setOrder(44);
855         tableFeaturePropertiesBuilder.setTableFeaturePropType(new ApplySetfieldBuilder().build());
856         List<TableFeatureProperties> tableFeatureProperties = new ArrayList<TableFeatureProperties>();
857         tableFeatureProperties.add(tableFeaturePropertiesBuilder.build());
858         tablePropertiesBuilder.setTableFeatureProperties(tableFeatureProperties);
859         
860         tableFeaturesBuilder.setTableProperties(tablePropertiesBuilder.build());
861         List<TableFeatures> tableFeatures = new ArrayList<TableFeatures>();
862         tableFeatures.add(tableFeaturesBuilder.build());
863         updatedTableBuilder.setTableFeatures(tableFeatures);
864         return updatedTableBuilder.build();
865     }
866     
867     /**
868      * Test method for
869      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
870      * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
871      * GetAllFlowStatisticsFromFlowTableInput)}
872      * .
873      * @throws ExecutionException 
874      * @throws InterruptedException 
875      */
876     @Test
877     public void testGetAllFlowStatisticsFromFlowTable() throws InterruptedException, ExecutionException {
878         GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatisticsFromFlowTableOutput = 
879                 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
880         allFlowStatisticsFromFlowTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
881         Set<RpcError> errorSet = Collections.emptySet();
882         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
883         Mockito.when(
884                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
885                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
886
887         GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder();
888         input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
889
890         mdSwitchOF10.getAllFlowStatisticsFromFlowTable(input.build()).get();
891         mdSwitchOF13.getAllFlowStatisticsFromFlowTable(input.build()).get();
892         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
893                 Matchers.any(MultipartRequestInput.class),
894                 Matchers.any(SwitchConnectionDistinguisher.class));
895     }
896     
897     /**
898      * Test method for
899      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
900      * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
901      * GetAllFlowStatisticsFromFlowTableInput)}
902      * .
903      * @throws ExecutionException 
904      * @throws InterruptedException 
905      */
906     @Test
907     public void testGetAllFlowsStatisticsFromAllFlowTables() throws InterruptedException, ExecutionException {
908         GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatisticsFromAllFlowTablesOutput = 
909                 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
910         allFlowStatisticsFromAllFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
911         Set<RpcError> errorSet = Collections.emptySet();
912         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
913         Mockito.when(
914                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
915                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
916
917         GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = 
918                                     new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
919
920         mdSwitchOF10.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
921         mdSwitchOF13.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
922         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
923                 Matchers.any(MultipartRequestInput.class),
924                 Matchers.any(SwitchConnectionDistinguisher.class));
925     }
926     
927     /**
928      * Test method for
929      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
930      * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
931      * GetAllFlowStatisticsFromFlowTableInput)}
932      * .
933      * @throws ExecutionException 
934      * @throws InterruptedException 
935      */
936     @Test
937     public void testGetFlowStatisticsFromFlowTables() throws InterruptedException, ExecutionException {
938         GetFlowStatisticsFromFlowTableOutputBuilder flowStatisticsFromFlowTablesOutput = 
939                 new GetFlowStatisticsFromFlowTableOutputBuilder();
940         flowStatisticsFromFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
941         Set<RpcError> errorSet = Collections.emptySet();
942         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
943         Mockito.when(
944                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
945                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
946
947         GetFlowStatisticsFromFlowTableInputBuilder input = 
948                                     new GetFlowStatisticsFromFlowTableInputBuilder();
949         input.setMatch(createMatch()); 
950
951         mdSwitchOF10.getFlowStatisticsFromFlowTable(input.build()).get();
952         mdSwitchOF13.getFlowStatisticsFromFlowTable(input.build()).get();
953         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
954                 Matchers.any(MultipartRequestInput.class),
955                 Matchers.any(SwitchConnectionDistinguisher.class));
956     }
957     
958     private static Match createMatch() {
959         MatchBuilder matchBuilder = new MatchBuilder(); 
960         EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
961         EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
962         ethernetDestinationBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
963         ethernetDestinationBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
964         ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build()); 
965         EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
966         ethernetSourceBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
967         ethernetSourceBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
968         ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build()); 
969         ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(42L)).build()); 
970         matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
971         return matchBuilder.build();
972     }
973     
974     /**
975      * Test method for
976      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
977      * getAggregateFlowStatisticsFromFlowTableForAllFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
978      * GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput)}
979      * .
980      * @throws ExecutionException 
981      * @throws InterruptedException 
982      */
983     @Test
984     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws InterruptedException, 
985                                                                                 ExecutionException {
986         GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder aggregateFlowStatisticsOutput = 
987                 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
988         aggregateFlowStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
989         Set<RpcError> errorSet = Collections.emptySet();
990         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
991         Mockito.when(
992                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
993                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
994
995         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = 
996                            new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
997         input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
998
999         mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1000         mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1001         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1002                 Matchers.any(MultipartRequestInput.class),
1003                 Matchers.any(SwitchConnectionDistinguisher.class));
1004     }
1005     
1006     /**
1007      * Test method for
1008      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1009      * getAggregateFlowStatisticsFromFlowTableForGivenMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
1010      * GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)}
1011      * .
1012      * @throws ExecutionException 
1013      * @throws InterruptedException 
1014      */
1015     @Test
1016     public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws InterruptedException, 
1017                                                                                 ExecutionException {
1018         GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregateFlowStatisticsForMatchOutput = 
1019                 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1020         aggregateFlowStatisticsForMatchOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1021         Set<RpcError> errorSet = Collections.emptySet();
1022         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1023         Mockito.when(
1024                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1025                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1026
1027         GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input = 
1028                            new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder();
1029         input.setMatch(createMatch());
1030         input.setCookie(new FlowCookie(new BigInteger("123456")));
1031         input.setCookieMask(new FlowCookie(new BigInteger("123456")));
1032         input.setOutGroup(44L);
1033         input.setOutPort(new BigInteger("12563"));
1034
1035         mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1036         mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1037         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1038                 Matchers.any(MultipartRequestInput.class),
1039                 Matchers.any(SwitchConnectionDistinguisher.class));
1040     }
1041     
1042     /**
1043      * Test method for
1044      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1045      * getFlowTablesStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.
1046      * GetFlowTablesStatisticsInput)}
1047      * .
1048      * @throws ExecutionException 
1049      * @throws InterruptedException 
1050      */
1051     @Test
1052     public void testGetFlowTablesStatistics() throws InterruptedException, ExecutionException {
1053         GetFlowTablesStatisticsOutputBuilder flowTableStatisticsOutput = 
1054                 new GetFlowTablesStatisticsOutputBuilder();
1055         flowTableStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1056         Set<RpcError> errorSet = Collections.emptySet();
1057         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1058         Mockito.when(
1059                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1060                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1061
1062         GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
1063
1064         mdSwitchOF10.getFlowTablesStatistics(input.build()).get();
1065         mdSwitchOF13.getFlowTablesStatistics(input.build()).get();
1066         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1067                 Matchers.any(MultipartRequestInput.class),
1068                 Matchers.any(SwitchConnectionDistinguisher.class));
1069     }
1070     
1071     /**
1072      * Test method for
1073      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1074      * getAllQueuesStatisticsFromAllPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1075      * GetAllQueuesStatisticsFromAllPortsInput)}
1076      * .
1077      * @throws ExecutionException 
1078      * @throws InterruptedException 
1079      */
1080     @Test
1081     public void testGetAllQueuesStatisticsFromAllPorts() throws InterruptedException, ExecutionException {
1082         GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueuesStatisticsAllPortsOutput = 
1083                 new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1084         allQueuesStatisticsAllPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1085         Set<RpcError> errorSet = Collections.emptySet();
1086         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1087         Mockito.when(
1088                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1089                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1090
1091         GetAllQueuesStatisticsFromAllPortsInputBuilder input = 
1092                 new GetAllQueuesStatisticsFromAllPortsInputBuilder();
1093
1094         mdSwitchOF10.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1095         mdSwitchOF13.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1096         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1097                 Matchers.any(MultipartRequestInput.class),
1098                 Matchers.any(SwitchConnectionDistinguisher.class));
1099     }
1100     
1101     /**
1102      * Test method for
1103      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1104      * getAllQueuesStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1105      * GetAllQueuesStatisticsFromGivenPortInput)}
1106      * .
1107      * @throws ExecutionException 
1108      * @throws InterruptedException 
1109      */
1110     @Test
1111     public void testGetAllQueuesStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1112         GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueuesStatisticsGivenPortsOutput = 
1113                 new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1114         allQueuesStatisticsGivenPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1115         Set<RpcError> errorSet = Collections.emptySet();
1116         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1117         Mockito.when(
1118                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1119                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1120
1121         GetAllQueuesStatisticsFromGivenPortInputBuilder input = 
1122                 new GetAllQueuesStatisticsFromGivenPortInputBuilder();
1123         input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1124         
1125         Mockito.when(features.getVersion()).thenReturn((short)1);
1126         mdSwitchOF10.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1127         Mockito.when(features.getVersion()).thenReturn((short)4);
1128         mdSwitchOF13.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1129         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1130                 Matchers.any(MultipartRequestInput.class),
1131                 Matchers.any(SwitchConnectionDistinguisher.class));
1132     }
1133     
1134     /**
1135      * Test method for
1136      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1137      * getQueueStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1138      * GetQueueStatisticsFromGivenPortInput)}
1139      * .
1140      * @throws ExecutionException 
1141      * @throws InterruptedException 
1142      */
1143     @Test
1144     public void testGetQueueStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1145         GetQueueStatisticsFromGivenPortOutputBuilder queuesStatisticsGivenPortOutput = 
1146                 new GetQueueStatisticsFromGivenPortOutputBuilder();
1147         queuesStatisticsGivenPortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1148         Set<RpcError> errorSet = Collections.emptySet();
1149         RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1150         Mockito.when(
1151                 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1152                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1153
1154         GetQueueStatisticsFromGivenPortInputBuilder input = 
1155                 new GetQueueStatisticsFromGivenPortInputBuilder();
1156         input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1157         input.setQueueId(new QueueId(55L));
1158         
1159         Mockito.when(features.getVersion()).thenReturn((short)1);
1160         mdSwitchOF10.getQueueStatisticsFromGivenPort(input.build()).get();
1161         Mockito.when(features.getVersion()).thenReturn((short)4);
1162         mdSwitchOF13.getQueueStatisticsFromGivenPort(input.build()).get();
1163         Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1164                 Matchers.any(MultipartRequestInput.class),
1165                 Matchers.any(SwitchConnectionDistinguisher.class));
1166     }
1167 }