summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-common
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-common')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/pom.xml81
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java34
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java33
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java40
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java57
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java121
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java66
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java55
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java65
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java50
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java80
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml41
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties47
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd88
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java154
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java61
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java145
19 files changed, 1223 insertions, 0 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/.gitignore b/appc-dg/appc-dg-shared/appc-dg-common/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/pom.xml b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
new file mode 100644
index 000000000..e41a3cb86
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-common</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-easymock</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-common</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.common,org.openecomp.appc.dg.common.objects,org.openecomp.appc.dg.common.utils</Export-Package>
+ <Private-Package>org.openecomp.appc.dg.common.impl.*</Private-Package>
+ <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java
new file mode 100644
index 000000000..a99038063
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface DCAEReporterPlugin extends SvcLogicJavaPlugin {
+ void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void reportSuccess(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java
new file mode 100644
index 000000000..2b3fbf793
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface JsonDgUtil extends SvcLogicJavaPlugin {
+ void flatAndAddToContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java
new file mode 100644
index 000000000..a356a1546
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface LegacyUtil extends SvcLogicJavaPlugin {
+
+ void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void convertPositiveResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void convertNegativeResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java
new file mode 100644
index 000000000..92d23e3a6
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+
+
+class Constants {
+
+ public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
+ public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
+ public static final String PAYLOAD = "payload";
+
+ enum LegacyAttributes {
+ Action("org.openecomp.appc.action"),
+ VMID("org.openecomp.appc.vmid"),
+ IdentityURL("org.openecomp.appc.identity.url"),
+ TenantID("org.openecomp.appc.tenant.id");
+
+ private String value;
+ LegacyAttributes(String value) {this.value = value;}
+ String getValue() {return value;}
+ };
+
+ enum LCMAttributes {
+ Action("input.action"),
+ Payload("input.payload"),
+ VMID("vm-id"),
+ IdentityURL("identity-url"),
+ TenantID("tenant.id");
+
+ private String value;
+ LCMAttributes(String value) {this.value = value;}
+ String getValue() {return value;}
+ };
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java
new file mode 100644
index 000000000..4458de10b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventHeader;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.adapter.dmaap.event.EventStatus;
+import org.openecomp.appc.dg.common.DCAEReporterPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Map;
+
+public class DCAEReporterPluginImpl implements DCAEReporterPlugin {
+
+ private EventSender eventSender;
+
+ public DCAEReporterPluginImpl() {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(EventSender.class);
+ eventSender = (EventSender) bctx.getService(sref);
+ }
+
+ @Override
+ public void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Integer errorReportCode = 501;
+ boolean bwcMode = Boolean.parseBoolean(ctx.getAttribute("isBwcMode"));
+ String errorDescription,apiVersion,eventId ;
+ errorDescription = getErrorDescriptionAndAddToCtx(bwcMode,params,ctx);
+ if(!bwcMode){
+ apiVersion = ctx.getAttribute("input.common-header.api-ver");
+ eventId = ctx.getAttribute("input.common-header.request-id");
+ }else {
+ apiVersion = ctx.getAttribute(Constants.API_VERSION_FIELD_NAME);
+ eventId = ctx.getAttribute(Constants.REQ_ID_FIELD_NAME);
+ }
+
+ EventMessage eventMessage = new EventMessage(new EventHeader((new java.util.Date()).toString(), apiVersion, eventId), new EventStatus(errorReportCode, errorDescription));
+ eventSender.sendEvent(DmaapDestination.DCAE, eventMessage);
+ }
+
+ private String getErrorDescriptionAndAddToCtx(boolean bwcMode, Map<String, String> params, SvcLogicContext ctx) {
+ String errorDescription;
+ if(!bwcMode) {
+ errorDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ }else {
+ addToContextIfNotContains(bwcMode,errorDescription,ctx);
+ }
+ }else{
+ errorDescription = params.get(Constants.DG_ERROR_FIELD_NAME);
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = ctx.getAttribute("org.openecomp.appc.dg.error");
+ }else {
+ addToContextIfNotContains(bwcMode, errorDescription,ctx);
+ }
+ }
+
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = "Unknown";
+ }
+ return errorDescription;
+ }
+
+ private void addToContextIfNotContains(boolean bwcMode, String errorDescription, SvcLogicContext ctx) {
+ String errorDescriptionFromCtx;
+ if(!StringUtils.isEmpty(errorDescription)) {
+ String outputStatusMessageProperty = bwcMode ? "org.openecomp.appc.dg.error" : Constants.DG_OUTPUT_STATUS_MESSAGE;
+ errorDescriptionFromCtx = ctx.getAttribute(outputStatusMessageProperty);
+ if(StringUtils.isEmpty(errorDescriptionFromCtx)){
+ ctx.setAttribute(outputStatusMessageProperty, errorDescription);
+ }else if (!errorDescriptionFromCtx.contains(errorDescription)){
+ ctx.setAttribute(outputStatusMessageProperty, errorDescriptionFromCtx+ " | "+ errorDescription);
+ }
+ }
+ }
+
+
+ @Override
+ public void reportSuccess(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Integer successReportCode = 500;
+ String successDescription, apiVersion, eventId;
+ successDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ apiVersion = ctx.getAttribute("input.common-header.api-ver");
+ eventId = ctx.getAttribute("input.common-header.request-id");
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, successDescription);
+
+ if (null == successDescription) {
+ successDescription = "Success";
+ }
+ EventMessage eventMessage = new EventMessage(new EventHeader((new java.util.Date()).toString(), apiVersion, eventId), new EventStatus(successReportCode, successDescription));
+ eventSender.sendEvent(DmaapDestination.DCAE, eventMessage);
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java
new file mode 100644
index 000000000..95191132a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.dg.common.JsonDgUtil;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.util.JsonUtil;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.util.Map;
+
+
+public class JsonDgUtilImpl implements JsonDgUtil {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonDgUtilImpl.class);
+
+ @Override
+ public void flatAndAddToContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to flatAndAddToContext with params = "+ ObjectUtils.toString(params)+", SvcLogicContext = "+ObjectUtils.toString(ctx));
+ }
+ try {
+ String paramName = Constants.PAYLOAD;
+ String payload = params.get(paramName);
+ if (payload == "")
+ payload = ctx.getAttribute("input.payload");
+ if (!StringUtils.isEmpty(payload)) {
+ Map<String, String> flatMap = JsonUtil.convertJsonStringToFlatMap(payload);
+ if (flatMap != null && flatMap.size() > 0) {
+ for (Map.Entry<String, String> entry : flatMap.entrySet()) {
+ ctx.setAttribute(entry.getKey(), entry.getValue());
+ }
+ }
+ } else {
+ logger.warn("input payload param value is empty (\"\") or null");
+ }
+ } catch (Exception e) {
+ logger.error(e.toString());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.toString());
+ throw new APPCException(e);
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java
new file mode 100644
index 000000000..6354b2044
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.dg.common.LegacyUtil;
+import org.openecomp.appc.dg.common.utils.JSONUtil;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+
+public class LegacyUtilImpl implements LegacyUtil {
+
+ @Override public void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ ctx.setAttribute(Constants.LegacyAttributes.Action.getValue(), ctx.getAttribute(Constants.LCMAttributes.Action.getValue()).toLowerCase());
+
+ String payloadStr = ctx.getAttribute(Constants.LCMAttributes.Payload.getValue());
+ Map<String,String> payloads = JSONUtil.extractPlainValues(payloadStr,
+ Constants.LCMAttributes.VMID.getValue(), Constants.LCMAttributes.IdentityURL.getValue(), Constants.LCMAttributes.TenantID.getValue());
+
+ ctx.setAttribute(Constants.LegacyAttributes.VMID.getValue(), payloads.get(Constants.LCMAttributes.VMID.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.IdentityURL.getValue(), payloads.get(Constants.LCMAttributes.IdentityURL.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.TenantID.getValue(), payloads.get(Constants.LCMAttributes.TenantID.getValue()));
+
+ }
+
+ @Override
+ public void convertPositiveResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ }
+
+ @Override
+ public void convertNegativeResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java
new file mode 100644
index 000000000..d576555c4
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.objects;
+
+
+
+public class ConnectionDetails {
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java
new file mode 100644
index 000000000..a298e9cca
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.utils;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+
+public class JAXBUtil {
+
+ public static <T> T toObject(String xml, Class<T> type) throws JAXBException {
+
+ //create JAXB context
+ JAXBContext context = JAXBContext.newInstance(type);
+
+ //Create Unmarshaller using JAXB context
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(xmlInputStream));
+
+ return type.cast(unmarshaller.unmarshal(reader));
+
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java
new file mode 100644
index 000000000..fe7197482
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.utils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.*;
+
+
+public class JSONUtil {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ public static <T> T fromJson(String json, Class<T> clazz) {
+
+ try {
+ return OBJECT_MAPPER.readValue(json, clazz);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static <T> T fromJson(Reader reader, Class<T> clazz) {
+
+ try {
+ return OBJECT_MAPPER.readValue(reader, clazz);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static String toJson(Object object) {
+
+ try {
+ return OBJECT_MAPPER.writeValueAsString(object);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Map<String,String> extractPlainValues(String json, String ... names) {
+ if (null == names) return Collections.emptyMap();
+ Map<String,String> values = new HashMap<>();
+ try {
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(json);
+ for (String name : names) {
+ values.put(name, jsonNode.path(name).asText());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return values;
+ }
+
+
+
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..53b5367e4
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <bean id="JsonDgUtilBean" class="org.openecomp.appc.dg.common.impl.JsonDgUtilImpl"/>
+ <service id="JsonDgUtil" interface="org.openecomp.appc.dg.common.JsonDgUtil" ref="JsonDgUtilBean"/>
+
+ <reference id="eventSenderRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.dmaap.EventSender" />
+
+ <bean id="DCAEReporterPluginBean" class="org.openecomp.appc.dg.common.impl.DCAEReporterPluginImpl" scope="singleton"/>
+ <service id="DCAEReporterPlugin" interface="org.openecomp.appc.dg.common.DCAEReporterPlugin" ref="DCAEReporterPluginBean"/>
+
+ <bean id="legacyUtilBean" class="org.openecomp.appc.dg.common.impl.LegacyUtilImpl" scope="singleton"/>
+ <service id="legacyUtil" interface="org.openecomp.appc.dg.common.LegacyUtil" ref="legacyUtilBean"/>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..d8451ee8b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,47 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : 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=========================================================
+###
+
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+org.openecomp.appc.netconf.db.url.netconfctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.netconf.db.user.netconfctl=test
+org.openecomp.appc.netconf.db.pass.netconfctl=123456
+
+org.openecomp.appc.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.db.user.sdnctl=test
+org.openecomp.appc.db.pass.sdnctl=123456
+
+org.openecomp.appc.netconf.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.netconf.db.user.sdnctl=test
+org.openecomp.appc.netconf.db.pass.sdnctl=123456
+
+### ###
+### Properties commented out below provided in appc.properties ###
+### ###
+#event.pool.members=<MY_DMAAP_URL>
+event.topic.write=APPC-TEST1
+event.client.key=VIlbtVl6YLhNUrtU
+event.client.secret=64AG2hF4pYeG2pq7CT6XwUOT
+#restconf.user=<RESTCONF_USER>
+#restconf.pass=<RESTCONF_PASSWORD>
+
+org.openecomp.appc.adapter.netconf.VNFOperationalStateValidatorImpl-CONFIG_FILE=VnfGetOperationalStates
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd
new file mode 100644
index 000000000..9fb979609
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd
@@ -0,0 +1,88 @@
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="vf-license-model">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="vnf-id"/>
+ <xs:element type="xs:string" name="vendor-name"/>
+ <xs:element name="feature-group-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="feature-group">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="feature-group-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="att-part-number"/>
+ <xs:element name="entitlement-pool-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="entitlement-pool">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="entitlement-pool-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="manufacturer-reference-number"/>
+ <xs:element name="threshold-value">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:byte" name="value"/>
+ <xs:element type="xs:string" name="unit"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="entitlement-metric">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element type="xs:string" name="increments"/>
+ <xs:element name="aggregation-function">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="time">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="license-key-group-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="license-key-group">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="license-key-group-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="type"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java
new file mode 100644
index 000000000..9b8290004
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.dg.common.impl.Constants;
+import org.openecomp.appc.dg.common.impl.DCAEReporterPluginImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.util.HashMap;
+import java.util.Map;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({DCAEReporterPluginImpl.class, FrameworkUtil.class})
+public class DCAEReporterPluginImplTest {
+ private SvcLogicContext ctx;
+ private Map<String, String> params;
+
+ private final BundleContext bundleContext=Mockito.mock(BundleContext.class);
+ private final Bundle bundleService=Mockito.mock(Bundle.class);
+ private final ServiceReference sref=Mockito.mock(ServiceReference.class);
+
+
+ private DCAEReporterPluginImpl dcaeReporterPlugin;
+ private EventSenderMock eventSender;
+
+ private String apiVer = "2.0.0";
+ private String requestId = "123";
+ private String error = "test-error";
+
+ @Before
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
+ eventSender = new EventSenderMock();
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref);
+ PowerMockito.when(bundleContext.getService(sref)).thenReturn(eventSender);
+ dcaeReporterPlugin = new DCAEReporterPluginImpl();
+
+ }
+
+
+
+
+ @Test
+ public void testReportBwcTrue() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "true");
+ params.put(Constants.DG_ERROR_FIELD_NAME, error);
+ ctx.setAttribute(Constants.API_VERSION_FIELD_NAME, apiVer);
+ ctx.setAttribute(Constants.REQ_ID_FIELD_NAME, requestId);
+
+ positiveAssert();
+ }
+
+ @Test
+ public void testReportErrorDescriptionNullBwcModeTrue() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "true");
+ params.put(Constants.DG_ERROR_FIELD_NAME, null);
+ ctx.setAttribute(Constants.API_VERSION_FIELD_NAME, apiVer);
+ ctx.setAttribute(Constants.REQ_ID_FIELD_NAME, requestId);
+
+ errorReasonNullAssert();
+ }
+
+ @Test
+ public void testReportErrorDescriptionNullBwcModeFalse() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "false");
+ params.put("output.status.message", null);
+ ctx.setAttribute("input.common-header.api-ver", apiVer);
+ ctx.setAttribute("input.common-header.request-id", requestId);
+
+ errorReasonNullAssert();
+ }
+
+
+ private void errorReasonNullAssert() throws APPCException {
+ dcaeReporterPlugin.report(params, ctx);
+ DmaapDestination destination = eventSender.getDestination();
+ EventMessage msg = eventSender.getMsg();
+ Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
+ Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
+ Assert.assertEquals("wrong error message", "Unknown", msg.getEventStatus().getReason());
+ Assert.assertEquals("wrong destination", destination.name(), "DCAE");
+
+ }
+
+
+ private void positiveAssert() throws APPCException {
+ dcaeReporterPlugin.report(params, ctx);
+ DmaapDestination destination = eventSender.getDestination();
+ EventMessage msg = eventSender.getMsg();
+ Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
+ Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
+ Assert.assertEquals("wrong error message", error, msg.getEventStatus().getReason());
+ Assert.assertEquals("wrong destination", destination.name(), "DCAE");
+
+ }
+
+
+ @Test
+ public void testReportBwcFalse() throws Exception {
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "false");
+ params.put("output.status.message", error);
+ ctx.setAttribute("input.common-header.api-ver", apiVer);
+ ctx.setAttribute("input.common-header.request-id", requestId);
+
+ positiveAssert();
+
+ }
+ }
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java
new file mode 100644
index 000000000..0e6b1651b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+public class EventSenderMock implements EventSender {
+ EventMessage msg;
+ DmaapDestination destination;
+
+ @Override
+ public boolean sendEvent(DmaapDestination destination, EventMessage msg) {
+ if (destination != null && msg != null){
+ this.msg = msg;
+ this.destination = destination;
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ @Override
+ public boolean sendEvent(DmaapDestination destination, Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ return false;
+ }
+
+ public EventMessage getMsg() {
+ return msg;
+ }
+
+ public DmaapDestination getDestination() {
+ return destination;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java
new file mode 100644
index 000000000..70534872d
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.appc.dg.common.impl;
+
+import ch.qos.logback.core.Appender;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.dg.common.impl.JsonDgUtilImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+public class JsonDgUtilImplTest {
+
+ private final Appender appender = mock(Appender.class);
+
+
+ @Test
+ public void testFlatAndAddToContext() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, payload);
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertEquals(ctx.getAttribute(testValueKey), testValueValue);
+ Assert.assertEquals(ctx.getAttribute(testValueKey2), testValueValue2);
+
+
+
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextNegativeWrongPayload() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, payload);
+ try {
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+ } catch (APPCException e) {
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ Assert.assertNotNull(ctx.getAttribute("output.status.message"));
+ }
+
+
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextPayloadFromContext() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, "");
+ ctx.setAttribute("input.payload", payload);
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertEquals(ctx.getAttribute(testValueKey), testValueValue);
+ Assert.assertEquals(ctx.getAttribute(testValueKey2), testValueValue2);
+ }
+
+ @Test
+ public void testFlatAndAddToContextNegativeNullPayload() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String testValueKey = "test-key";
+ String testValueKey2 = "test-key2";
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextNegativeEmptyPayload() throws Exception {
+
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueKey2 = "test-key2";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, "");
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ }
+}