@Test public final void testGetResult() throws PolicyException { service.getValidation(); String result = service.getResult(false); assertEquals("success", result); }
public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } if (!configBody.containsKey("serviceTypePolicyName")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy 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(); String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", ""); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_PM") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(null) .serviceType(serviceType) .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; }
ClosedLoopPMPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } if (!configBody.containsKey("serviceTypePolicyName")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy 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(); String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", ""); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_PM") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(null) .serviceType(serviceType) .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; } }
ClosedLoopPMPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } if (!configBody.containsKey("serviceTypePolicyName")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy 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(); String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", ""); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_PM") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(null) .serviceType(serviceType) .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; } ClosedLoopPMPolicyService(String policyName, String policyScope,
                                     PolicyParameters policyParameters, String date); }
ClosedLoopPMPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } if (!configBody.containsKey("serviceTypePolicyName")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy 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(); String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", ""); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_PM") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(null) .serviceType(serviceType) .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; } ClosedLoopPMPolicyService(String policyName, String policyScope,
                                     PolicyParameters policyParameters, String date); Boolean getValidation(); String getMessage(); String getResult(boolean updateFlag); }
ClosedLoopPMPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } if (!configBody.containsKey("onapname")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given."; LOGGER.error(message); return message; } if (!configBody.containsKey("serviceTypePolicyName")) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Service Type Policy 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(); String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", ""); StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("ClosedLoop_PM") .policyName(policyName) .description(policyParameters.getPolicyDescription()) .onapName(onapName) .jsonBody(jsonBody) .draft(false) .oldPolicyFileName(null) .serviceType(serviceType) .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; } ClosedLoopPMPolicyService(String policyName, String policyScope,
                                     PolicyParameters policyParameters, String date); Boolean getValidation(); String getMessage(); String getResult(boolean updateFlag);  }