2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.policy.pdp.rest.api.services;
24 import static org.junit.Assert.*;
25 import java.io.FileInputStream;
26 import java.util.Arrays;
27 import java.util.List;
28 import java.util.Properties;
29 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.xacml.std.pap.StdPAPPolicy;
35 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
37 public class PAPServicesTest {
39 PAPServices papServices = null;
42 public void setUp() throws Exception {
43 PAPServices.setJunit(true);
44 Properties prop = new Properties();
45 prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
46 String succeeded = prop.getProperty("xacml.rest.pap.url");
47 List<String> paps = Arrays.asList(succeeded.split(","));
48 PAPServices.setPaps(paps);
49 papServices = new PAPServices();
53 public void tearDown() throws Exception {
54 PAPServices.setPaps(null);
55 PAPServices.setJunit(false);
59 public final void testCallPAP() throws PolicyException {
60 StdPAPPolicy newPAPPolicy = new StdPAPPolicy();
61 String response = null;
62 response = (String) papServices.callPAP(newPAPPolicy,
63 new String[] {"operation=create", "apiflag=api", "policyType=Config"}, UUID.randomUUID(), "Config");
64 assertEquals("success", response);
68 public final void testGetActiveVersion() {
69 String activeVersion =
70 papServices.getActiveVersion("test", "Config_", "test.testpolicy", "Config", UUID.randomUUID());
71 assertNull(activeVersion);
75 public final void testPushPolicy() throws PolicyException {
76 StdPDPPolicy selectedPolicy =
77 papServices.pushPolicy("test", "Config_", "test.testpolicy", "Config", "default", UUID.randomUUID());
78 assertNull(selectedPolicy);