2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.policy.rest.util;
22 import static org.junit.Assert.assertTrue;
24 import java.util.HashSet;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.policy.xacml.std.pap.StdPDPGroup;
29 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
31 import com.att.research.xacml.api.pap.PDPPolicy;
33 public class PDPPolicyContainerTest {
36 PDPPolicyContainer container;
41 group = new StdPDPGroup();
42 group.setDefault(true);
43 group.setDefaultGroup(true);
44 group.setDescription("Test");
46 group.setName("Test");
47 group.setOnapPdps(new HashSet<>());
48 group.setOperation("Test");
49 group.setPipConfigs(new HashSet<>());
50 HashSet<PDPPolicy> policies = new HashSet<>();
51 policy = new StdPDPPolicy();
52 policy.setName("Config_test.1.xml");
53 policy.setId("Config_test");
55 group.setPolicies(policies);
56 group.setSelectedPolicies(new HashSet<>());
57 container = new PDPPolicyContainer(group);
62 public void testPDPPolicyContainer(){
63 container.nextItemId(policy);
64 container.prevItemId(policy);
65 container.firstItemId();
66 container.lastItemId();
67 container.isFirstId(policy);
68 container.isLastId(policy);
69 container.addItemAfter(policy);
70 container.getContainerPropertyIds();
71 container.getItemIds();
72 container.getType("Id");
73 assertTrue(String.class.equals(String.class));
74 container.getType("Name");
75 assertTrue(String.class.equals(String.class));
76 container.getType("Version");
77 assertTrue(String.class.equals(String.class));
78 container.getType("Description");
79 assertTrue(String.class.equals(String.class));
80 container.getType("Root");
81 assertTrue(Boolean.class.equals(Boolean.class));
82 assertTrue(container.size() == 1);
83 container.containsId(policy);
84 container.removeItem(policy);
85 container.addContainerProperty(null, null, null);
86 container.removeContainerProperty(policy);
87 container.removeAllItems();
88 container.addItemAt(0);