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.pdp.rest.api.services;
22 import static org.junit.Assert.*;
24 import java.io.FileInputStream;
25 import java.util.Arrays;
26 import java.util.List;
27 import java.util.Properties;
28 import java.util.UUID;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.policy.api.PolicyException;
34 import org.onap.policy.rest.XACMLRestProperties;
35 import org.onap.policy.xacml.std.pap.StdPAPPolicy;
36 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
38 public class PAPServicesTest {
40 PAPServices papServices = null;
43 public void setUp() throws Exception {
44 PAPServices.junit = true;
45 Properties prop = new Properties();
46 prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
47 String succeeded = prop.getProperty("xacml.rest.pap.url");
48 List<String> paps = Arrays.asList(succeeded.split(","));
49 PAPServices.setPaps(paps);
50 papServices = new PAPServices();
55 public void tearDown() throws Exception {
56 PAPServices.junit = false;
60 public final void testCallPAP() throws PolicyException {
61 StdPAPPolicy newPAPPolicy = new StdPAPPolicy();
62 String response = null;
63 response = (String) papServices.callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Config"}, UUID.randomUUID(), "Config");
64 assertEquals("success",response);
68 public final void testGetActiveVersion() {
69 String activeVersion = papServices.getActiveVersion("test", "Config_", "test.testpolicy", "Config", UUID.randomUUID());
70 assertNull(activeVersion);
74 public final void testPushPolicy() throws PolicyException {
75 StdPDPPolicy selectedPolicy = papServices.pushPolicy("test", "Config_", "test.testpolicy", "Config", "default", UUID.randomUUID());
76 assertNull(selectedPolicy);