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