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