From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:14:21 -0800 Subject: Second part of onap rename This is the second commit of the rename. The folder structure is renamed for appc-adapters and appc-config in this commit. Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../onap/sdnc/config/audit/SliAuditActivator.java | 62 +++++++++ .../onap/sdnc/config/audit/SliAuditConstant.java | 64 ++++++++++ .../sdnc/config/audit/node/CompareCliData.java | 43 +++++++ .../sdnc/config/audit/node/CompareConstants.java | 43 +++++++ .../config/audit/node/CompareDataInterface.java | 27 ++++ .../sdnc/config/audit/node/CompareJsonData.java | 82 ++++++++++++ .../onap/sdnc/config/audit/node/CompareNode.java | 138 +++++++++++++++++++++ .../sdnc/config/audit/node/CompareXmlData.java | 105 ++++++++++++++++ .../onap/sdnc/config/audit/node/Parameters.java | 102 +++++++++++++++ .../sdnc/config/audit/SliAuditActivator.java | 62 --------- .../sdnc/config/audit/SliAuditConstant.java | 64 ---------- .../sdnc/config/audit/node/CompareCliData.java | 43 ------- .../sdnc/config/audit/node/CompareConstants.java | 43 ------- .../config/audit/node/CompareDataInterface.java | 27 ---- .../sdnc/config/audit/node/CompareJsonData.java | 82 ------------ .../sdnc/config/audit/node/CompareNode.java | 138 --------------------- .../sdnc/config/audit/node/CompareXmlData.java | 105 ---------------- .../sdnc/config/audit/node/Parameters.java | 102 --------------- .../sdnc/config/audit/node/TestCompareNodeCli.java | 70 +++++++++++ .../config/audit/node/TestCompareNodeJson.java | 63 ++++++++++ .../sdnc/config/audit/node/TestCompareNodeXml.java | 85 +++++++++++++ .../sdnc/config/audit/node/TestCompareNodeCli.java | 70 ----------- .../config/audit/node/TestCompareNodeJson.java | 63 ---------- .../sdnc/config/audit/node/TestCompareNodeXml.java | 85 ------------- 24 files changed, 884 insertions(+), 884 deletions(-) create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditActivator.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditConstant.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareCliData.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareConstants.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareDataInterface.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareJsonData.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareNode.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareXmlData.java create mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/Parameters.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java delete mode 100644 appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java create mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java create mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java create mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeXml.java delete mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java delete mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java delete mode 100644 appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java (limited to 'appc-config/appc-config-audit') diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditActivator.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditActivator.java new file mode 100644 index 000000000..648d8ea86 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditActivator.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit; + +import java.util.LinkedList; +import java.util.List; + +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; + +public class SliAuditActivator implements BundleActivator{ + + private List registrations = new LinkedList(); + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(SliAuditActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception + { + + CompareNode compareNodePlugin = new CompareNode(); + log.info("Registering service "+ compareNodePlugin.getClass().getName()); + registrations.add(ctx.registerService(compareNodePlugin.getClass().getName(), compareNodePlugin, null)); + + } + @Override + public void stop(BundleContext arg0) throws Exception + { + for (ServiceRegistration registration: registrations) + { + registration.unregister(); + registration = null; + } + + } + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditConstant.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditConstant.java new file mode 100644 index 000000000..0bfaa1e36 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/SliAuditConstant.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit; + +public class SliAuditConstant { + + public static String STRING_ENCODING = "utf-8"; + public static String Y = "Y"; + public static String N = "N"; + public static String DATA_TYPE_TEXT = "TEXT"; + public static String DATA_TYPE_JSON = "JSON"; + public static String DATA_TYPE_XML = "XML"; + public static String DATA_TYPE_SQL = "SQL"; + + public static String INPUT_PARAM_JSON_DATA = "jsonData"; + public static String INPUT_PARAM_IS_ESCAPED = "isEscaped"; + public static String INPUT_PARAM_BLOCK_KEYS = "blockKeys"; + public static String INPUT_PARAM_LOG_DATA = "logData"; + public static String INPUT_PARAM_CHECK_DATA = "checkData"; + public static String INPUT_PARAM_ESCAPE_DATA = "escapeData"; + public static String INPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; + public static String INPUT_PARAM_DATA_TYPE = "dataType"; + public static String INPUT_PARAM_FILE_NAME = "fileName"; + + public static String INPUT_PARAM_TEMPLATE_DATA = "templateData"; + public static String INPUT_PARAM_TEMPLATE_FILE = "templateFile"; + public static String INPUT_PARAM_TEMPLATE_TYPE = "templateType"; + public static String INPUT_PARAM_DO_PRETTY_OUTPUT = "doPrettyOutput"; + public static String INPUT_PARAM_REQUEST_DATA = "requestData"; + public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix"; + + + public static String OUTPUT_PARAM_MERGED_DATA = "mergedData"; + public static String OUTPUT_PARAM_TRANSFORMED_DATA = "transformedData"; + public static String OUTPUT_PARAM_FILE_DATA = "fileData"; + public static String OUTPUT_PARAM_PARSED_ERROR = "parsedError"; + public static String OUTPUT_PARAM_DATA_TYPE = "dataType"; + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static String OUTPUT_PARAM_ESCAPE_DATA = "escapeData"; + public static String OUTPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; + + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareCliData.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareCliData.java new file mode 100644 index 000000000..969d126bb --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareCliData.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +public class CompareCliData implements CompareDataInterface{ + + String payloadX; + String payloadY; + + public CompareCliData(String payloadX, String payloadY) + { + super(); + this.payloadX = payloadX; + this.payloadY = payloadY; + } + + @Override + public boolean compare() throws Exception + { + if(payloadX != null && payloadX.equals(payloadY)) + return true; + else + return false; + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareConstants.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareConstants.java new file mode 100644 index 000000000..42b18d5c3 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareConstants.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +public class CompareConstants { + + + public static final String FORMAT_JSON = "RESTCONF"; + public static final String FORMAT_XML = "XML"; + public static final String FORMAT_CLI = "CLI"; + public static final String NETCONF_XML = "NETCONF-XML"; + public static final String RESTCONF_XML = "RESTCONF-XML"; + + + public static final String STATUS_FAILURE = "FAILURE"; + public static final String RESPONSE_STATUS = "STATUS"; + public static final String STATUS_SUCCESS = "SUCCESS"; + + public static final String ERROR_CODE = "Error-code"; + + public static final String ERROR_MESSAGE = "Error-Message"; + public static final String ERROR_MESSAGE_DEATIL = "Compare Node Failed-Internal Error.See karaf log file"; + + public static final String NO_MATCH_MESSAGE = "The configurations do not match"; +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareDataInterface.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareDataInterface.java new file mode 100644 index 000000000..95f154e2e --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareDataInterface.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +public interface CompareDataInterface +{ + boolean compare() throws Exception; +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareJsonData.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareJsonData.java new file mode 100644 index 000000000..422ac30ac --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareJsonData.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.io.IOException; +import java.util.Map; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class CompareJsonData implements CompareDataInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareJsonData.class); + + String payloadX; + String payloadY; + + public CompareJsonData(String payloadX, String payloadY) + { + this.payloadX = payloadX; + this.payloadY = payloadY; + } + + @Override + public boolean compare() throws Exception + { + + ObjectMapper dataMapper = new ObjectMapper(); + boolean match = false; + try + { + Map controlData = (Map)(dataMapper.readValue(payloadX, Map.class)); + Map testData = (Map)(dataMapper.readValue(payloadY, Map.class)); + + log.debug("Control Data :" + controlData); + log.debug("testData Data :" + testData); + + if(controlData.equals(testData)) + match=true; + } + catch(JsonParseException e) + { + throw new Exception(e.getMessage()); + } + catch(JsonMappingException e) + { + throw new Exception(e.getMessage()); + } + catch(IOException ioe) + { + throw new Exception(ioe.getMessage()); + } + + return match; + } + + + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareNode.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareNode.java new file mode 100644 index 000000000..710b5ffd1 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareNode.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.util.HashMap; +import java.util.Map; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + +public class CompareNode implements SvcLogicJavaPlugin +{ + + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareNode.class); + + public void compare( Map inParams, SvcLogicContext ctx) throws SvcLogicException + { + log.debug("Starting Compare Node Analysis"); + + HashMap status = new HashMap(); + Parameters params = new Parameters(inParams); + try + { + if(params.getCompareDataType() != null) + { + if(params.getPayloadX() !=null && params.getPayloadY() !=null) + { + status = getCompareResults(params); + log.debug("Compare Result : " + status); + } + else + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, "One of the Data Received by CompareNode is Empty"); + } + } + else + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, "Missing compareDataType value in input request: Expecting at least one of CLI/RESTCONF/XML"); + } + + } + catch(Exception e) + { + status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + status.put(CompareConstants.ERROR_CODE, "200"); + status.put(CompareConstants.ERROR_MESSAGE, CompareConstants.ERROR_MESSAGE_DEATIL); + log.debug("Error in Comapre Node Execution " + e.getMessage()); + + } + + createContextReposne(status, ctx, params.getRequestIdentifier()); + } + + private HashMap getCompareResults(Parameters params) throws Exception + { + HashMap resultMap = new HashMap(); + boolean cmpResult = false; + CompareDataInterface handler; + + + + if(params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_JSON)) + handler = new CompareJsonData(params.getPayloadX(), params.getPayloadY()); + else if((params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_XML)) + || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.NETCONF_XML)) + || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.RESTCONF_XML))) + handler = new CompareXmlData(params.getPayloadX(), params.getPayloadY()); + else if (params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_CLI)) + handler = new CompareCliData(params.getPayloadX(), params.getPayloadY()); + else + { + throw new Exception("Format " + params.getCompareDataType() + " not supported"); + } + try + { + log.debug("Received Format to compare : " + params.getCompareDataType()); + + cmpResult = handler.compare(); + if(cmpResult) + { + resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_SUCCESS); + + } + else + { + resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); + resultMap.put(CompareConstants.ERROR_CODE, "500"); + resultMap.put(CompareConstants.ERROR_MESSAGE, CompareConstants.NO_MATCH_MESSAGE); + } + } + catch (Exception e) + { + throw e; + } + + return resultMap; + } + + private void createContextReposne(HashMap status, SvcLogicContext ctx, String requestIdentifier ) + { + if(requestIdentifier == null) + requestIdentifier = ""; + else + requestIdentifier = requestIdentifier + "."; + + ctx.setAttribute(requestIdentifier.concat( CompareConstants.RESPONSE_STATUS), (String) status.get(CompareConstants.RESPONSE_STATUS)); + ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_CODE), (String) status.get(CompareConstants.ERROR_CODE)); + ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_MESSAGE), (String) status.get(CompareConstants.ERROR_MESSAGE)); + } + +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareXmlData.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareXmlData.java new file mode 100644 index 000000000..00837092f --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/CompareXmlData.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.io.IOException; +import java.io.StringReader; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.XMLUnit; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class CompareXmlData implements CompareDataInterface +{ + private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareXmlData.class); + + + String controlXml; + String testXml; + + Document doc; + + public CompareXmlData(String controlXml, String testXml) { + super(); + this.controlXml = controlXml; + this.testXml = testXml; + } + + @Override + public boolean compare() throws Exception + { + + log.debug("controlXml : " + controlXml); + log.debug("testXml : " + testXml); + + doSetup(); + + try + { + Diff diff = new Diff(getCompareDoc(controlXml), getCompareDoc(testXml)); + if(diff.similar()) + return true; + else + return false; + } + catch(SAXException se) + { + se.printStackTrace(); + throw new Exception(se.getMessage()); + } + catch(Exception e) + { + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + } + + private void doSetup() throws ParserConfigurationException, SAXException, IOException + { + + XMLUnit.setIgnoreAttributeOrder(true); + XMLUnit.setIgnoreComments(true); + XMLUnit.setIgnoreWhitespace(true); + } + + public Document getCompareDoc(String inXml) throws ParserConfigurationException, SAXException, IOException + { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + StringReader reader = new StringReader(inXml); + InputSource inputSource = new InputSource(reader); + Document doc = dBuilder.parse(inputSource); + doc.getDocumentElement().normalize(); + + return doc; + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/Parameters.java b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/Parameters.java new file mode 100644 index 000000000..e3358df11 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/main/java/org/onap/sdnc/config/audit/node/Parameters.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + + +import java.util.Map; + +public class Parameters +{ + + String payloadX ; + + public String getPayloadX() { + return payloadX; + } + public void setPayloadX(String payloadX) { + this.payloadX = payloadX; + } + + String payloadXtype; + + public String getPayloadXtype() { + return payloadXtype; + } + public void setPayloadXtype(String payloadXtype) { + this.payloadXtype = payloadXtype; + } + + String payloadY ; + + public String getPayloadY() { + return payloadY; + } + public void setPayloadY(String payloadY) { + this.payloadY = payloadY; + } + + String payloadYtype; + + public String getPayloadYtype() { + return payloadYtype; + } + public void setPayloadYtype(String payloadYtype) { + this.payloadYtype = payloadYtype; + } + + String compareDataType; + + public String getCompareDataType() { + return compareDataType; + } + public void setCompareDataType(String compareDataType) { + this.compareDataType = compareDataType; + } + + String compareType; + + public String getCompareType() { + return compareType; + } + public void setCompareType(String compareType) { + this.compareType = compareType; + } + + String requestIdentifier; + + public String getRequestIdentifier() { + return requestIdentifier; + } + public void setRequestIdentifier(String requestIdentifier) { + this.requestIdentifier = requestIdentifier; + } + public Parameters(Map inParams) + { + this.compareType = inParams.get("compareType"); + this.compareDataType = inParams.get("compareDataType"); + this.payloadX= inParams.get("sourceData"); + this.payloadY= inParams.get("targetData"); + this.payloadXtype = inParams.get("sourceDataType"); + this.payloadYtype = inParams.get("targetDataType"); + this.requestIdentifier = inParams.get("requestIdentifier"); + + } +} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java deleted file mode 100644 index 648d8ea86..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditActivator.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit; - -import java.util.LinkedList; -import java.util.List; - -import org.openecomp.sdnc.config.audit.node.CompareNode; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; - -public class SliAuditActivator implements BundleActivator{ - - private List registrations = new LinkedList(); - - - private static final EELFLogger log = EELFManager.getInstance().getLogger(SliAuditActivator.class); - - @Override - public void start(BundleContext ctx) throws Exception - { - - CompareNode compareNodePlugin = new CompareNode(); - log.info("Registering service "+ compareNodePlugin.getClass().getName()); - registrations.add(ctx.registerService(compareNodePlugin.getClass().getName(), compareNodePlugin, null)); - - } - @Override - public void stop(BundleContext arg0) throws Exception - { - for (ServiceRegistration registration: registrations) - { - registration.unregister(); - registration = null; - } - - } - -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java deleted file mode 100644 index 0bfaa1e36..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/SliAuditConstant.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit; - -public class SliAuditConstant { - - public static String STRING_ENCODING = "utf-8"; - public static String Y = "Y"; - public static String N = "N"; - public static String DATA_TYPE_TEXT = "TEXT"; - public static String DATA_TYPE_JSON = "JSON"; - public static String DATA_TYPE_XML = "XML"; - public static String DATA_TYPE_SQL = "SQL"; - - public static String INPUT_PARAM_JSON_DATA = "jsonData"; - public static String INPUT_PARAM_IS_ESCAPED = "isEscaped"; - public static String INPUT_PARAM_BLOCK_KEYS = "blockKeys"; - public static String INPUT_PARAM_LOG_DATA = "logData"; - public static String INPUT_PARAM_CHECK_DATA = "checkData"; - public static String INPUT_PARAM_ESCAPE_DATA = "escapeData"; - public static String INPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; - public static String INPUT_PARAM_DATA_TYPE = "dataType"; - public static String INPUT_PARAM_FILE_NAME = "fileName"; - - public static String INPUT_PARAM_TEMPLATE_DATA = "templateData"; - public static String INPUT_PARAM_TEMPLATE_FILE = "templateFile"; - public static String INPUT_PARAM_TEMPLATE_TYPE = "templateType"; - public static String INPUT_PARAM_DO_PRETTY_OUTPUT = "doPrettyOutput"; - public static String INPUT_PARAM_REQUEST_DATA = "requestData"; - public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix"; - - - public static String OUTPUT_PARAM_MERGED_DATA = "mergedData"; - public static String OUTPUT_PARAM_TRANSFORMED_DATA = "transformedData"; - public static String OUTPUT_PARAM_FILE_DATA = "fileData"; - public static String OUTPUT_PARAM_PARSED_ERROR = "parsedError"; - public static String OUTPUT_PARAM_DATA_TYPE = "dataType"; - public static String OUTPUT_PARAM_STATUS = "status"; - public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; - public static String OUTPUT_PARAM_ESCAPE_DATA = "escapeData"; - public static String OUTPUT_PARAM_UNESCAPE_DATA = "unEscapeData"; - - public static String OUTPUT_STATUS_SUCCESS = "success"; - public static String OUTPUT_STATUS_FAILURE = "failure"; - -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java deleted file mode 100644 index 969d126bb..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareCliData.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -public class CompareCliData implements CompareDataInterface{ - - String payloadX; - String payloadY; - - public CompareCliData(String payloadX, String payloadY) - { - super(); - this.payloadX = payloadX; - this.payloadY = payloadY; - } - - @Override - public boolean compare() throws Exception - { - if(payloadX != null && payloadX.equals(payloadY)) - return true; - else - return false; - } -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java deleted file mode 100644 index 42b18d5c3..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareConstants.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -public class CompareConstants { - - - public static final String FORMAT_JSON = "RESTCONF"; - public static final String FORMAT_XML = "XML"; - public static final String FORMAT_CLI = "CLI"; - public static final String NETCONF_XML = "NETCONF-XML"; - public static final String RESTCONF_XML = "RESTCONF-XML"; - - - public static final String STATUS_FAILURE = "FAILURE"; - public static final String RESPONSE_STATUS = "STATUS"; - public static final String STATUS_SUCCESS = "SUCCESS"; - - public static final String ERROR_CODE = "Error-code"; - - public static final String ERROR_MESSAGE = "Error-Message"; - public static final String ERROR_MESSAGE_DEATIL = "Compare Node Failed-Internal Error.See karaf log file"; - - public static final String NO_MATCH_MESSAGE = "The configurations do not match"; -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java deleted file mode 100644 index 95f154e2e..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareDataInterface.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - - -public interface CompareDataInterface -{ - boolean compare() throws Exception; -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java deleted file mode 100644 index 422ac30ac..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareJsonData.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -import java.io.IOException; -import java.util.Map; - - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class CompareJsonData implements CompareDataInterface { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareJsonData.class); - - String payloadX; - String payloadY; - - public CompareJsonData(String payloadX, String payloadY) - { - this.payloadX = payloadX; - this.payloadY = payloadY; - } - - @Override - public boolean compare() throws Exception - { - - ObjectMapper dataMapper = new ObjectMapper(); - boolean match = false; - try - { - Map controlData = (Map)(dataMapper.readValue(payloadX, Map.class)); - Map testData = (Map)(dataMapper.readValue(payloadY, Map.class)); - - log.debug("Control Data :" + controlData); - log.debug("testData Data :" + testData); - - if(controlData.equals(testData)) - match=true; - } - catch(JsonParseException e) - { - throw new Exception(e.getMessage()); - } - catch(JsonMappingException e) - { - throw new Exception(e.getMessage()); - } - catch(IOException ioe) - { - throw new Exception(ioe.getMessage()); - } - - return match; - } - - - -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java deleted file mode 100644 index 710b5ffd1..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareNode.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - - -import java.util.HashMap; -import java.util.Map; - - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -public class CompareNode implements SvcLogicJavaPlugin -{ - - private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareNode.class); - - public void compare( Map inParams, SvcLogicContext ctx) throws SvcLogicException - { - log.debug("Starting Compare Node Analysis"); - - HashMap status = new HashMap(); - Parameters params = new Parameters(inParams); - try - { - if(params.getCompareDataType() != null) - { - if(params.getPayloadX() !=null && params.getPayloadY() !=null) - { - status = getCompareResults(params); - log.debug("Compare Result : " + status); - } - else - { - status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); - status.put(CompareConstants.ERROR_CODE, "200"); - status.put(CompareConstants.ERROR_MESSAGE, "One of the Data Received by CompareNode is Empty"); - } - } - else - { - status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); - status.put(CompareConstants.ERROR_CODE, "200"); - status.put(CompareConstants.ERROR_MESSAGE, "Missing compareDataType value in input request: Expecting at least one of CLI/RESTCONF/XML"); - } - - } - catch(Exception e) - { - status.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); - status.put(CompareConstants.ERROR_CODE, "200"); - status.put(CompareConstants.ERROR_MESSAGE, CompareConstants.ERROR_MESSAGE_DEATIL); - log.debug("Error in Comapre Node Execution " + e.getMessage()); - - } - - createContextReposne(status, ctx, params.getRequestIdentifier()); - } - - private HashMap getCompareResults(Parameters params) throws Exception - { - HashMap resultMap = new HashMap(); - boolean cmpResult = false; - CompareDataInterface handler; - - - - if(params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_JSON)) - handler = new CompareJsonData(params.getPayloadX(), params.getPayloadY()); - else if((params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_XML)) - || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.NETCONF_XML)) - || (params.getCompareDataType().equalsIgnoreCase(CompareConstants.RESTCONF_XML))) - handler = new CompareXmlData(params.getPayloadX(), params.getPayloadY()); - else if (params.getCompareDataType().equalsIgnoreCase(CompareConstants.FORMAT_CLI)) - handler = new CompareCliData(params.getPayloadX(), params.getPayloadY()); - else - { - throw new Exception("Format " + params.getCompareDataType() + " not supported"); - } - try - { - log.debug("Received Format to compare : " + params.getCompareDataType()); - - cmpResult = handler.compare(); - if(cmpResult) - { - resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_SUCCESS); - - } - else - { - resultMap.put(CompareConstants.RESPONSE_STATUS, CompareConstants.STATUS_FAILURE); - resultMap.put(CompareConstants.ERROR_CODE, "500"); - resultMap.put(CompareConstants.ERROR_MESSAGE, CompareConstants.NO_MATCH_MESSAGE); - } - } - catch (Exception e) - { - throw e; - } - - return resultMap; - } - - private void createContextReposne(HashMap status, SvcLogicContext ctx, String requestIdentifier ) - { - if(requestIdentifier == null) - requestIdentifier = ""; - else - requestIdentifier = requestIdentifier + "."; - - ctx.setAttribute(requestIdentifier.concat( CompareConstants.RESPONSE_STATUS), (String) status.get(CompareConstants.RESPONSE_STATUS)); - ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_CODE), (String) status.get(CompareConstants.ERROR_CODE)); - ctx.setAttribute(requestIdentifier.concat(CompareConstants.ERROR_MESSAGE), (String) status.get(CompareConstants.ERROR_MESSAGE)); - } - -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java deleted file mode 100644 index 00837092f..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/CompareXmlData.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - - -import java.io.IOException; -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - - -public class CompareXmlData implements CompareDataInterface -{ - private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareXmlData.class); - - - String controlXml; - String testXml; - - Document doc; - - public CompareXmlData(String controlXml, String testXml) { - super(); - this.controlXml = controlXml; - this.testXml = testXml; - } - - @Override - public boolean compare() throws Exception - { - - log.debug("controlXml : " + controlXml); - log.debug("testXml : " + testXml); - - doSetup(); - - try - { - Diff diff = new Diff(getCompareDoc(controlXml), getCompareDoc(testXml)); - if(diff.similar()) - return true; - else - return false; - } - catch(SAXException se) - { - se.printStackTrace(); - throw new Exception(se.getMessage()); - } - catch(Exception e) - { - e.printStackTrace(); - throw new Exception(e.getMessage()); - } - } - - private void doSetup() throws ParserConfigurationException, SAXException, IOException - { - - XMLUnit.setIgnoreAttributeOrder(true); - XMLUnit.setIgnoreComments(true); - XMLUnit.setIgnoreWhitespace(true); - } - - public Document getCompareDoc(String inXml) throws ParserConfigurationException, SAXException, IOException - { - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - StringReader reader = new StringReader(inXml); - InputSource inputSource = new InputSource(reader); - Document doc = dBuilder.parse(inputSource); - doc.getDocumentElement().normalize(); - - return doc; - } -} diff --git a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java b/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java deleted file mode 100644 index e3358df11..000000000 --- a/appc-config/appc-config-audit/provider/src/main/java/org/openecomp/sdnc/config/audit/node/Parameters.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - - -import java.util.Map; - -public class Parameters -{ - - String payloadX ; - - public String getPayloadX() { - return payloadX; - } - public void setPayloadX(String payloadX) { - this.payloadX = payloadX; - } - - String payloadXtype; - - public String getPayloadXtype() { - return payloadXtype; - } - public void setPayloadXtype(String payloadXtype) { - this.payloadXtype = payloadXtype; - } - - String payloadY ; - - public String getPayloadY() { - return payloadY; - } - public void setPayloadY(String payloadY) { - this.payloadY = payloadY; - } - - String payloadYtype; - - public String getPayloadYtype() { - return payloadYtype; - } - public void setPayloadYtype(String payloadYtype) { - this.payloadYtype = payloadYtype; - } - - String compareDataType; - - public String getCompareDataType() { - return compareDataType; - } - public void setCompareDataType(String compareDataType) { - this.compareDataType = compareDataType; - } - - String compareType; - - public String getCompareType() { - return compareType; - } - public void setCompareType(String compareType) { - this.compareType = compareType; - } - - String requestIdentifier; - - public String getRequestIdentifier() { - return requestIdentifier; - } - public void setRequestIdentifier(String requestIdentifier) { - this.requestIdentifier = requestIdentifier; - } - public Parameters(Map inParams) - { - this.compareType = inParams.get("compareType"); - this.compareDataType = inParams.get("compareDataType"); - this.payloadX= inParams.get("sourceData"); - this.payloadY= inParams.get("targetData"); - this.payloadXtype = inParams.get("sourceDataType"); - this.payloadYtype = inParams.get("targetDataType"); - this.requestIdentifier = inParams.get("requestIdentifier"); - - } -} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java new file mode 100644 index 000000000..a35b08632 --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeCli.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.util.HashMap; + +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +public class TestCompareNodeCli { + private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class); + + @Test + public void TestCompareCliForSamePayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + testMap.put("compareDataType", "Cli"); + testMap.put("sourceData", "This is a Text Configuration of Device"); + testMap.put("targetData", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("SUCCESS")); + } + + @Test + public void TestCompareCliFordifferentPayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + testMap.put("compareDataType", "Cli"); + testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); + testMap.put("targetData", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("FAILURE")); + } + + @Test + public void TestCompareForMissingInput() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); + testMap.put("targetData.configuration-data", "This is a Text Configuration of Device"); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("FAILURE")); + } +} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java new file mode 100644 index 000000000..aa819dffc --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeJson.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.util.HashMap; + +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +public class TestCompareNodeJson { + private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class); + + @Test + public void TestCompareJsonForSamePayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + String testJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + testMap.put("compareDataType", "RestConf"); + testMap.put("sourceData", controlJson); + testMap.put("targetData", testJson); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("SUCCESS")); + } + + @Test + public void TestCompareJsonFordifferentPayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + String testJson = "{\n\"input\": {\n \"appc-request-header\": { \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; + testMap.put("compareDataType", "RestConf"); + testMap.put("sourceData", controlJson); + testMap.put("targetData", testJson); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("FAILURE")); + } +} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeXml.java b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeXml.java new file mode 100644 index 000000000..ed82da83a --- /dev/null +++ b/appc-config/appc-config-audit/provider/src/test/java/org/onap/sdnc/config/audit/node/TestCompareNodeXml.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.config.audit.node; + +import java.io.IOException; +import java.util.HashMap; +import org.junit.Test; +import org.openecomp.sdnc.config.audit.node.CompareNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +public class TestCompareNodeXml { + private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class); + + @Test + public void TestCompareExtactXML() throws SvcLogicException { + log.debug("TestCompareNode.TestCompareExtactXML()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + String s = "Test"; + + String t = "Test"; + testMap.put("compareDataType", "RESTCONF-XML"); + testMap.put("requestIdentifier", "123"); + testMap.put("sourceData", s); + testMap.put("targetData", t); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("123." + "STATUS").equals("SUCCESS")); + } + + @Test + public void TestCompareforAttributeOrder() throws IOException, SvcLogicException { + log.debug("TestCompareNode.TestCompareforAttributeOrder()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + testMap.put("compareDataType", "XML"); + testMap.put("sourceData", + "2true5060true5060"); + testMap.put("targetData", + "true5060true50602"); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("SUCCESS")); + } + + @Test + public void TestCompareForComments() throws SvcLogicException { + log.debug("TestCompareNode.TestCompareForComments()"); + SvcLogicContext ctx = new SvcLogicContext(); + HashMap testMap = new HashMap(); + CompareNode cmp = new CompareNode(); + testMap.put("compareDataType", "XML"); + testMap.put("sourceData", "2"); + testMap.put("targetData", "2"); + cmp.compare(testMap, ctx); + assert (ctx.getAttribute("STATUS").equals("SUCCESS")); + } + +} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java deleted file mode 100644 index a35b08632..000000000 --- a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeCli.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -import java.util.HashMap; - -import org.junit.Test; -import org.openecomp.sdnc.config.audit.node.CompareNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class TestCompareNodeCli { - private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class); - - @Test - public void TestCompareCliForSamePayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - testMap.put("compareDataType", "Cli"); - testMap.put("sourceData", "This is a Text Configuration of Device"); - testMap.put("targetData", "This is a Text Configuration of Device"); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("SUCCESS")); - } - - @Test - public void TestCompareCliFordifferentPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - testMap.put("compareDataType", "Cli"); - testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); - testMap.put("targetData", "This is a Text Configuration of Device"); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("FAILURE")); - } - - @Test - public void TestCompareForMissingInput() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - testMap.put("sourceData", "This is a Text Negative test Configuration of Device"); - testMap.put("targetData.configuration-data", "This is a Text Configuration of Device"); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("FAILURE")); - } -} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java deleted file mode 100644 index aa819dffc..000000000 --- a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeJson.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -import java.util.HashMap; - -import org.junit.Test; -import org.openecomp.sdnc.config.audit.node.CompareNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class TestCompareNodeJson { - private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class); - - @Test - public void TestCompareJsonForSamePayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; - String testJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; - testMap.put("compareDataType", "RestConf"); - testMap.put("sourceData", controlJson); - testMap.put("targetData", testJson); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("SUCCESS")); - } - - @Test - public void TestCompareJsonFordifferentPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - String controlJson = "{\n\"input\": {\n \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; - String testJson = "{\n\"input\": {\n \"appc-request-header\": { \n \"svc-action\": \"prepare\" \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\", \n \"source\": \"Version2\" \n} \n} \n}"; - testMap.put("compareDataType", "RestConf"); - testMap.put("sourceData", controlJson); - testMap.put("targetData", testJson); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("FAILURE")); - } -} diff --git a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java b/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java deleted file mode 100644 index ed82da83a..000000000 --- a/appc-config/appc-config-audit/provider/src/test/java/org/openecomp/sdnc/config/audit/node/TestCompareNodeXml.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.config.audit.node; - -import java.io.IOException; -import java.util.HashMap; -import org.junit.Test; -import org.openecomp.sdnc.config.audit.node.CompareNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class TestCompareNodeXml { - private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class); - - @Test - public void TestCompareExtactXML() throws SvcLogicException { - log.debug("TestCompareNode.TestCompareExtactXML()"); - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - String s = "Test"; - - String t = "Test"; - testMap.put("compareDataType", "RESTCONF-XML"); - testMap.put("requestIdentifier", "123"); - testMap.put("sourceData", s); - testMap.put("targetData", t); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("123." + "STATUS").equals("SUCCESS")); - } - - @Test - public void TestCompareforAttributeOrder() throws IOException, SvcLogicException { - log.debug("TestCompareNode.TestCompareforAttributeOrder()"); - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - testMap.put("compareDataType", "XML"); - testMap.put("sourceData", - "2true5060true5060"); - testMap.put("targetData", - "true5060true50602"); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("SUCCESS")); - } - - @Test - public void TestCompareForComments() throws SvcLogicException { - log.debug("TestCompareNode.TestCompareForComments()"); - SvcLogicContext ctx = new SvcLogicContext(); - HashMap testMap = new HashMap(); - CompareNode cmp = new CompareNode(); - testMap.put("compareDataType", "XML"); - testMap.put("sourceData", "2"); - testMap.put("targetData", "2"); - cmp.compare(testMap, ctx); - assert (ctx.getAttribute("STATUS").equals("SUCCESS")); - } - -} -- cgit 1.2.3-korg