diff options
26 files changed, 305 insertions, 459 deletions
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java index e1f709779..72d671f87 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +76,7 @@ public class EngineServiceInfoResponseTest { assertTrue(response.equals(response)); assertFalse(response.equals(null)); - assertFalse(response.equals(new StartEngine(new AxArtifactKey()))); + assertFalse(response.equals((Object)new StartEngine(new AxArtifactKey()))); response = new EngineServiceInfoResponse(null, false, null); EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null); diff --git a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java index 58f07b9da..939b104d1 100644 --- a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java +++ b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java @@ -21,25 +21,18 @@ package org.onap.policy.apex.examples.bbs; - - import java.io.BufferedReader; import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.StringWriter; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.security.cert.X509Certificate; import java.util.Base64; -import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -49,6 +42,9 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; + +import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; +import org.onap.policy.common.utils.network.NetworkUtil; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; import org.w3c.dom.Document; @@ -60,141 +56,39 @@ import org.xml.sax.InputSource; * The Class WebClient act as rest client for BBS usecase. */ public class WebClient { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(WebClient.class); - /** - * Disable ssl verification. - */ - private static void disableCertificateValidation() { - try { - TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(X509Certificate[] certs, String authType) { - } - - public void checkServerTrusted(X509Certificate[] certs, String authType) { - } - } - }; - - - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - - HostnameVerifier allHostsValid = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); - } catch (Exception e) { - LOGGER.error("httpsRequest Exception " + e); - } - } + // Duplicated string constants + private static final String BBS_POLICY = "BBS Policy"; /** * Send simple https rest request. * - * @param requestUrl url - * @param requestMethod method eg POST/GET/PUT - * @param outputStr Data - * @param username Simple Username - * @param pass Simple password + * @param requestUrl url + * @param requestMethod method eg POST/GET/PUT + * @param outputStr Data + * @param username Simple Username + * @param pass Simple password * @param contentType http content type - * @param fillApp If required to fill app details - * @param disableSSl If disabling ssl checking - * @return String response message + * @apram secureHttp flag indicating if HTTPS should be used + * @return String response message */ - public String httpsRequest(String requestUrl, String requestMethod, - String outputStr, String username, String pass, - String contentType, boolean fillApp, boolean disableSSl) { + public String httpRequest(String requestUrl, String requestMethod, String outputStr, String username, String pass, + String contentType, boolean secureHttp) { String result = ""; - StringBuffer buffer = new StringBuffer(); + StringBuilder builder = new StringBuilder(); try { LOGGER.info("httpsRequest starts " + requestUrl + " method " + requestMethod); - if (disableSSl) { - disableCertificateValidation(); - } - URL url = new URL(requestUrl); - HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection(); - httpUrlConn.setDoOutput(true); - httpUrlConn.setDoInput(true); - httpUrlConn.setUseCaches(false); - - if ((username != null) && (pass != null)) { - httpUrlConn.setRequestProperty("Authorization", getAuth(username, pass)); - } else { - LOGGER.warn("Authorization information missing"); - } - - httpUrlConn.setRequestProperty("Content-Type", contentType); - httpUrlConn.setRequestProperty("Accept", contentType); - if (fillApp) { - httpUrlConn.setRequestProperty("X-FromAppId", "BBS Policy"); - httpUrlConn.setRequestProperty("X-TransactionId", "BBS Policy"); - } - httpUrlConn.setRequestMethod(requestMethod); + disableCertificateValidation(); - if ("GET".equalsIgnoreCase(requestMethod)) { - httpUrlConn.connect(); - } - - if (null != outputStr) { - OutputStream outputStream = httpUrlConn.getOutputStream(); - outputStream.write(outputStr.getBytes(StandardCharsets.UTF_8)); - outputStream.close(); + URL url = new URL(requestUrl); + HttpURLConnection httpUrlConn = null; + if (secureHttp) { + httpUrlConn = (HttpsURLConnection) url.openConnection(); } - - try (InputStream inputStream = httpUrlConn.getInputStream()) { - try (InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { - try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { - String str; - while ((str = bufferedReader.readLine()) != null) { - buffer.append(str); - } - } - } - httpUrlConn.disconnect(); - result = buffer.toString(); + else { + httpUrlConn = (HttpURLConnection) url.openConnection(); } - LOGGER.info("httpsRequest success "); - } catch (Exception ce) { - LOGGER.error("httpsRequest Exception " + ce); - } - return result; - } - - /** - * Send simple https rest request. - * - * @param requestUrl url - * @param requestMethod method eg POST/GET/PUT - * @param outputStr Data - * @param username Simple Username - * @param pass Simple password - * @param contentType http content type - * @param fillApp If required to fill app details - * @param disableSSl If disabling ssl checking - * @return String response message - */ - public String httpRequest(String requestUrl, String requestMethod, - String outputStr, String username, String pass, - String contentType, boolean fillApp, boolean disableSSl) { - String result = ""; - StringBuffer buffer = new StringBuffer(); - try { - LOGGER.info("httpRequest starts " + requestUrl + " method " + requestMethod); - if (disableSSl) { - disableCertificateValidation(); - } - URL url = new URL(requestUrl); - HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection(); httpUrlConn.setDoOutput(true); httpUrlConn.setDoInput(true); httpUrlConn.setUseCaches(false); @@ -207,10 +101,8 @@ public class WebClient { httpUrlConn.setRequestProperty("Content-Type", contentType); httpUrlConn.setRequestProperty("Accept", contentType); - if (fillApp) { - httpUrlConn.setRequestProperty("X-FromAppId", "BBS Policy"); - httpUrlConn.setRequestProperty("X-TransactionId", "BBS Policy"); - } + httpUrlConn.setRequestProperty("X-FromAppId", BBS_POLICY); + httpUrlConn.setRequestProperty("X-TransactionId", BBS_POLICY); httpUrlConn.setRequestMethod(requestMethod); if ("GET".equalsIgnoreCase(requestMethod)) { @@ -223,17 +115,14 @@ public class WebClient { outputStream.close(); } - try (InputStream inputStream = httpUrlConn.getInputStream()) { - try (InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { - try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { - String str; - while ((str = bufferedReader.readLine()) != null) { - buffer.append(str); - } - } + try (BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(httpUrlConn.getInputStream(), StandardCharsets.UTF_8))) { + String str; + while ((str = bufferedReader.readLine()) != null) { + builder.append(str); } httpUrlConn.disconnect(); - result = buffer.toString(); + result = builder.toString(); } LOGGER.info("httpsRequest success "); } catch (Exception ce) { @@ -243,18 +132,6 @@ public class WebClient { } /** - * Return Basic Authentication String. - * - * @param userName UserName - * @param password PassWord - * @return Basic Authentication - */ - private String getAuth(String userName, String password) { - String userCredentials = userName + ":" + password; - return ("Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes(StandardCharsets.UTF_8))); - } - - /** * Pretty print xml string. * * @param xml Input string @@ -264,21 +141,19 @@ public class WebClient { public String toPrettyString(String xml, int indent) { try { try (ByteArrayInputStream br = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) { - Document document = DocumentBuilderFactory.newInstance() - .newDocumentBuilder() - .parse(new InputSource(br)); + Document document = + DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(br)); document.normalize(); XPath path = XPathFactory.newInstance().newXPath(); - NodeList nodeList = (NodeList) path.evaluate("//text()[normalize-space()='']", - document, - XPathConstants.NODESET); + NodeList nodeList = + (NodeList) path.evaluate("//text()[normalize-space()='']", document, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); ++i) { Node node = nodeList.item(i); node.getParentNode().removeChild(node); } - + TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setAttribute("indent-number", indent); Transformer transformer = transformerFactory.newTransformer(); @@ -291,7 +166,37 @@ public class WebClient { return stringWriter.toString(); } } catch (Exception e) { - throw new RuntimeException(e); + throw new ApexRuntimeException("pretiffication failed", e); } } + + /** + * Disable ssl verification. + */ + private static void disableCertificateValidation() { + try { + TrustManager[] trustAllCerts = NetworkUtil.getAlwaysTrustingManager(); + + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + + HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); + + } catch (Exception e) { + LOGGER.error("certificate validation Exception " + e); + } + } + + /** + * Return Basic Authentication String. + * + * @param userName UserName + * @param password PassWord + * @return Basic Authentication + */ + private String getAuth(String userName, String password) { + String userCredentials = userName + ":" + password; + return ("Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes(StandardCharsets.UTF_8))); + } } diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js index 419ce4350..6e72e618c 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +33,7 @@ var attachmentPoint = executor.inFields.get("attachmentPoint"); var requestID = executor.inFields.get("requestID"); var serviceInstanceId = executor.inFields.get("serviceInstanceId"); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); executor.logger.info(NomadicONTContext); var jsonObj; @@ -42,7 +42,6 @@ var aaiUpdateResult = true; var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient"); var client = new wbClient(); - /* Get AAI URL from Configuration file. */ var AAI_URL = "localhost:8080"; var CUSTOMER_ID = requestID; @@ -55,8 +54,7 @@ var results; var putUrl; var service_instance; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); var line; while ((line = br.readLine()) != null) { if (line.startsWith("AAI_URL")) { @@ -81,14 +79,12 @@ executor.logger.info("AAI_URL " + AAI_URL); /* Get service instance Id from AAI */ try { - var urlGet = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + - SERVICE_INSTANCE_ID + "?format=resource_and_url"; + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result.toString()); @@ -100,9 +96,8 @@ try { service_instance_id = service_instance['service-instance-id']; resource_version = service_instance['resource-version']; relationship_list = service_instance['relationship-list']; - executor.logger.info("After Parse service_instance " + JSON.stringify( - service_instance, null, 4) + "\n url " + putUrl + - "\n Service instace Id " + service_instance_id); + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + service_instance_id); if (result == "") { aaiUpdateResult = false; @@ -112,21 +107,16 @@ try { aaiUpdateResult = false; } - - /* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */ var putUpddateServInstance; putUpddateServInstance = service_instance; try { if (aaiUpdateResult == true) { putUpddateServInstance["orchestration-status"] = "active"; - executor.logger.info("ready to putAfter Parse " + JSON.stringify( - putUpddateServInstance, null, 4)); - var urlPut = HTTP_PROTOCOL + AAI_URL + - putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify( - putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -138,11 +128,9 @@ try { aaiUpdateResult = false; } -if (!service_instance.hasOwnProperty('input-parameters') || !service_instance - .hasOwnProperty('metadata')) { +if (!service_instance.hasOwnProperty('input-parameters') || !service_instance.hasOwnProperty('metadata')) { aaiUpdateResult = false; - executor.logger.info( - "Validate data failed. input-parameters or metadata is missing"); + executor.logger.info("Validate data failed. input-parameters or metadata is missing"); } /* update logical link in pnf */ @@ -154,25 +142,22 @@ try { var pnfUpdate; var relationShips = relationship_list["relationship"]; - for (var i = 0; i < relationShips.length; i++) { if (relationShips[i]["related-to"] == "pnf") { - var relationship_data = relationShips[i]["relationship-data"]; - for (var j = 0; j < relationship_data.length; j++) { - if (relationship_data[j]["relationship-key"] == "pnf.pnf-name") { + var relationship_data = relationShips[i]["relationship-data"]; + for (var j = 0; j < relationship_data.length; j++) { + if (relationship_data[j]["relationship-key"] == "pnf.pnf-name") { pnfName = relationship_data[j]['relationship-value']; break; - } - } + } + } } } executor.logger.info("pnf-name found " + pnfName); /* 1. Get PNF */ - var urlGetPnf = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; - pnfResponse = client.httpsRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + var urlGetPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + pnfResponse = client.httpRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGetPnf + " " + pnfResponse); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -181,18 +166,17 @@ try { pnfUpdate = JSON.parse(pnfResponse.toString()); executor.logger.info(JSON.stringify(pnfUpdate, null, 4)); - /*2. Create logical link */ var link_name = attachmentPoint; var logicalLink = { - "link-name": link_name, - "in-maint": false, - "link-type": "attachment-point" - }; - var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + link_name; - result = client.httpsRequest(urlNewLogicalLink, "PUT", JSON.stringify(logicalLink), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + "link-name" : link_name, + "in-maint" : false, + "link-type" : "attachment-point" + }; + var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name; + result = client.httpRequest(urlNewLogicalLink, "PUT", JSON.stringify(logicalLink), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlNewLogicalLink + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -202,9 +186,10 @@ try { /*3. Update pnf with new relation*/ for (var i = 0; i < pnfUpdate["relationship-list"]["relationship"].length; i++) { if (pnfUpdate["relationship-list"]["relationship"][i]['related-to'] == 'logical-link') { - pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + link_name; + pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name; for (var j = 0; j < pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'].length; j++) { - if (pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-key'] == "logical-link.link-name") { + if (pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-key'] == "logical-link.link-name") { oldLinkName = pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value']; pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value'] = link_name; break; @@ -215,10 +200,9 @@ try { } executor.logger.info("Put pnf to aai " + JSON.stringify(pnfUpdate, null, 4)); - var urlPutPnf = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; - result = client.httpsRequest(urlPutPnf, "PUT", JSON.stringify(pnfUpdate), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + var urlPutPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + result = client.httpRequest(urlPutPnf, "PUT", JSON.stringify(pnfUpdate), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPutPnf + " " + result); /* If failure to retrieve data proceed to Failure */ @@ -229,18 +213,19 @@ try { /* Get and Delete the Stale logical link */ var oldLinkResult; var linkResult; - var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + oldLinkName; - linkResult = client.httpsRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); - executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " " + linkResult.hasOwnProperty("link-name")); + var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + oldLinkName; + linkResult = client + .httpRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); + executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " " + + linkResult.hasOwnProperty("link-name")); oldLinkResult = JSON.parse(linkResult.toString()); if (oldLinkResult.hasOwnProperty("link-name") == true) { var res_version = oldLinkResult["resource-version"]; var urlDelOldLogicalLink = urlOldLogicalLink + "?resource-version=" + res_version; executor.logger.info("Delete called for " + urlDelOldLogicalLink); - result = client.httpsRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Delete called for " + urlDelOldLogicalLink + " result " + result); } } @@ -262,8 +247,7 @@ if (aaiUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); @@ -278,4 +262,4 @@ function IsValidJSONString(str) { } return true; } -/* Utility functions End */
\ No newline at end of file +/* Utility functions End */ diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js index 5d18f23b0..7e116f0ea 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,11 +33,10 @@ var attachmentPoint = executor.inFields.get("attachmentPoint"); var requestID = executor.inFields.get("requestID"); var serviceInstanceId = executor.inFields.get("serviceInstanceId"); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); executor.logger.info(NomadicONTContext); -//Get the AAI URL from configuraiotn file +// Get the AAI URL from configuraiotn file var AAI_URL = "localhost:8080"; var CUSTOMER_ID = requestID; var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test"; @@ -48,8 +48,7 @@ var client = new wbClient(); var AAI_USERNAME = null; var AAI_PASSWORD = null; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); // read line by line var line; while ((line = br.readLine()) != null) { @@ -74,14 +73,12 @@ executor.logger.info("AAI_URL " + AAI_URL); var aaiUpdateResult = true; /* Get service instance Id from AAI */ try { - var urlGet = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + - SERVICE_INSTANCE_ID + "?format=resource_and_url"; + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result); @@ -90,9 +87,8 @@ try { results = jsonObj['results'][0]; putUrl = results['url']; service_instance = results['service-instance']; - executor.logger.info("After Parse service_instance " + JSON.stringify( - service_instance, null, 4) + "\n url " + putUrl + - "\n Service instace Id " + SERVICE_INSTANCE_ID); + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + SERVICE_INSTANCE_ID); if (result == "") { aaiUpdateResult = false; @@ -104,21 +100,17 @@ try { var putUpddateServInstance = service_instance; putUpddateServInstance['orchestration-status'] = "created"; -executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, - 4)); +executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, 4)); var resource_version = putUpddateServInstance['resource-version']; var putUrl = NomadicONTContext.get("url"); -/*BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ]*/ +/* BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ] */ try { if (aaiUpdateResult == true) { - executor.logger.info("ready to putAfter Parse " + JSON.stringify( - putUpddateServInstance, null, 4)); - var urlPut = HTTP_PROTOCOL + AAI_URL + - putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify( - putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -139,9 +131,8 @@ if (aaiUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); -executor.logger.info("End Execution AAIServiceCreateTask.js");
\ No newline at end of file +executor.logger.info("End Execution AAIServiceCreateTask.js"); diff --git a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js index 55f5a1ba1..d588eaf48 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +39,7 @@ var uuidType = Java.type("java.util.UUID"); var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient"); var client = new wbClient(); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); var sdncUUID = uuidType.randomUUID(); executor.logger.info(NomadicONTContext); var jsonObj; @@ -50,8 +50,7 @@ var SVC_NOTIFICATION_URL; var putUpddateServInstance = JSON.parse(NomadicONTContext.get("aai_message")); var input_param = JSON.parse(putUpddateServInstance['input-parameters']); try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); var line; while ((line = br.readLine()) != null) { if (line.startsWith("SDNC_URL")) { @@ -60,8 +59,7 @@ try { } else if (line.startsWith("SVC_NOTIFICATION_URL")) { var str = line.split("="); SVC_NOTIFICATION_URL = str[str.length - 1]; - } - else if (line.startsWith("SDNC_USERNAME")) { + } else if (line.startsWith("SDNC_USERNAME")) { var str = line.split("="); SDNC_USERNAME = str[str.length - 1]; } else if (line.startsWith("SDNC_PASSWORD")) { @@ -79,12 +77,11 @@ var jsonObj; var sdncUpdateResult = true; /* BBS Policy calls SDN-C GR-API to delete AccessConnectivity VF ID */ -/* Prepare Data*/ +/* Prepare Data */ var xmlDeleteAccess = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlDeleteAccess += line; @@ -96,56 +93,39 @@ try { /* BBS Policy calls SDN-C GR-API to delete AccessConnectivity */ xmlDeleteAccess = xmlDeleteAccess.replace("svc_request_id_value", sdncUUID); -xmlDeleteAccess = xmlDeleteAccess.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlDeleteAccess = xmlDeleteAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlDeleteAccess = xmlDeleteAccess.replace("request_id_value", sdncUUID); xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", sdncUUID); -xmlDeleteAccess = xmlDeleteAccess.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlDeleteAccess = xmlDeleteAccess.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlDeleteAccess = xmlDeleteAccess.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlDeleteAccess = xmlDeleteAccess.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlDeleteAccess = xmlDeleteAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_name_value", "AccessConnectivity"); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value", getResourceUuid( input_param['service']['parameters']['resources'], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value", - "AccessConnectivity"); - -xmlDeleteAccess = xmlDeleteAccess.replace("vendor_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlDeleteAccess = xmlDeleteAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], - 'controller-service-id')); + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); executor.logger.info(client.toPrettyString(xmlDeleteAccess, 4)); try { - var urlPost1 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; - result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + var urlPost1 = HTTP_PROTOCOL + SDNC_URL + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml", + false); executor.logger.info("Data received From " + urlPost1 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -155,14 +135,13 @@ try { sdncUpdateResult = false; } -/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */ +/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */ -/* Prepare Data*/ +/* Prepare Data */ var xmlCreateAccess = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlCreateAccess += line; @@ -172,62 +151,47 @@ try { executor.logger.info("Failed to retrieve data " + err); } xmlCreateAccess = xmlCreateAccess.replace("svc_request_id_value", sdncUUID); -xmlCreateAccess = xmlCreateAccess.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlCreateAccess = xmlCreateAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlCreateAccess = xmlCreateAccess.replace("request_id_value", requestID); xmlCreateAccess = xmlCreateAccess.replace("service_id_value", sdncUUID); -xmlCreateAccess = xmlCreateAccess.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlCreateAccess = xmlCreateAccess.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlCreateAccess = xmlCreateAccess.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlCreateAccess = xmlCreateAccess.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlCreateAccess = xmlCreateAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlCreateAccess = xmlCreateAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlCreateAccess = xmlCreateAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "AccessConnectivity"); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", getResourceUuid( input_param['service']['parameters']['resources'], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", - "AccessConnectivity"); - -xmlCreateAccess = xmlCreateAccess.replace("vendor_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_manufacturer']); -xmlCreateAccess = xmlCreateAccess.replace("ont_sn_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_serial_num']); -xmlCreateAccess = xmlCreateAccess.replace("s_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'svlan')); -xmlCreateAccess = xmlCreateAccess.replace("c_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'cvlan')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlCreateAccess = xmlCreateAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlCreateAccess = xmlCreateAccess.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlCreateAccess = xmlCreateAccess.replace("s_vlan_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'svlan')); +xmlCreateAccess = xmlCreateAccess.replace("c_vlan_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'cvlan')); xmlCreateAccess = xmlCreateAccess.replace("remote_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'remote-id')); + putUpddateServInstance['metadata']['metadatum'], 'remote-id')); executor.logger.info(client.toPrettyString(xmlCreateAccess, 4)); try { if (sdncUpdateResult == true) { - var urlPost2 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; - result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + var urlPost2 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml", + false); executor.logger.info("Data received From " + urlPost2 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -238,12 +202,11 @@ try { sdncUpdateResult = false; } -/* BBS Policy calls SDN-C GR-API to create change Internet Profile */ +/* BBS Policy calls SDN-C GR-API to create change Internet Profile */ var xmlChangeProfile = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlChangeProfile += line; @@ -254,75 +217,56 @@ try { } xmlChangeProfile = xmlChangeProfile.replace("svc_request_id_value", sdncUUID); -xmlChangeProfile = xmlChangeProfile.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlChangeProfile = xmlChangeProfile.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlChangeProfile = xmlChangeProfile.replace("request_id_value", requestID); xmlChangeProfile = xmlChangeProfile.replace("service_id_value", sdncUUID); -xmlChangeProfile = xmlChangeProfile.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlChangeProfile = xmlChangeProfile.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlChangeProfile = xmlChangeProfile.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", - "InternetProfile"); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( - input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", - "InternetProfile"); - -xmlChangeProfile = xmlChangeProfile.replace("vendor_value", input_param[ - 'service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlChangeProfile = xmlChangeProfile.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlChangeProfile = xmlChangeProfile.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "InternetProfile"); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", "InternetProfile"); + +xmlChangeProfile = xmlChangeProfile.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); xmlChangeProfile = xmlChangeProfile.replace("service_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], - 'controller-service-id')); + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); xmlChangeProfile = xmlChangeProfile.replace("remote_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'remote-id')); -xmlChangeProfile = xmlChangeProfile.replace("ont_sn_value", input_param[ - 'service']['parameters']['requestInputs']['ont_ont_serial_num']); -xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlChangeProfile = xmlChangeProfile.replace("mac_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'rgw-mac-address')); + putUpddateServInstance['metadata']['metadatum'], 'remote-id')); +xmlChangeProfile = xmlChangeProfile.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("mac_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'rgw-mac-address')); xmlChangeProfile = xmlChangeProfile.replace("up_speed_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'up-speed')); + putUpddateServInstance['metadata']['metadatum'], 'up-speed')); xmlChangeProfile = xmlChangeProfile.replace("down_speed_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'down-speed')); + putUpddateServInstance['metadata']['metadatum'], 'down-speed')); xmlChangeProfile = xmlChangeProfile.replace("s_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'svlan')); + putUpddateServInstance['metadata']['metadatum'], 'svlan')); xmlChangeProfile = xmlChangeProfile.replace("c_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'cvlan')); + putUpddateServInstance['metadata']['metadatum'], 'cvlan')); executor.logger.info(client.toPrettyString(xmlChangeProfile, 4)); try { if (sdncUpdateResult == true) { - var urlPost3 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + var urlPost3 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; result = client.httpRequest(urlPost3, "POST", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + "application/xml", false); executor.logger.info("Data received From " + urlPost3 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -345,8 +289,7 @@ if (sdncUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); @@ -401,4 +344,4 @@ function IsValidJSONString(str) { } return true; } -/* Utility functions End */
\ No newline at end of file +/* Utility functions End */ diff --git a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js index 56be83628..90b1b0075 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,8 +84,8 @@ try { SERVICE_INSTANCE_ID + "?format=resource_and_url" executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result); @@ -122,8 +123,8 @@ try { putUpddateServInstance, null, 4)); var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { diff --git a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java index 8012c1e30..2ff9435b2 100644 --- a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java +++ b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.examples.bbs; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,13 +36,15 @@ import org.mockito.Mockito; public class WebClientTest { HttpsURLConnection mockedHttpsUrlConnection; String sampleString = "Response Code :200"; + /** * Set up the mocked REST manager. - * @throws IOException + * + * @throws IOException on I/O errors */ @Before public void setupMockedRest() throws IOException { - mockedHttpsUrlConnection = mock(HttpsURLConnection.class); + mockedHttpsUrlConnection = mock(HttpsURLConnection.class); InputStream inputStream = new ByteArrayInputStream(sampleString.getBytes()); when(mockedHttpsUrlConnection.getInputStream()).thenReturn(inputStream); Mockito.doNothing().when(mockedHttpsUrlConnection).connect(); @@ -50,17 +53,17 @@ public class WebClientTest { @Test public void httpsRequest() { WebClient cl = new WebClient(); - String result = cl.httpsRequest("https://some.random.url/data", "POST", null, - "admin", "admin", "application/json",true, true); - + String result = cl.httpRequest("https://some.random.url/data", "POST", null, "admin", "admin", + "application/json", true); + assertNotNull(result); } @Test public void httpRequest() { WebClient cl = new WebClient(); - String result = cl.httpRequest("http://some.random.url/data", "GET", null, - "admin", "admin", "application/json",true, true); - + String result = + cl.httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json", false); + assertNotNull(result); } @Test diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java index b00be2fd1..ee14a0606 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -65,7 +66,7 @@ public class AxKeyInfoTest { assertTrue(testKeyInfo.equals(testKeyInfo)); assertTrue(testKeyInfo.equals(clonedReferenceKey)); assertFalse(testKeyInfo.equals(null)); - assertFalse(testKeyInfo.equals(new AxArtifactKey())); + assertFalse(testKeyInfo.equals((Object)new AxArtifactKey())); assertFalse(testKeyInfo.equals(new AxKeyInfo(new AxArtifactKey()))); assertFalse(testKeyInfo.equals(new AxKeyInfo(key, UUID.randomUUID(), "Some Description"))); assertFalse(testKeyInfo.equals(new AxKeyInfo(key, uuid, "Some Description"))); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java index a1d272775..061df61a5 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +68,7 @@ public class AxKeyUseTest { assertTrue(keyUse.equals(keyUse)); assertTrue(keyUse.equals(clonedKeyUse)); - assertFalse(keyUse.equals("Hello")); + assertFalse(keyUse.equals((Object)"Hello")); assertTrue(keyUse.equals(new AxKeyUse(key))); assertEquals(0, keyUse.compareTo(keyUse)); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java index 27726a9b4..2745b95ac 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +93,7 @@ public class AxReferenceKeyTest { assertTrue(testReferenceKey.equals(testReferenceKey)); assertTrue(testReferenceKey.equals(clonedReferenceKey)); - assertFalse(testReferenceKey.equals("Hello")); + assertFalse(testReferenceKey.equals((Object)"Hello")); assertFalse(testReferenceKey.equals(new AxReferenceKey("PKN", "0.0.2", "PLN", "LN"))); assertFalse(testReferenceKey.equals(new AxReferenceKey("NPKN", "0.0.2", "PLN", "LN"))); assertFalse(testReferenceKey.equals(new AxReferenceKey("NPKN", "0.0.1", "PLN", "LN"))); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java index 6ca94ddc8..af0ef5f3c 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +74,7 @@ public class SupportApexBasicModelConceptsTester { assertTrue(model.equals(model)); assertTrue(model.equals(clonedModel)); assertFalse(model.equals(null)); - assertFalse(model.equals("Hello")); + assertFalse(model.equals((Object)"Hello")); clonedModel.getKey().setVersion("0.0.2"); assertFalse(model.equals(clonedModel)); clonedModel.getKey().setVersion("0.0.1"); @@ -95,7 +96,7 @@ public class SupportApexBasicModelConceptsTester { final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI); assertFalse(keyI.equals(null)); - assertFalse(keyI.equals(new AxArtifactKey())); + assertFalse(keyI.equals((Object)new AxArtifactKey())); assertTrue(keyI.equals(clonedKeyI)); clonedKeyI.setKey(new AxArtifactKey()); diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java index eb0db0da7..d0d994a05 100644 --- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java +++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -36,7 +37,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; /** * Context album tests. - * + * * @author Liam Fallon (liam.fallon@ericsson.com) */ public class ContextAlbumsTest { @@ -125,7 +126,7 @@ public class ContextAlbumsTest { assertTrue(album.equals(album)); assertTrue(album.equals(clonedAlbum)); assertFalse(album.equals(null)); - assertFalse(album.equals("Hello")); + assertFalse(album.equals((Object)"Hello")); assertFalse(album.equals(new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey()))); assertFalse(album.equals(new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey()))); assertFalse(album.equals(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey()))); @@ -192,7 +193,7 @@ public class ContextAlbumsTest { assertTrue(albums.equals(albums)); assertTrue(albums.equals(clonedAlbums)); assertFalse(albums.equals(null)); - assertFalse(albums.equals("Hello")); + assertFalse(albums.equals((Object)"Hello")); assertFalse(albums.equals(new AxContextAlbums(new AxArtifactKey()))); assertEquals(0, albums.compareTo(albums)); diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java index fbf97881f..d2a4bc53a 100644 --- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java +++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +67,7 @@ public class ContextModelTest { assertTrue(model.equals(model)); assertTrue(model.equals(clonedModel)); - assertFalse(model.equals("Hello")); + assertFalse(model.equals((Object)"Hello")); assertFalse(model.equals(new AxContextModel(new AxArtifactKey()))); assertFalse(model.equals(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation()))); diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java index 392bdd53b..fe834b43e 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +116,7 @@ public class EngineModelTest { assertTrue(model.equals(model)); assertTrue(model.equals(clonedModel)); - assertFalse(model.equals("Hello")); + assertFalse(model.equals((Object)"Hello")); assertFalse(model.equals(new AxEngineModel(new AxArtifactKey()))); assertFalse(model.equals(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats))); diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java index 86a8c4763..c6fde1cdf 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,7 +141,7 @@ public class EngineStatsTest { assertTrue(stats.equals(stats)); assertTrue(stats.equals(clonedStats)); assertFalse(stats.equals(null)); - assertFalse(stats.equals("Hello")); + assertFalse(stats.equals((Object)"Hello")); assertFalse(stats.equals(new AxEngineStats(new AxReferenceKey()))); assertEquals(0, stats.compareTo(stats)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java index 74f092a94..99d377261 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +65,7 @@ public class EventModelTest { assertTrue(model.equals(model)); assertTrue(model.equals(clonedModel)); - assertFalse(model.equals("Hello")); + assertFalse(model.equals((Object)"Hello")); assertFalse(model.equals(new AxEventModel(new AxArtifactKey()))); assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey)))); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java index 4a17c2a48..b9b643e47 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -194,7 +195,7 @@ public class EventsTest { assertTrue(event.equals(event)); assertTrue(event.equals(clonedEvent)); assertFalse(event.equals(null)); - assertFalse(event.equals("Hello")); + assertFalse(event.equals((Object)"Hello")); assertFalse( event.equals(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap))); assertFalse(event.equals(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap))); @@ -277,7 +278,7 @@ public class EventsTest { assertTrue(events.equals(events)); assertTrue(events.equals(clonedEvents)); assertFalse(events.equals(null)); - assertFalse(events.equals("Hello")); + assertFalse(events.equals((Object)"Hello")); assertFalse(events.equals(new AxEvents(new AxArtifactKey()))); assertEquals(0, events.compareTo(events)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java index 3d88b4c81..fe3c9e6b7 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +118,7 @@ public class FieldTest { assertTrue(field.equals(field)); assertTrue(field.equals(clonedField)); assertFalse(field.equals(null)); - assertFalse(field.equals("Hello")); + assertFalse(field.equals((Object)"Hello")); assertFalse(field.equals(new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false))); assertFalse(field.equals(new AxField(fieldKey, AxArtifactKey.getNullKey(), false))); assertFalse(field.equals(new AxField(fieldKey, schemaKey, false))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java index 70db66348..f9f424880 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,7 +163,7 @@ public class LogicTest { assertTrue(logic.equals(logic)); assertTrue(logic.equals(clonedLogic)); assertFalse(logic.equals(null)); - assertFalse(logic.equals("Hello")); + assertFalse(logic.equals((Object)"Hello")); assertFalse(logic.equals(new AxLogic(AxReferenceKey.getNullKey(), "LogicFlavour", "Logic"))); assertFalse(logic.equals(new AxLogic(logicKey, "AnotherLogicFlavour", "Logic"))); assertFalse(logic.equals(new AxLogic(logicKey, "LogicFlavour", "AnotherLogic"))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java index e1264e887..1974413ff 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -240,7 +241,7 @@ public class PoliciesTest { assertTrue(policy.equals(policy)); assertTrue(policy.equals(clonedPolicy)); assertFalse(policy.equals(null)); - assertFalse(policy.equals("Hello")); + assertFalse(policy.equals((Object)"Hello")); assertFalse(policy.equals( new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState))); assertFalse(policy.equals(new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState))); @@ -324,7 +325,7 @@ public class PoliciesTest { assertTrue(policies.equals(policies)); assertTrue(policies.equals(clonedPolicies)); assertFalse(policies.equals(null)); - assertFalse(policies.equals("Hello")); + assertFalse(policies.equals((Object)"Hello")); assertFalse(policies.equals(new AxPolicies(new AxArtifactKey()))); assertEquals(0, policies.compareTo(policies)); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java index 6c93efde0..d2c6b1bdb 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +90,7 @@ public class PolicyModelTest { assertTrue(model.equals(model)); assertTrue(model.equals(clonedModel)); - assertFalse(model.equals("Hello")); + assertFalse(model.equals((Object)"Hello")); assertFalse(model.equals(new AxPolicyModel(new AxArtifactKey()))); assertFalse(model.equals(new AxPolicyModel(AxArtifactKey.getNullKey(), new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java index 901d641cb..7d1826bd0 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +120,7 @@ public class StateOutputTest { assertTrue(so.equals(so)); assertTrue(so.equals(clonedPar)); assertFalse(so.equals(null)); - assertFalse(so.equals("Hello")); + assertFalse(so.equals((Object)"Hello")); assertFalse(so.equals(new AxStateOutput(AxReferenceKey.getNullKey(), eKey, nsKey))); assertFalse(so.equals(new AxStateOutput(soKey, new AxArtifactKey(), nsKey))); assertFalse(so.equals(new AxStateOutput(soKey, eKey, new AxReferenceKey()))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java index cfc8a494e..b37d49030 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,7 +136,7 @@ public class StateTaskReferenceTest { assertTrue(stRef.equals(stRef)); assertTrue(stRef.equals(clonedStRef)); assertFalse(stRef.equals(null)); - assertFalse(stRef.equals("Hello")); + assertFalse(stRef.equals((Object)"Hello")); assertFalse(stRef.equals( new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey))); assertFalse(stRef.equals(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java index ecc8a4f66..fe059724f 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +100,7 @@ public class TaskParameterTest { assertTrue(par.equals(par)); assertTrue(par.equals(clonedPar)); assertFalse(par.equals(null)); - assertFalse(par.equals("Hello")); + assertFalse(par.equals((Object)"Hello")); assertFalse(par.equals(new AxTaskParameter(AxReferenceKey.getNullKey(), "DefaultValue"))); assertFalse(par.equals(new AxTaskParameter(parKey, "OtherDefaultValue"))); assertTrue(par.equals(new AxTaskParameter(parKey, "DefaultValue"))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java index 248dd6307..1041d4219 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -228,7 +229,7 @@ public class TasksTest { assertTrue(task.equals(task)); assertTrue(task.equals(clonedTask)); assertFalse(task.equals(null)); - assertFalse(task.equals("Hello")); + assertFalse(task.equals((Object)"Hello")); assertFalse(task.equals(new AxTask(new AxArtifactKey(), ifMap, ofMap, tpMap, ctxtSet, tl))); assertFalse(task.equals(new AxTask(taskKey, ifEmptyMap, ofMap, tpMap, ctxtSet, tl))); assertFalse(task.equals(new AxTask(taskKey, ifMap, ofEmptyMap, tpMap, ctxtSet, tl))); @@ -311,7 +312,7 @@ public class TasksTest { assertTrue(tasks.equals(tasks)); assertTrue(tasks.equals(clonedTasks)); assertFalse(tasks.equals(null)); - assertFalse(tasks.equals("Hello")); + assertFalse(tasks.equals((Object)"Hello")); assertFalse(tasks.equals(new AxTasks(new AxArtifactKey()))); assertEquals(0, tasks.compareTo(tasks)); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java index f66dbfe9e..fc5754ebc 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,6 @@ public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameter public static final String KAFKA_EVENT_CONSUMER_PLUGIN_CLASS = ApexKafkaConsumer.class.getName(); // Repeated strings in messages - private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string"; private static final String ENTRY = "entry "; private static final String KAFKA_PROPERTIES = "kafkaProperties"; |