2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.impl.registry.flow;
11 import java.math.BigInteger;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
23 * Flow building helper.
25 public final class TestFlowHelper {
27 private TestFlowHelper() {
31 * Creates flow and statistics builder.
32 * @param index data seed
33 * @return flow stats builder with dummy content
35 protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) {
36 FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
37 flowAndStatisticsMapListBuilder.setPriority(index);
38 flowAndStatisticsMapListBuilder.setTableId((short) index);
39 flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
41 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
43 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
44 MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + index);
45 ethernetSourceBuilder.setAddress(macAddress);
46 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
48 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
49 ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + index + ":00:00"));
50 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
52 MatchBuilder matchBuilder = new MatchBuilder();
53 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
55 flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
56 flowAndStatisticsMapListBuilder.withKey(new FlowAndStatisticsMapListKey(new FlowId(String.valueOf(index))));
57 return flowAndStatisticsMapListBuilder;