@Test public final void testGetResult() throws PolicyException { 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"; } String servicModel = null; String policyDescription = null; String priority = null; String version = null; String onapName = policyParameters.getOnapName(); JsonObject optimizationAttributes = null; try { optimizationAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody()); } catch (JsonException | IllegalStateException e) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " + policyParameters.getConfigBody(); LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e); return null; } if (optimizationAttributes.get("service") != null) { servicModel = optimizationAttributes.get("service").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("description")) { policyDescription = optimizationAttributes.get("description").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("priority")) { priority = optimizationAttributes.get("priority").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("version")) { version = optimizationAttributes.get("version").toString().replace("\"", ""); } StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("Optimization") .policyName(policyName) .description(policyDescription) .onapName(onapName) .configName(null) .serviceType(servicModel) .uuid(null) .msLocation(null) .jsonBody(optimizationAttributes.toString()) .priority(priority) .version(version) .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(), "ConfigOptimization"); LOGGER.info("Response: " + response); return response; }
OptimizationPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } String servicModel = null; String policyDescription = null; String priority = null; String version = null; String onapName = policyParameters.getOnapName(); JsonObject optimizationAttributes = null; try { optimizationAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody()); } catch (JsonException | IllegalStateException e) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " + policyParameters.getConfigBody(); LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e); return null; } if (optimizationAttributes.get("service") != null) { servicModel = optimizationAttributes.get("service").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("description")) { policyDescription = optimizationAttributes.get("description").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("priority")) { priority = optimizationAttributes.get("priority").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("version")) { version = optimizationAttributes.get("version").toString().replace("\"", ""); } StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("Optimization") .policyName(policyName) .description(policyDescription) .onapName(onapName) .configName(null) .serviceType(servicModel) .uuid(null) .msLocation(null) .jsonBody(optimizationAttributes.toString()) .priority(priority) .version(version) .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(), "ConfigOptimization"); LOGGER.info("Response: " + response); return response; } }
OptimizationPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } String servicModel = null; String policyDescription = null; String priority = null; String version = null; String onapName = policyParameters.getOnapName(); JsonObject optimizationAttributes = null; try { optimizationAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody()); } catch (JsonException | IllegalStateException e) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " + policyParameters.getConfigBody(); LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e); return null; } if (optimizationAttributes.get("service") != null) { servicModel = optimizationAttributes.get("service").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("description")) { policyDescription = optimizationAttributes.get("description").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("priority")) { priority = optimizationAttributes.get("priority").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("version")) { version = optimizationAttributes.get("version").toString().replace("\"", ""); } StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("Optimization") .policyName(policyName) .description(policyDescription) .onapName(onapName) .configName(null) .serviceType(servicModel) .uuid(null) .msLocation(null) .jsonBody(optimizationAttributes.toString()) .priority(priority) .version(version) .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(), "ConfigOptimization"); LOGGER.info("Response: " + response); return response; } OptimizationPolicyService(String policyName, String policyScope, PolicyParameters policyParameters,
                                     String date); }
OptimizationPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } String servicModel = null; String policyDescription = null; String priority = null; String version = null; String onapName = policyParameters.getOnapName(); JsonObject optimizationAttributes = null; try { optimizationAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody()); } catch (JsonException | IllegalStateException e) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " + policyParameters.getConfigBody(); LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e); return null; } if (optimizationAttributes.get("service") != null) { servicModel = optimizationAttributes.get("service").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("description")) { policyDescription = optimizationAttributes.get("description").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("priority")) { priority = optimizationAttributes.get("priority").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("version")) { version = optimizationAttributes.get("version").toString().replace("\"", ""); } StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("Optimization") .policyName(policyName) .description(policyDescription) .onapName(onapName) .configName(null) .serviceType(servicModel) .uuid(null) .msLocation(null) .jsonBody(optimizationAttributes.toString()) .priority(priority) .version(version) .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(), "ConfigOptimization"); LOGGER.info("Response: " + response); return response; } OptimizationPolicyService(String policyName, String policyScope, PolicyParameters policyParameters,
                                     String date); String getMessage(); String getResult(boolean updateFlag); }
OptimizationPolicyService { public String getResult(boolean updateFlag) throws PolicyException { String response = null; String operation = null; if (updateFlag) { operation = "update"; } else { operation = "create"; } String servicModel = null; String policyDescription = null; String priority = null; String version = null; String onapName = policyParameters.getOnapName(); JsonObject optimizationAttributes = null; try { optimizationAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody()); } catch (JsonException | IllegalStateException e) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " + policyParameters.getConfigBody(); LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e); return null; } if (optimizationAttributes.get("service") != null) { servicModel = optimizationAttributes.get("service").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("description")) { policyDescription = optimizationAttributes.get("description").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("priority")) { priority = optimizationAttributes.get("priority").toString().replace("\"", ""); } if (optimizationAttributes.containsKey("version")) { version = optimizationAttributes.get("version").toString().replace("\"", ""); } StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() .configPolicyType("Optimization") .policyName(policyName) .description(policyDescription) .onapName(onapName) .configName(null) .serviceType(servicModel) .uuid(null) .msLocation(null) .jsonBody(optimizationAttributes.toString()) .priority(priority) .version(version) .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(), "ConfigOptimization"); LOGGER.info("Response: " + response); return response; } OptimizationPolicyService(String policyName, String policyScope, PolicyParameters policyParameters,
                                     String date); String getMessage(); String getResult(boolean updateFlag);  }