2 * Copyright (c) 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
9 package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
14 import java.util.HashMap;
15 import java.util.List;
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;
23 public class ParamDerivatorTest {
25 private ParamDerivator derivator = ParamDerivator.ETHER_TYPE_DERIVATOR;
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);
33 List<Map<String, ParameterValue>> result = derivator.deriveParameter(params);
35 assertEquals(1, result.size());
36 assertEquals(params, result.get(0));
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);
45 List<Map<String, ParameterValue>> derivedParams = derivator.deriveParameter(params);
47 assertEquals(2, derivedParams.size());
49 Map<String, ParameterValue> ipv4Params = derivedParams.get(0);
50 Map<String, ParameterValue> ipv6Params = derivedParams.get(1);
52 assertTrue(ipv4Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
53 assertTrue(ipv6Params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));