0e2c685b5a2ef3e6a04d8982eb78b8c088c64f6d
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / flowflag / FlowFlagReactorTest.java
1 /**
2  * Copyright (c) 2013 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 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
9
10 import java.math.BigInteger;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowplugin.api.OFConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
17
18 /**
19  * match conversion and injection test
20  */
21 public class FlowFlagReactorTest {
22
23     private FlowModFlags[] flowFlags;
24
25     /**
26      * prepare input match
27      */
28     @Before
29     public void setUp() {
30         flowFlags = new FlowModFlags[] {
31                 new FlowModFlags(true, true, true, true, true),
32                 new FlowModFlags(false, false, false, false, false),
33                 new FlowModFlags(true, false, true, false, true)
34         };
35     }
36
37     /**
38      * convert for OF-1.3, inject into {@link FlowModInputBuilder}
39      */
40     @Test
41     public void testMatchConvertorV13_flow() {
42         FlowModInputBuilder target = new FlowModInputBuilder();
43         for (FlowModFlags fFlag : flowFlags) {
44             target.setFlags(null);
45             FlowFlagReactor.getInstance().convert(fFlag,
46                     OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
47             Assert.assertNotNull(target.getFlags());
48         }
49     }
50
51     /**
52      * convert for OF-1.0, inject into {@link FlowModInputBuilder}
53      */
54     @Test
55     public void testMatchConvertorV10_flow() {
56         FlowModInputBuilder target = new FlowModInputBuilder();
57         for (FlowModFlags fFlag : flowFlags) {
58             target.setFlagsV10(null);
59             FlowFlagReactor.getInstance().convert(fFlag,
60                     OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
61             Assert.assertNotNull(target.getFlagsV10());
62         }
63     }
64 }