JUnit additions for PDP-REST,REST,SDK-APP
[policy/engine.git] / ONAP-PDP-REST / src / test / java / org / onap / policy / pdp / rest / api / models / PDPResponseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.pdp.rest.api.models;
22
23 import static org.junit.Assert.assertEquals;
24 import java.util.HashMap;
25 import java.util.Map;
26 import org.junit.Test;
27 import org.onap.policy.api.PolicyConfigStatus;
28 import org.onap.policy.api.PolicyDecision;
29 import org.onap.policy.api.PolicyResponseStatus;
30 import org.onap.policy.api.PolicyType;
31
32 public class PDPResponseTest {
33   @Test
34   public void testSetAndGet() {
35     // Test values
36     String message = "testMessage";
37     String config = "testConfig";
38     String policyName = "testPolicyName";
39     String policyVersion = "1.0";
40     PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
41     PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
42     PolicyType type = PolicyType.JSON;
43     Map<String, String> property = new HashMap<String, String>();
44     PolicyDecision policyDecision = PolicyDecision.PERMIT;
45
46     PDPResponse response = new PDPResponse();
47
48     response.setStatus(message, policyResponseStatus, policyConfigStatus);
49     response.setConfig(config);
50     assertEquals(config, response.getConfig());
51     response.setType(type);
52     assertEquals(type, response.getType());
53     response.setPolicyConfigStatus(policyConfigStatus);
54     assertEquals(policyConfigStatus, response.getPolicyConfigStatus());
55     response.setPolicyConfigMessage(message);
56     assertEquals(message, response.getPolicyConfigMessage());
57     response.setProperty(property);
58     assertEquals(property, response.getProperty());
59     response.setPolicyName(policyName);
60     assertEquals(policyName, response.getPolicyName());
61     response.setPolicyVersion(policyVersion);
62     assertEquals(policyVersion, response.getPolicyVersion());
63     response.setMatchingConditions(property);
64     assertEquals(property, response.getMatchingConditions());
65     response.setResponseAttributes(property);
66     assertEquals(property, response.getResponseAttributes());
67     response.setPolicyResponseStatus(policyResponseStatus);
68     assertEquals(policyResponseStatus, response.getPolicyResponseStatus());
69     response.setDecision(policyDecision);
70     assertEquals(policyDecision, response.getDecision());
71     response.setDetails(message);
72     assertEquals(message, response.getDetails());
73     response.setActionAdvised(property);
74     assertEquals(property, response.getActionAdvised());
75     response.setActionTaken(property);
76     assertEquals(property, response.getActionTaken());
77     response.setRequestAttributes(property);
78     assertEquals(property, response.getRequestAttributes());
79     response.setPolicyResponseMessage(message);
80     assertEquals(message, response.getPolicyResponseMessage());
81   }
82 }