2 * Copyright (c) 2014, 2016 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
8 package test.mock.util;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
16 import java.math.BigInteger;
17 import java.util.Random;
19 public class FlowMockGenerator {
20 private static final Random rnd = new Random();
21 private static final FlowBuilder flowBuilder = new FlowBuilder();
23 public static Flow getRandomFlow() {
24 flowBuilder.setKey(new FlowKey(new FlowId("flow." + rnd.nextInt(1000))));
25 flowBuilder.setOutGroup(TestUtils.nextLong(0, 4294967296L));
26 flowBuilder.setTableId((short) rnd.nextInt(256));
27 flowBuilder.setOutPort(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE)));
28 flowBuilder.setStrict(rnd.nextBoolean());
29 flowBuilder.setContainerName("container." + rnd.nextInt(1000));
30 flowBuilder.setBarrier(rnd.nextBoolean());
31 flowBuilder.setMatch(MatchMockGenerator.getRandomMatch());
32 flowBuilder.setPriority(rnd.nextInt(65535));
33 flowBuilder.setCookie(new FlowCookie(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE))));
34 flowBuilder.setCookieMask(flowBuilder.getCookie());
35 return flowBuilder.build();