2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.xacml.pdp.application.guard;
25 import static org.assertj.core.api.Assertions.assertThat;
27 import java.util.HashMap;
29 import org.junit.Test;
30 import org.onap.policy.models.decisions.concepts.DecisionRequest;
32 public class GuardPolicyRequestTest {
35 public void testAnomalies() {
36 DecisionRequest decisionRequest = new DecisionRequest();
37 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
39 Map<String, Object> resources = new HashMap<>();
40 decisionRequest.setResource(resources);
41 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
43 resources.put("notguard", "foo");
44 decisionRequest.setResource(resources);
45 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
47 resources.put("guard", null);
48 decisionRequest.setResource(resources);
49 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
51 Map<String, Object> guard = new HashMap<>();
52 resources.put("guard", guard);
53 decisionRequest.setResource(resources);
54 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
56 guard.put("crap", "notused");
57 resources.put("guard", guard);
58 decisionRequest.setResource(resources);
59 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
61 guard.put("actor", "notused");
62 resources.put("guard", guard);
63 decisionRequest.setResource(resources);
64 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
66 guard.put("recipe", "notused");
67 resources.put("guard", guard);
68 decisionRequest.setResource(resources);
69 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
71 guard.put("clname", "notused");
72 resources.put("guard", guard);
73 decisionRequest.setResource(resources);
74 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
76 guard.put("target", "notused");
77 resources.put("guard", guard);
78 decisionRequest.setResource(resources);
79 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();
81 guard.put("vfCount", 1);
82 resources.put("guard", guard);
83 decisionRequest.setResource(resources);
84 assertThat(GuardPolicyRequest.createInstance(decisionRequest)).isNotNull();