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