ClosedLoopFaultPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; String oldPolicyName = null; if (updateFlag) { operation = "update"; if (policyName.endsWith("_Draft")) { oldPolicyName = policyName + "_Draft.1"; } } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } String onapName = configBody.get("onapname").toString().trim().replace("\"", ""); if (onapName == null || onapName.trim().isEmpty()) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } boolean levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel()); if (!levelCheck) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given."; LOGGER.error(message); return message; } String jsonBody = configBody.toString(); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_Fault") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(oldPolicyName) .serviceType(null) .editPolicy(updateFlag) .domain(policyScope) .highestVersion(0) .riskLevel(policyParameters.getRiskLevel()) .riskType(policyParameters.getRiskType()) .guard(String.valueOf(policyParameters.getGuard())) .ttlDate(date) .build()); response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api", "policyType=Config"}, policyParameters.getRequestID(), "ConfigClosedLoop"); return response; } ClosedLoopFaultPolicyService(String policyName, String policyScope,
                                        PolicyParameters policyParameters, String date); Boolean getValidation(); String getMessage(); String getResult(boolean updateFlag);  }
@Test public final void testGetResult() throws PolicyException { service.getValidation(); String result = service.getResult(false); assertEquals("success", result); }