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 class TestFlowHelper {
25 * Creates flow and statistics builder.
26 * @param index data seed
27 * @return flow stats builder with dummy content
29 protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) {
30 FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
31 flowAndStatisticsMapListBuilder.setPriority(index);
32 flowAndStatisticsMapListBuilder.setTableId((short) index);
33 flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
35 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
37 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
38 MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + index);
39 ethernetSourceBuilder.setAddress(macAddress);
40 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
42 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
43 ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + index + ":00:00"));
44 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
46 MatchBuilder matchBuilder = new MatchBuilder();
47 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
49 flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
50 return flowAndStatisticsMapListBuilder;