From 4c8000e91a9dee0738e55e2bda930b94af474157 Mon Sep 17 00:00:00 2001 From: Temoc Rodriguez Date: Thu, 14 Dec 2017 15:58:32 -0800 Subject: Add guard junits Added a few junit files which test most functionality in the guard submodule. Some minor bugs were found by the junits and fixed those newly found bugs. Added persistence.xml for use by junits in guard. Issue-ID: POLICY-490 Change-Id: Ied7e276cfd417e1f396b5a6685a2e9acc9efd109 Signed-off-by: Temoc Rodriguez --- .../java/org/onap/policy/simulators/GuardSimulatorJaxRs.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'controlloop/common/simulators') diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java index 7415130ea..4551cf246 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,14 +30,15 @@ import org.json.JSONObject; @Path("/pdp/api") public class GuardSimulatorJaxRs { + public static final String DENY_CLNAME = "denyGuard"; @POST @Path("/getDecision") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public String getGuardDecision(String req){ + public String getGuardDecision(String req){ String clName = new JSONObject(req).getJSONObject("decisionAttributes").getString("clname"); - if ("denyGuard".equals(clName)) + if (DENY_CLNAME.equals(clName)) { return "{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}"; } -- cgit 1.2.3-korg