2 * Copyright (C) 2014 Cisco Systems, Inc.
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
10 package org.opendaylight.groupbasedpolicy.renderer.opflex.mit;
12 import static org.junit.Assert.assertTrue;
16 import java.util.ArrayList;
17 import java.util.List;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyClassInfo.PolicyClassInfoBuilder;
22 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId;
23 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyInfoBuilder;
25 public class PolicyClassInfoTest {
27 List<PolicyPropertyId> testKeyList;
28 List<PolicyPropertyInfo> testPropertyInfoList;
29 PolicyPropertyInfo testPpi;
31 private static final int TEST_PROP_ID = 200;
32 private static final int TEST_CLASS_ID = 100;
33 private static final String TEST_CLASS_NAME = "foobar";
34 private static final PolicyClassInfo.PolicyClassType TEST_CLASS_TYPE =
35 PolicyClassInfo.PolicyClassType.POLICY;
38 public void setUp() throws Exception {
39 PolicyPropertyInfoBuilder ppib = new PolicyPropertyInfoBuilder();
40 testPpi = ppib.build();
41 testKeyList = new ArrayList<PolicyPropertyId>();
42 testKeyList.add(new PolicyPropertyId(TEST_PROP_ID));
43 testPropertyInfoList = new ArrayList<PolicyPropertyInfo>();
44 testPropertyInfoList.add(testPpi);
48 public void testBuilder() throws Exception {
49 PolicyClassInfoBuilder pcib = new PolicyClassInfoBuilder();
50 PolicyClassInfo pci = null;
51 pcib.setClassId(TEST_CLASS_ID);
52 pcib.setClassName(TEST_CLASS_NAME);
53 pcib.setKey(testKeyList);
54 pcib.setPolicyType(TEST_CLASS_TYPE);
55 pcib.setProperty(testPropertyInfoList);
58 assertTrue(pci.getClassId() == TEST_CLASS_ID);
59 assertTrue(pci.getClassName().equals(TEST_CLASS_NAME));
60 assertTrue(pci.getKeys().get(0) == testKeyList.get(0));
61 assertTrue(pci.getPolicyType() == TEST_CLASS_TYPE);
62 assertTrue(pci.getProperties().get(0) == testPropertyInfoList.get(0));