Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / renderers / iovisor / src / test / java / org / opendaylight / groupbasedpolicy / renderer / iovisor / sf / ParamDerivatorTest.java
1 /*
2  * Copyright (c) 2016 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.groupbasedpolicy.renderer.iovisor.sf;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.HashMap;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.junit.Test;
19 import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
22
23 public class ParamDerivatorTest {
24
25     private ParamDerivator derivator = ParamDerivator.ETHER_TYPE_DERIVATOR;
26
27     @Test
28     public void testDeriveParameter_noDerivation() {
29         Map<String, ParameterValue> params = new HashMap<>();
30         ParameterValue pv = new ParameterValueBuilder().setIntValue(EtherTypeClassifierDefinition.IPv4_VALUE).build();
31         params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, pv);
32
33         List<Map<String, ParameterValue>> result = derivator.deriveParameter(params);
34
35         assertEquals(1, result.size());
36         assertEquals(params, result.get(0));
37     }
38
39     @Test
40     public void testDeriveParameter_withDerivation() {
41         Map<String, ParameterValue> params = new HashMap<>();
42         ParameterValue pv = new ParameterValueBuilder().setIntValue(EtherTypeClassifierDefinition.IPv4_VALUE).build();
43         params.put("dummy key", pv);
44
45         List<Map<String, ParameterValue>> derivedParams = derivator.deriveParameter(params);
46
47         assertEquals(2, derivedParams.size());
48
49         Map<String, ParameterValue> ipv4Params = derivedParams.get(0);
50         Map<String, ParameterValue> ipv6Params = derivedParams.get(1);
51
52         assertTrue(ipv4Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
53         assertTrue(ipv6Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
54     }
55
56 }