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