2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
\r
11 import static org.junit.Assert.assertEquals;
\r
12 import static org.junit.Assert.assertTrue;
\r
14 import java.util.HashMap;
\r
15 import java.util.List;
\r
16 import java.util.Map;
\r
18 import org.junit.Test;
\r
19 import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
\r
23 public class ParamDerivatorTest {
\r
25 private ParamDerivator derivator = ParamDerivator.ETHER_TYPE_DERIVATOR;
\r
28 public void testDeriveParameter_noDerivation() {
\r
29 Map<String, ParameterValue> params = new HashMap<>();
\r
30 ParameterValue pv = new ParameterValueBuilder().setIntValue(EtherTypeClassifierDefinition.IPv4_VALUE).build();
\r
31 params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, pv);
\r
33 List<Map<String, ParameterValue>> result = derivator.deriveParameter(params);
\r
35 assertEquals(1, result.size());
\r
36 assertEquals(params, result.get(0));
\r
40 public void testDeriveParameter_withDerivation() {
\r
41 Map<String, ParameterValue> params = new HashMap<>();
\r
42 ParameterValue pv = new ParameterValueBuilder().setIntValue(EtherTypeClassifierDefinition.IPv4_VALUE).build();
\r
43 params.put("dummy key", pv);
\r
45 List<Map<String, ParameterValue>> derivedParams = derivator.deriveParameter(params);
\r
47 assertEquals(2, derivedParams.size());
\r
49 Map<String, ParameterValue> ipv4Params = derivedParams.get(0);
\r
50 Map<String, ParameterValue> ipv6Params = derivedParams.get(1);
\r
52 assertTrue(ipv4Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
\r
53 assertTrue(ipv6Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
\r