78ec8fd589ef8dbd3ead9da76148293414953616
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / registry / flow / TestFlowHelper.java
1 /*
2  * Copyright (c) 2015 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.impl.registry.flow;
10
11 import java.math.BigInteger;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.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;
19
20 /**
21  * flow building helper
22  */
23 public class TestFlowHelper {
24     /**
25      * @param i data seed
26      * @return flow stats builder with dummy content
27      */
28     protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int i) {
29         FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
30         flowAndStatisticsMapListBuilder.setPriority(i);
31         flowAndStatisticsMapListBuilder.setTableId((short) i);
32         flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
33
34         MatchBuilder matchBuilder = new MatchBuilder();
35
36         EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
37
38         EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
39         MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + i);
40         ethernetSourceBuilder.setAddress(macAddress);
41         ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
42
43         EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
44         ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + i + ":00:00"));
45         ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
46
47         matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
48
49         flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
50         return flowAndStatisticsMapListBuilder;
51     }
52 }