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.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
21 * Flow building helper.
23 public final class TestFlowHelper {
25 private TestFlowHelper() {
29 * Creates flow and statistics builder.
30 * @param index data seed
31 * @return flow stats builder with dummy content
33 protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) {
34 FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
35 flowAndStatisticsMapListBuilder.setPriority(index);
36 flowAndStatisticsMapListBuilder.setTableId((short) index);
37 flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
39 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
41 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
42 MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + index);
43 ethernetSourceBuilder.setAddress(macAddress);
44 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
46 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
47 ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + index + ":00:00"));
48 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
50 MatchBuilder matchBuilder = new MatchBuilder();
51 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
53 flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
54 return flowAndStatisticsMapListBuilder;