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=========================================================
23 package org.onap.policy.pdp.rest.api.models;
25 import static org.junit.Assert.assertEquals;
26 import java.util.HashMap;
28 import org.junit.Test;
29 import org.onap.policy.api.PolicyConfigStatus;
30 import org.onap.policy.api.PolicyDecision;
31 import org.onap.policy.api.PolicyResponseStatus;
32 import org.onap.policy.api.PolicyType;
34 public class PDPResponseTest {
36 public void testSetAndGet() {
38 String message = "testMessage";
39 String config = "testConfig";
40 String policyName = "testPolicyName";
41 String policyVersion = "1.0";
42 PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
43 PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
44 PolicyType type = PolicyType.JSON;
45 Map<String, String> property = new HashMap<String, String>();
46 PolicyDecision policyDecision = PolicyDecision.PERMIT;
48 PDPResponse response = new PDPResponse();
50 response.setStatus(message, policyResponseStatus, policyConfigStatus);
51 response.setConfig(config);
52 assertEquals(config, response.getConfig());
53 response.setType(type);
54 assertEquals(type, response.getType());
55 response.setPolicyConfigStatus(policyConfigStatus);
56 assertEquals(policyConfigStatus, response.getPolicyConfigStatus());
57 response.setPolicyConfigMessage(message);
58 assertEquals(message, response.getPolicyConfigMessage());
59 response.setProperty(property);
60 assertEquals(property, response.getProperty());
61 response.setPolicyName(policyName);
62 assertEquals(policyName, response.getPolicyName());
63 response.setPolicyVersion(policyVersion);
64 assertEquals(policyVersion, response.getPolicyVersion());
65 response.setMatchingConditions(property);
66 assertEquals(property, response.getMatchingConditions());
67 response.setResponseAttributes(property);
68 assertEquals(property, response.getResponseAttributes());
69 response.setPolicyResponseStatus(policyResponseStatus);
70 assertEquals(policyResponseStatus, response.getPolicyResponseStatus());
71 response.setDecision(policyDecision);
72 assertEquals(policyDecision, response.getDecision());
73 response.setDetails(message);
74 assertEquals(message, response.getDetails());
75 response.setActionAdvised(property);
76 assertEquals(property, response.getActionAdvised());
77 response.setActionTaken(property);
78 assertEquals(property, response.getActionTaken());
79 response.setRequestAttributes(property);
80 assertEquals(property, response.getRequestAttributes());
81 response.setPolicyResponseMessage(message);
82 assertEquals(message, response.getPolicyResponseMessage());