aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-engine/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-20 21:13:19 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-20 23:22:35 +0100
commita02548ec2e98a8a13cd76ecc83379b13cd26030b (patch)
tree1159028f8ac452b61fa4dc0e4a510ba7100ace26 /services/services-engine/src
parentaece3940d349329efe6d220961f6f2a487f90565 (diff)
Fix bug with POJO events in APex
When an envet should be decoded entirely into a POJO and is too complex for Avro, apex decoding breaks. This reviuew fixes thsi issue. Issue-ID: POLICY-1034 Change-Id: Iccd739c4bb5c1645a2a7165f5bbfdfd4b964d79e Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'services/services-engine/src')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java306
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java47
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java6
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java7
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java107
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java5
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java245
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java66
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java69
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java39
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java69
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java57
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java3
-rw-r--r--services/services-engine/src/test/resources/events/TestPojoEvent.json15
-rw-r--r--services/services-engine/src/test/resources/events/TestPojoEventList.json77
-rw-r--r--services/services-engine/src/test/resources/events/TestPojoListEvent.json79
-rw-r--r--services/services-engine/src/test/resources/policymodels/PojoEventModel.apex19
-rw-r--r--services/services-engine/src/test/resources/policymodels/PojoEventModel.json365
20 files changed, 1505 insertions, 87 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
index 27970f982..b9e1648f1 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
@@ -36,17 +36,16 @@ public class ApexEventProtocolParameters extends EventProtocolParameters {
* service.
*/
public ApexEventProtocolParameters() {
- this(ApexEventProtocolParameters.class.getCanonicalName(), APEX_EVENT_PROTOCOL_LABEL);
+ this(APEX_EVENT_PROTOCOL_LABEL);
}
/**
* Constructor to create an event protocol parameters instance with the name of a sub class of this class.
*
- * @param parameterClassName the class name of a sub class of this class
* @param eventProtocolLabel the name of the event protocol for this plugin
*/
- public ApexEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) {
- super(parameterClassName);
+ public ApexEventProtocolParameters(final String eventProtocolLabel) {
+ super();
// Set the event protocol properties for the JSON event protocol
this.setLabel(eventProtocolLabel);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
index 343ef9ac0..78b96ed2c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
@@ -26,6 +26,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.onap.policy.apex.context.SchemaHelper;
@@ -51,6 +52,10 @@ import org.slf4j.ext.XLoggerFactory;
public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JsonEventConverter.class);
+ // Recurring string constants
+ private static final String ERROR_PARSING = "error parsing ";
+ private static final String ERROR_CODING = "error coding ";
+
// The parameters for the JSON event protocol
private JsonEventProtocolParameters jsonPars;
@@ -106,21 +111,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
// Check if we have a list of objects
if (decodedJsonObject instanceof List) {
- // Check if it's a list of JSON objects or a list of strings
- @SuppressWarnings("unchecked")
- final List<Object> decodedJsonList = (List<Object>) decodedJsonObject;
-
- // Decode each of the list elements in sequence
- for (final Object jsonListObject : decodedJsonList) {
- if (jsonListObject instanceof String) {
- eventList.add(jsonStringApexEvent(eventName, (String) jsonListObject));
- } else if (jsonListObject instanceof JsonObject) {
- eventList.add(jsonObject2ApexEvent(eventName, (JsonObject) jsonListObject));
- } else {
- throw new ApexEventException("incoming event (" + jsonEventString
- + ") is a JSON object array containing an invalid object " + jsonListObject);
- }
- }
+ eventList.addAll(decodeEventList(eventName, jsonEventString, decodedJsonObject));
} else {
eventList.add(jsonStringApexEvent(eventName, jsonEventString));
}
@@ -135,6 +126,39 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
return eventList;
}
+ /**
+ * Decode a list of Apex events.
+ *
+ * @param eventName the name of the incoming events
+ * @param jsonEventString the JSON representation of the event list
+ * @param decodedJsonObject The JSON list object
+ * @return a list of decoded Apex events
+ * @throws ApexEventException on event decoding errors
+ */
+ private Collection<? extends ApexEvent> decodeEventList(final String eventName, String jsonEventString,
+ final Object decodedJsonObject) throws ApexEventException {
+
+ final List<ApexEvent> eventList = new ArrayList<>();
+
+ // Check if it's a list of JSON objects or a list of strings
+ @SuppressWarnings("unchecked")
+ final List<Object> decodedJsonList = (List<Object>) decodedJsonObject;
+
+ // Decode each of the list elements in sequence
+ for (final Object jsonListObject : decodedJsonList) {
+ if (jsonListObject instanceof String) {
+ eventList.add(jsonStringApexEvent(eventName, (String) jsonListObject));
+ } else if (jsonListObject instanceof JsonObject) {
+ eventList.add(jsonObject2ApexEvent(eventName, (JsonObject) jsonListObject));
+ } else {
+ throw new ApexEventException("incoming event (" + jsonEventString
+ + ") is a JSON object array containing an invalid object " + jsonListObject);
+ }
+ }
+
+ return eventList;
+ }
+
/*
* (non-Javadoc)
*
@@ -149,6 +173,22 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
throw new ApexEventException("event processing failed, Apex event is null");
}
+ if (jsonPars.getPojoField() == null) {
+ return fromApexEventWithFields(apexEvent);
+ } else {
+ return fromApexEventPojo(apexEvent);
+ }
+ }
+
+ /**
+ /**
+ * Serialise an Apex event to a JSON string field by field.
+ *
+ * @param apexEvent the event to Serialise
+ * @return the Serialise event as JSON
+ * @throws ApexEventException exceptions on marshaling to JSON
+ */
+ private Object fromApexEventWithFields(final ApexEvent apexEvent) {
// Get the event definition for the event from the model service
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(),
apexEvent.getVersion());
@@ -172,7 +212,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
if (!apexEvent.containsKey(fieldName)) {
if (!eventField.getOptional()) {
- final String errorMessage = "error parsing " + eventDefinition.getId() + " event to Json. "
+ final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json. "
+ "Field \"" + fieldName + "\" is missing, but is mandatory. Fields: " + apexEvent;
LOGGER.debug(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
@@ -193,6 +233,51 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
}
/**
+ * Serialise an Apex event to a JSON string as a single POJO.
+ *
+ * @param apexEvent the event to Serialise
+ * @return the Serialise event as JSON
+ * @throws ApexEventException exceptions on marshaling to JSON
+ */
+ private Object fromApexEventPojo(ApexEvent apexEvent) throws ApexEventException {
+ // Get the event definition for the event from the model service
+ final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(),
+ apexEvent.getVersion());
+
+ if (eventDefinition.getFields().isEmpty()) {
+ final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json, Field "
+ + jsonPars.getPojoField() + " not found, no fields defined on event.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ if (eventDefinition.getFields().size() != 1) {
+ final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json, Field "
+ + jsonPars.getPojoField() + ", "
+ + " one and only one field may be defined on a POJO event definition.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ AxField pojoFieldDefinition = eventDefinition.getFields().iterator().next();
+
+ if (!jsonPars.getPojoField().equals(pojoFieldDefinition.getKey().getLocalName())) {
+ final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json. Field "
+ + jsonPars.getPojoField() + " not found on POJO event definition.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ final Object fieldValue = apexEvent.get(jsonPars.getPojoField());
+
+ // Get the schema helper
+ final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory()
+ .createSchemaHelper(pojoFieldDefinition.getKey(), pojoFieldDefinition.getSchema());
+
+ return fieldSchemaHelper.marshal2String(fieldValue);
+ }
+
+ /**
* This method converts a JSON object into an Apex event.
*
* @param eventName the name of the event
@@ -231,12 +316,31 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(),
apexEvent.getVersion());
+ if (jsonPars.getPojoField() == null) {
+ jsonObject2ApexEventWithFields(jsonObject, apexEvent, eventDefinition);
+ } else {
+ jsonObject2ApexEventPojo(jsonObject, apexEvent, eventDefinition);
+ }
+
+ return apexEvent;
+ }
+
+ /**
+ * Decode an Apex event field by field.
+ *
+ * @param jsonObject the JSON representation of the event
+ * @param apexEvent the incoming event header
+ * @param eventDefinition the definition of the event from the model
+ * @throws ApexEventException on decode errors
+ */
+ private void jsonObject2ApexEventWithFields(final JsonObject jsonObject, final ApexEvent apexEvent,
+ final AxEvent eventDefinition) throws ApexEventException {
// Iterate over the input fields in the event
for (final AxField eventField : eventDefinition.getFields()) {
final String fieldName = eventField.getKey().getLocalName();
if (!hasJsonField(jsonObject, fieldName)) {
if (!eventField.getOptional()) {
- final String errorMessage = "error parsing " + eventDefinition.getId() + " event from Json. "
+ final String errorMessage = ERROR_PARSING + eventDefinition.getId() + " event from Json. "
+ "Field \"" + fieldName + "\" is missing, but is mandatory.";
LOGGER.debug(errorMessage);
throw new ApexEventException(errorMessage);
@@ -255,53 +359,140 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
apexEvent.put(fieldName, null);
}
}
- return apexEvent;
+ }
+
+ /**
+ * Decode an Apex event as a single POJO.
+ *
+ * @param jsonObject the JSON representation of the event
+ * @param apexEvent the incoming event header
+ * @param eventDefinition the definition of the event from the model
+ * @throws ApexEventException on decode errors
+ */
+ private void jsonObject2ApexEventPojo(JsonObject jsonObject, ApexEvent apexEvent, AxEvent eventDefinition)
+ throws ApexEventException {
+ if (eventDefinition.getFields().isEmpty()) {
+ final String errorMessage = ERROR_PARSING + eventDefinition.getId() + " event from Json, Field "
+ + jsonPars.getPojoField() + " not found, no fields defined on event.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ if (eventDefinition.getFields().size() != 1) {
+ final String errorMessage = ERROR_PARSING + eventDefinition.getId() + " event from Json, Field "
+ + jsonPars.getPojoField()
+ + ", one and only one field may be defined on a POJO event definition.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ AxField pojoFieldDefinition = eventDefinition.getFields().iterator().next();
+
+ if (!jsonPars.getPojoField().equals(pojoFieldDefinition.getKey().getLocalName())) {
+ final String errorMessage = ERROR_PARSING + eventDefinition.getId() + " event from Json. Field "
+ + jsonPars.getPojoField() + " not found on POJO event definition.";
+ LOGGER.debug(errorMessage);
+ throw new ApexEventException(errorMessage);
+ }
+
+ // Get the schema helper
+ final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory()
+ .createSchemaHelper(pojoFieldDefinition.getKey(), pojoFieldDefinition.getSchema());
+ apexEvent.put(jsonPars.getPojoField(), fieldSchemaHelper.createNewInstance(jsonObject));
}
/**
* This method processes the event header of an Apex event.
*
- * @param eventName the name of the event
+ * @param parameterEventName the name of the event from the parameters
* @param jsonObject the JSON object containing the JSON representation of the incoming event
* @return an apex event constructed using the header fields of the event
* @throws ApexEventRuntimeException the apex event runtime exception
* @throws ApexEventException on invalid events with missing header fields
*/
- private ApexEvent processApexEventHeader(final String eventName, final JsonObject jsonObject)
+ private ApexEvent processApexEventHeader(final String parameterEventName, final JsonObject jsonObject)
throws ApexEventException {
- String name = getJsonStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD, jsonPars.getNameAlias(),
- ApexEvent.NAME_REGEXP, false);
+
+ final String eventName = getHeaderName(jsonObject, parameterEventName);
+
+ String eventVersion = getHeaderVersion(jsonObject);
+
+ final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(eventName, eventVersion);
+
+ if (eventDefinition == null) {
+ if (eventVersion == null) {
+ throw new ApexEventRuntimeException(
+ "an event definition for an event named \"" + eventName + "\" not found in Apex model");
+ } else {
+ throw new ApexEventRuntimeException("an event definition for an event named \"" + eventName
+ + "\" with version \"" + eventVersion + "\" not found in Apex model");
+ }
+ }
+
+ // Use the defined event version if no version is specified on the incoming fields
+ if (eventVersion == null) {
+ eventVersion = eventDefinition.getKey().getVersion();
+ }
+
+ final String eventNamespace = getHeaderNamespace(jsonObject, eventName, eventDefinition);
+ final String eventSource = getHeaderSource(jsonObject, eventDefinition);
+ final String eventTarget = getHeaderTarget(jsonObject, eventDefinition);
+
+ return new ApexEvent(eventName, eventVersion, eventNamespace, eventSource, eventTarget);
+ }
+
+ /**
+ * Determine the name field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @param parameterEventName the configured event name from the parameters
+ * @return the event name to use on the event header
+ */
+ private String getHeaderName(final JsonObject jsonObject, final String parameterEventName) {
+ final String jsonEventName = getJsonStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD,
+ jsonPars.getNameAlias(), ApexEvent.NAME_REGEXP, false);
// Check that an event name has been specified
- if (name == null && eventName == null) {
+ if (jsonEventName == null && parameterEventName == null) {
throw new ApexEventRuntimeException(
"event received without mandatory parameter \"name\" on configuration or on event");
}
// Check if an event name was specified on the event parameters
- if (eventName != null) {
- if (name != null && !eventName.equals(name)) {
+ if (jsonEventName != null) {
+ if (parameterEventName != null && !parameterEventName.equals(jsonEventName)) {
LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\","
- + " using configured event name", name, eventName);
+ + " using configured event name", jsonEventName, parameterEventName);
}
- name = eventName;
+ return jsonEventName;
+ } else {
+ return parameterEventName;
}
+ }
- // Now, find the event definition in the model service. If version is null, the newest event
+ /**
+ * Determine the version field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @return the event version
+ */
+ private String getHeaderVersion(final JsonObject jsonObject) {
+ // Find the event definition in the model service. If version is null, the newest event
// definition in the model service is used
- String version = getJsonStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, jsonPars.getVersionAlias(),
+ return getJsonStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, jsonPars.getVersionAlias(),
ApexEvent.VERSION_REGEXP, false);
- final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(name, version);
- if (eventDefinition == null) {
- throwVersionException(name, version);
- }
-
- // Use the defined event version if no version is specified on the incoming fields
- if (version == null) {
- version = eventDefinition.getKey().getVersion();
- }
+ }
+ /**
+ * Determine the name space field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @param eventName the name of the event
+ * @param eventDefinition the definition of the event structure
+ * @return the event version
+ */
+ private String getHeaderNamespace(final JsonObject jsonObject, final String name, final AxEvent eventDefinition) {
// Check the name space is OK if it is defined, if not, use the name space from the model
String namespace = getJsonStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD,
jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false);
@@ -314,38 +505,41 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
} else {
namespace = eventDefinition.getNameSpace();
}
+ return namespace;
+ }
+ /**
+ * Determine the source field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @param eventDefinition the definition of the event structure
+ * @return the event version
+ */
+ private String getHeaderSource(final JsonObject jsonObject, final AxEvent eventDefinition) {
// For source, use the defined source only if the source is not found on the incoming event
String source = getJsonStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, jsonPars.getSourceAlias(),
ApexEvent.SOURCE_REGEXP, false);
if (source == null) {
source = eventDefinition.getSource();
}
+ return source;
+ }
+ /**
+ * Determine the target field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @param eventDefinition the definition of the event structure
+ * @return the event version
+ */
+ private String getHeaderTarget(final JsonObject jsonObject, final AxEvent eventDefinition) {
// For target, use the defined source only if the source is not found on the incoming event
String target = getJsonStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, jsonPars.getTargetAlias(),
ApexEvent.TARGET_REGEXP, false);
if (target == null) {
target = eventDefinition.getTarget();
}
-
- return new ApexEvent(name, version, namespace, source, target);
- }
-
- /**
- * Throw an exception on event name and/or version with the correct text.
- * @param name The event name
- * @param version The event version
- */
- private void throwVersionException(String name, String version) {
- if (version == null) {
- throw new ApexEventRuntimeException(
- "an event definition for an event named \"" + name + "\" not found in Apex model");
- }
- else {
- throw new ApexEventRuntimeException("an event definition for an event named \"" + name
- + "\" with version \"" + version + "\" not found in Apex model");
- }
+ return target;
}
/**
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
index 8e44ec59b..5ff795d76 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
@@ -22,6 +22,7 @@ package org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCharDelimitedParameters;
+// @formatter:off
/**
* Event protocol parameters for JSON as an event protocol.
*
@@ -37,10 +38,14 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCh
* parameter is optional.
* <li>targetAlias: The field in a JSON event to use as an alias for the event target. This
* parameter is optional.
+ * <li>pojoField: The event is received and sent as a single POJO using the event field
+ * definition in this field name in the schema, there must be one and only one field in the
+ * event definition, the event has a single parameter whose type is the Pojo. This parameter is optional.
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+//@formatter:on
public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedParameters {
/** The label of this event protocol. */
public static final String JSON_EVENT_PROTOCOL_LABEL = "JSON";
@@ -58,23 +63,23 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
private String targetAlias = null;
// @formatter:on
+ // Flag indicating POJO decoding and encoding and parameter indicating the name of the Pojo field
+ private String pojoField = null;
+
/**
- * Constructor to create a JSON event protocol parameter instance and register the instance with
- * the parameter service.
+ * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter
+ * service.
*/
public JsonEventProtocolParameters() {
- this(JsonEventProtocolParameters.class.getCanonicalName(), JSON_EVENT_PROTOCOL_LABEL);
+ this(JSON_EVENT_PROTOCOL_LABEL);
}
/**
- * Constructor to create an event protocol parameters instance with the name of a sub class of
- * this class.
- *
- * @param parameterClassName the class name of a sub class of this class
+ * Constructor to create an event protocol parameters instance with the name of a sub class of this class.
* @param eventProtocolLabel the name of the event protocol for this plugin
*/
- public JsonEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) {
- super(parameterClassName);
+ public JsonEventProtocolParameters(final String eventProtocolLabel) {
+ super();
// Set the event protocol properties for the JSON event protocol
this.setLabel(eventProtocolLabel);
@@ -87,7 +92,9 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
this.setEventProtocolPluginClass(Apex2JsonEventConverter.class.getCanonicalName());
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onap.policy.common.parameters.ParameterGroup#getName()
*/
@Override
@@ -139,7 +146,16 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
public String getTargetAlias() {
return targetAlias;
}
-
+
+ /**
+ * Return the name of the POJO field to use for POJO decoding and encoding.
+ *
+ * @return the name of the POJO field
+ */
+ public String getPojoField() {
+ return pojoField;
+ }
+
/**
* Sets the name alias.
*
@@ -184,4 +200,13 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
public void setTargetAlias(String targetAlias) {
this.targetAlias = targetAlias;
}
+
+ /**
+ * Sets the POJO field that name for POJO decoding and encoding.
+ *
+ * @param pojoField The name of the POJO field to use on the event
+ */
+ public void setPojoField(final String pojoField) {
+ this.pojoField = pojoField;
+ }
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
index 29afc4edb..92efb53b3 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
@@ -48,10 +48,8 @@ public abstract class EventProtocolParameters implements ParameterGroup {
/**
* Constructor to create an event protocol parameters instance with the name of a sub class of this class and
* register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
*/
- public EventProtocolParameters(final String parameterClassName) {
+ public EventProtocolParameters() {
super();
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
index bf8d1a5e1..8d8766772 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
@@ -42,11 +42,9 @@ public abstract class EventProtocolTextCharDelimitedParameters extends EventProt
/**
* Constructor to create an event protocol parameters instance with the name of a sub class of this class.
- *
- * @param parameterClassName the class name of a sub class of this class
*/
- public EventProtocolTextCharDelimitedParameters(final String parameterClassName) {
- super(parameterClassName);
+ public EventProtocolTextCharDelimitedParameters() {
+ super();
}
/**
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
index dce2ee2c3..402d015fc 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
@@ -47,12 +47,9 @@ public abstract class EventProtocolTextTokenDelimitedParameters extends EventPro
/**
* Constructor to create an event protocol parameters instance with the name of a sub class of this class.
- *
- * @param parameterClassName
- * the class name of a sub class of this class
*/
- public EventProtocolTextTokenDelimitedParameters(final String parameterClassName) {
- super(parameterClassName);
+ public EventProtocolTextTokenDelimitedParameters() {
+ super();
}
/**
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java
new file mode 100644
index 000000000..471f90425
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
+import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+
+/**
+ * Test the JSON event converter corner cases.
+ *
+ */
+public class TestJsonEventConverter {
+
+ @Test
+ public void testJsonEventConverter() {
+ Apex2JsonEventConverter converter = new Apex2JsonEventConverter();
+
+ try {
+ converter.init(null);
+ fail("test should throw an exception");
+ } catch (Exception ie) {
+ assertEquals("specified consumer properties are not applicable to the JSON event protocol",
+ ie.getMessage());
+ }
+
+ try {
+ converter.init(new EventProtocolParameters() {
+ });
+ fail("test should throw an exception");
+ } catch (Exception ie) {
+ assertEquals("specified consumer properties are not applicable to the JSON event protocol",
+ ie.getMessage());
+ }
+
+ JsonEventProtocolParameters pars = new JsonEventProtocolParameters();
+ converter.init(pars);
+
+ try {
+ converter.toApexEvent(null, null);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("event processing failed, event is null", tae.getMessage());
+ }
+
+ try {
+ converter.toApexEvent(null, 1);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("error converting event \"1\" to a string", tae.getMessage());
+ }
+
+ try {
+ converter.toApexEvent(null, "[{\"aKey\": 1},{\"aKey\": 2}]");
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Failed to unmarshal JSON event: incoming event ([{\"aKey\": 1},{\"aKey\": 2}]) "
+ + "is a JSON object array containing an invalid object "
+ + "{aKey=1.0}, event=[{\"aKey\": 1},{\"aKey\": 2}]", tae.getMessage());
+ }
+
+ try {
+ converter.toApexEvent(null, "[1,2,3]");
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Failed to unmarshal JSON event: incoming event ([1,2,3]) is a JSON object array "
+ + "containing an invalid object 1.0, event=[1,2,3]", tae.getMessage());
+ }
+
+ try {
+ converter.fromApexEvent(null);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("event processing failed, Apex event is null", tae.getMessage());
+ }
+
+ try {
+ converter.fromApexEvent(new ApexEvent("Event", "0.0.1", "a.name.space", "here", "there"));
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Model for org.onap.policy.apex.model.eventmodel.concepts.AxEvents not found in model service",
+ tae.getMessage());
+ }
+ }
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java
index cfe2921b8..a9165d792 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java
@@ -96,7 +96,7 @@ public class TestJsonEventHandler {
}
/**
- * Test JSO nto apex event.
+ * Test JSON to apex event.
*
* @throws ApexException the apex exception
*/
@@ -134,7 +134,7 @@ public class TestJsonEventHandler {
}
/**
- * Test JSO nto apex bad event.
+ * Test JSON to apex bad event.
*
* @throws ApexException the apex exception
*/
@@ -292,6 +292,7 @@ public class TestJsonEventHandler {
public void testApexEventToJson() throws ApexException {
try {
final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
+ jsonEventConverter.init(new JsonEventProtocolParameters());
assertNotNull(jsonEventConverter);
final Date event0000StartTime = new Date();
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java
new file mode 100644
index 000000000..1dae4c0f4
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java
@@ -0,0 +1,245 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
+import org.onap.policy.apex.service.engine.event.testpojos.TestPojo;
+import org.onap.policy.apex.service.engine.event.testpojos.TestPojoList;
+import org.onap.policy.common.parameters.ParameterService;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * Test JSON Event Handler.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestJsonEventHandlerForPojo {
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestJsonEventHandlerForPojo.class);
+
+ /**
+ * Setup event model.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexModelException the apex model exception
+ */
+ @BeforeClass
+ public static void setupEventModel() throws IOException, ApexModelException {
+ final String policyModelString = TextFileUtils
+ .getTextFileAsString("src/test/resources/policymodels/PojoEventModel.json");
+ final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<AxPolicyModel>(AxPolicyModel.class);
+ modelReader.setValidateFlag(false);
+ final AxPolicyModel apexPolicyModel = modelReader.read(new ByteArrayInputStream(policyModelString.getBytes()));
+
+ // Set up the models in the model service
+ apexPolicyModel.register();
+ }
+
+ /**
+ * Initialize default schema parameters.
+ */
+ @BeforeClass
+ public static void initializeDefaultSchemaParameters() {
+ ParameterService.clear();
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters);
+ }
+
+ /**
+ * Teardown default schema parameters.
+ */
+ @AfterClass
+ public static void teardownDefaultSchemaParameters() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
+ /**
+ * Test POJO to apex event and back.
+ *
+ * @throws ApexException the apex exception
+ * @throws IOException on IO exceptions
+ */
+ @Test
+ public void testJsonPojoToApexEvent() throws ApexException, IOException {
+ final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
+ assertNotNull(jsonEventConverter);
+
+ JsonEventProtocolParameters pars = new JsonEventProtocolParameters();
+ pars.setPojoField("POJO_PAR");
+ jsonEventConverter.init(pars);
+
+ final String apexEventJsonStringIn = TextFileUtils
+ .getTextFileAsString("src/test/resources/events/TestPojoEvent.json");
+
+ logger.debug("input event\n" + apexEventJsonStringIn);
+
+ final List<ApexEvent> apexEventList = jsonEventConverter.toApexEvent("PojoEvent", apexEventJsonStringIn);
+ assertEquals(1, apexEventList.size());
+ final ApexEvent apexEvent = apexEventList.get(0);
+ assertNotNull(apexEvent);
+
+ logger.debug(apexEvent.toString());
+
+ assertEquals("PojoEvent", apexEvent.getName());
+ assertEquals("0.0.1", apexEvent.getVersion());
+ assertEquals("org.onap.policy.apex.service.engine.event.testpojos", apexEvent.getNameSpace());
+ assertEquals("Outside", apexEvent.getSource());
+ assertEquals("Apex", apexEvent.getTarget());
+
+ TestPojo testPojo = (TestPojo) apexEvent.get("POJO_PAR");
+
+ assertEquals(1, testPojo.getAnInt());
+ assertEquals(2, testPojo.getAnInteger().intValue());
+ assertEquals("a string", testPojo.getSomeString());
+
+ assertEquals(10, testPojo.getTestSubPojo().getAnInt());
+ assertEquals(20, testPojo.getTestSubPojo().getAnInteger().intValue());
+ assertEquals("a sub string", testPojo.getTestSubPojo().getSomeString());
+
+ assertEquals(100, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInt());
+ assertEquals(200, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInteger().intValue());
+ assertEquals("a sub sub string", testPojo.getTestSubPojo().getTestSubSubPojo().getSomeString());
+
+ String eventBackInJson = (String) jsonEventConverter.fromApexEvent(apexEvent);
+ assertEquals(apexEventJsonStringIn.replaceAll("\\s+", ""), eventBackInJson.replaceAll("\\s+", ""));
+ }
+
+ /**
+ * Test POJO List to apex event and back.
+ *
+ * @throws ApexException the apex exception
+ * @throws IOException on IO exceptions
+ */
+ @Test
+ public void testJsonPojoListToApexEvent() throws ApexException, IOException {
+ final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
+ assertNotNull(jsonEventConverter);
+
+ JsonEventProtocolParameters pars = new JsonEventProtocolParameters();
+ pars.setPojoField("POJO_LIST_PAR");
+ jsonEventConverter.init(pars);
+
+ final String apexEventJsonStringIn = TextFileUtils
+ .getTextFileAsString("src/test/resources/events/TestPojoListEvent.json");
+
+ logger.debug("input event\n" + apexEventJsonStringIn);
+
+ final List<ApexEvent> apexEventList = jsonEventConverter.toApexEvent("PojoListEvent", apexEventJsonStringIn);
+ assertEquals(1, apexEventList.size());
+ final ApexEvent apexEvent = apexEventList.get(0);
+ assertNotNull(apexEvent);
+
+ logger.debug(apexEvent.toString());
+
+ assertEquals("PojoListEvent", apexEvent.getName());
+ assertEquals("0.0.1", apexEvent.getVersion());
+ assertEquals("org.onap.policy.apex.service.engine.event.testpojos", apexEvent.getNameSpace());
+ assertEquals("Outside", apexEvent.getSource());
+ assertEquals("Apex", apexEvent.getTarget());
+
+ TestPojoList testPojoList = (TestPojoList) apexEvent.get("POJO_LIST_PAR");
+
+ for (TestPojo testPojo : testPojoList.getTestPojoList()) {
+ assertEquals(1, testPojo.getAnInt());
+ assertEquals(2, testPojo.getAnInteger().intValue());
+ assertEquals("a string", testPojo.getSomeString());
+
+ assertEquals(10, testPojo.getTestSubPojo().getAnInt());
+ assertEquals(20, testPojo.getTestSubPojo().getAnInteger().intValue());
+ assertEquals("a sub string", testPojo.getTestSubPojo().getSomeString());
+
+ assertEquals(100, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInt());
+ assertEquals(200, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInteger().intValue());
+ assertEquals("a sub sub string", testPojo.getTestSubPojo().getTestSubSubPojo().getSomeString());
+ }
+ String eventBackInJson = (String) jsonEventConverter.fromApexEvent(apexEvent);
+ assertEquals(apexEventJsonStringIn.replaceAll("\\s+", ""), eventBackInJson.replaceAll("\\s+", ""));
+ }
+
+ /**
+ * Test POJO event with bad configurations.
+ *
+ * @throws ApexException the apex exception
+ * @throws IOException on IO exceptions
+ */
+ @Test
+ public void testJsonBadPojoApexEvent() throws ApexException, IOException {
+ final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
+ assertNotNull(jsonEventConverter);
+
+ JsonEventProtocolParameters pars = new JsonEventProtocolParameters();
+ pars.setPojoField("BAD_POJO_PAR");
+ jsonEventConverter.init(pars);
+
+ final String apexEventJsonStringIn = TextFileUtils
+ .getTextFileAsString("src/test/resources/events/TestPojoEvent.json");
+
+ logger.debug("input event\n" + apexEventJsonStringIn);
+
+ try {
+ jsonEventConverter.toApexEvent("PojoEvent", apexEventJsonStringIn);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Failed to unmarshal JSON event: error parsing PojoEvent:0.0.1 event from Json. "
+ + "Field BAD_POJO_PAR not found on POJO event definition.",
+ tae.getMessage().substring(0, 133));
+ }
+
+ pars.setPojoField("POJO_PAR");
+ try {
+ jsonEventConverter.toApexEvent("PojoNoFieldEvent", apexEventJsonStringIn);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Failed to unmarshal JSON event: error parsing PojoNoFieldEvent:0.0.1 event from Json, "
+ + "Field POJO_PAR not found, no fields defined on event.",
+ tae.getMessage().substring(0, 139));
+ }
+
+ try {
+ jsonEventConverter.toApexEvent("PojoTooManyFieldsEvent", apexEventJsonStringIn);
+ fail("test should throw an exception");
+ } catch (Exception tae) {
+ assertEquals("Failed to unmarshal JSON event: error parsing PojoTooManyFieldsEvent:0.0.1 event from Json, "
+ + "Field POJO_PAR, one and only one field may be defined on a POJO event definition.",
+ tae.getMessage().substring(0, 173));
+ }
+ }
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java
new file mode 100644
index 000000000..139ea6b45
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
+
+/**
+ * Test the JSON event parameters.
+ *
+ */
+public class TestJsonEventProtocolPrameters {
+
+ @Test
+ public void testJsonParameters() {
+ assertNotNull(new JsonEventProtocolParameters());
+
+ JsonEventProtocolParameters params = new JsonEventProtocolParameters();
+
+ params.setLabel("MyLabel");
+ assertEquals("MyLabel", params.getLabel());
+ assertEquals("MyLabel", params.getName());
+
+ params.setEventProtocolPluginClass("MyPluginClass");
+ assertEquals("MyPluginClass", params.getEventProtocolPluginClass());
+
+ params.setNameAlias("MyNameAlias");
+ assertEquals("MyNameAlias", params.getNameAlias());
+
+ params.setVersionAlias("MyVersionAlias");
+ assertEquals("MyVersionAlias", params.getVersionAlias());
+
+ params.setNameSpaceAlias("MyNameSpaceAlias");
+ assertEquals("MyNameSpaceAlias", params.getNameSpaceAlias());
+
+ params.setSourceAlias("MySourceAlias");
+ assertEquals("MySourceAlias", params.getSourceAlias());
+
+ params.setTargetAlias("MyTargetAlias");
+ assertEquals("MyTargetAlias", params.getTargetAlias());
+
+ params.setPojoField("MyPojoField");
+ assertEquals("MyPojoField", params.getPojoField());
+ }
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java
new file mode 100644
index 000000000..009b2a756
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event.testpojos;
+
+/**
+ * A test Pojo for pojo decoding and encoding in Apex.
+ */
+public class TestPojo {
+ private int anInt;
+ private Integer anInteger;
+ private String someString;
+
+ private TestSubPojo testSubPojo;
+
+ /**
+ * Gets the an int.
+ *
+ * @return the an int
+ */
+ public int getAnInt() {
+ return anInt;
+ }
+
+ /**
+ * Gets the an integer.
+ *
+ * @return the an integer
+ */
+ public Integer getAnInteger() {
+ return anInteger;
+ }
+
+ /**
+ * Gets the a string.
+ *
+ * @return the a string
+ */
+ public String getSomeString() {
+ return someString;
+ }
+
+ /**
+ * Gets the test sub pojo.
+ *
+ * @return the test sub pojo
+ */
+ public TestSubPojo getTestSubPojo() {
+ return testSubPojo;
+ }
+
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java
new file mode 100644
index 000000000..0b39a30dc
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event.testpojos;
+
+import java.util.List;
+
+/**
+ * A test list of POJO for decoding and encoding.
+ */
+public class TestPojoList {
+ private List<TestPojo> testPojoList;
+
+ /**
+ * Gets the test pojo list.
+ *
+ * @return the test pojo list
+ */
+ public List<TestPojo> getTestPojoList() {
+ return testPojoList;
+ }
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java
new file mode 100644
index 000000000..f5ea80efc
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event.testpojos;
+
+/**
+ * A test Pojo for pojo decoding and encoding in Apex.
+ */
+public class TestSubPojo {
+ private int anInt;
+ private Integer anInteger;
+ private String someString;
+
+ private TestSubSubPojo testSubSubPojo;
+
+ /**
+ * Gets the an int.
+ *
+ * @return the an int
+ */
+ public int getAnInt() {
+ return anInt;
+ }
+
+ /**
+ * Gets the an integer.
+ *
+ * @return the an integer
+ */
+ public Integer getAnInteger() {
+ return anInteger;
+ }
+
+ /**
+ * Gets the a string.
+ *
+ * @return the a string
+ */
+ public String getSomeString() {
+ return someString;
+ }
+
+ /**
+ * Gets the test sub sub pojo.
+ *
+ * @return the test sub sub pojo
+ */
+ public TestSubSubPojo getTestSubSubPojo() {
+ return testSubSubPojo;
+ }
+
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java
new file mode 100644
index 000000000..8e027f5d6
--- /dev/null
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.service.engine.event.testpojos;
+
+/**
+ * A test Pojo for pojo decoding and encoding in Apex.
+ */
+public class TestSubSubPojo {
+ private int anInt;
+ private Integer anInteger;
+ private String someString;
+
+ /**
+ * Gets the an int.
+ *
+ * @return the an int
+ */
+ public int getAnInt() {
+ return anInt;
+ }
+
+ /**
+ * Gets the an integer.
+ *
+ * @return the an integer
+ */
+ public Integer getAnInteger() {
+ return anInteger;
+ }
+
+ /**
+ * Gets the a string.
+ *
+ * @return the a string
+ */
+ public String getSomeString() {
+ return someString;
+ }
+}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
index 7ae403726..8af9d57d9 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
@@ -20,7 +20,6 @@
package org.onap.policy.apex.service.engine.parameters.dummyclasses;
-import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters;
/**
@@ -38,7 +37,7 @@ public class SuperTokenDelimitedEventProtocolParameters extends EventProtocolTex
* the parameter service.
*/
public SuperTokenDelimitedEventProtocolParameters() {
- super(JsonEventProtocolParameters.class.getCanonicalName());
+ super();
// Set the event protocol properties for the JSON carrier technology
this.setLabel(SUPER_TOKEN_EVENT_PROTOCOL_LABEL);
diff --git a/services/services-engine/src/test/resources/events/TestPojoEvent.json b/services/services-engine/src/test/resources/events/TestPojoEvent.json
new file mode 100644
index 000000000..ce2cb2b6b
--- /dev/null
+++ b/services/services-engine/src/test/resources/events/TestPojoEvent.json
@@ -0,0 +1,15 @@
+{
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+}
diff --git a/services/services-engine/src/test/resources/events/TestPojoEventList.json b/services/services-engine/src/test/resources/events/TestPojoEventList.json
new file mode 100644
index 000000000..3c0d7bf3e
--- /dev/null
+++ b/services/services-engine/src/test/resources/events/TestPojoEventList.json
@@ -0,0 +1,77 @@
+[
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ }
+]
diff --git a/services/services-engine/src/test/resources/events/TestPojoListEvent.json b/services/services-engine/src/test/resources/events/TestPojoListEvent.json
new file mode 100644
index 000000000..c3e38568e
--- /dev/null
+++ b/services/services-engine/src/test/resources/events/TestPojoListEvent.json
@@ -0,0 +1,79 @@
+{
+ "testPojoList": [
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ },
+ {
+ "anInt": 1,
+ "anInteger": 2,
+ "someString": "a string",
+ "testSubPojo": {
+ "anInt": 10,
+ "anInteger": 20,
+ "someString": "a sub string",
+ "testSubSubPojo": {
+ "anInt": 100,
+ "anInteger": 200,
+ "someString": "a sub sub string"
+ }
+ }
+ }
+ ]
+}
diff --git a/services/services-engine/src/test/resources/policymodels/PojoEventModel.apex b/services/services-engine/src/test/resources/policymodels/PojoEventModel.apex
new file mode 100644
index 000000000..b7153a317
--- /dev/null
+++ b/services/services-engine/src/test/resources/policymodels/PojoEventModel.apex
@@ -0,0 +1,19 @@
+model create name=PojoEventModel version=0.0.1
+
+schema create name=TestPojoType version=0.0.1 flavour=Java schema=org.onap.policy.apex.service.engine.event.testpojos.TestPojo
+schema create name=TestPojoListType version=0.0.1 flavour=Java schema=org.onap.policy.apex.service.engine.event.testpojos.TestPojoList
+
+event create name=PojoEvent version=0.0.1 nameSpace=org.onap.policy.apex.service.engine.event.testpojos source=Outside target=Apex
+
+event parameter create name=PojoEvent version=0.0.1 parName=POJO_PAR schemaName=TestPojoType
+
+event create name=PojoListEvent version=0.0.1 nameSpace=org.onap.policy.apex.service.engine.event.testpojos source=Outside target=Apex
+
+event parameter create name=PojoListEvent version=0.0.1 parName=POJO_LIST_PAR schemaName=TestPojoListType
+
+event create name=PojoNoFieldEvent version=0.0.1 nameSpace=org.onap.policy.apex.service.engine.event.testpojos source=Outside target=Apex
+
+event create name=PojoTooManyFieldsEvent version=0.0.1 nameSpace=org.onap.policy.apex.service.engine.event.testpojos source=Outside target=Apex
+event parameter create name=PojoTooManyFieldsEvent version=0.0.1 parName=POJO_LIST_PAR0 schemaName=TestPojoListType
+event parameter create name=PojoTooManyFieldsEvent version=0.0.1 parName=POJO_LIST_PAR1 schemaName=TestPojoListType
+
diff --git a/services/services-engine/src/test/resources/policymodels/PojoEventModel.json b/services/services-engine/src/test/resources/policymodels/PojoEventModel.json
new file mode 100644
index 000000000..3bd04a375
--- /dev/null
+++ b/services/services-engine/src/test/resources/policymodels/PojoEventModel.json
@@ -0,0 +1,365 @@
+{
+ "apexPolicyModel" : {
+ "key" : {
+ "name" : "PojoEventModel",
+ "version" : "0.0.1"
+ },
+ "keyInformation" : {
+ "key" : {
+ "name" : "PojoEventModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "keyInfoMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "PojoEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "60411084-d846-3681-9ba7-093bacfd78d2",
+ "description" : "Generated description for concept referred to by key \"PojoEvent:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel",
+ "version" : "0.0.1"
+ },
+ "UUID" : "1a77f36c-7dd2-3188-91d1-5839114f3a3f",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_Albums",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_Albums",
+ "version" : "0.0.1"
+ },
+ "UUID" : "b8fe7c9c-2445-3cb0-a671-da2d380e418a",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_Albums:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_Events",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_Events",
+ "version" : "0.0.1"
+ },
+ "UUID" : "fb9f68f9-f5b7-361a-8b8e-df1fe987084e",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_Events:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "UUID" : "2156f4d7-cfb2-3e15-ab78-4aced50730bf",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_KeyInfo:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_Policies",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_Policies",
+ "version" : "0.0.1"
+ },
+ "UUID" : "45fd6cff-59de-3511-8398-8a88ad01cd1a",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_Policies:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "UUID" : "9081b534-62db-384a-b7cc-4e5fc1d781b3",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_Schemas:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoEventModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEventModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "UUID" : "1e917c60-b5e5-3849-83ca-27d795a633a9",
+ "description" : "Generated description for concept referred to by key \"PojoEventModel_Tasks:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoListEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoListEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "d9627e71-18ac-38d7-b033-33a704132afc",
+ "description" : "Generated description for concept referred to by key \"PojoListEvent:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoNoFieldEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoNoFieldEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "d42ab6d1-9b39-3d94-9a65-d47c116a478f",
+ "description" : "Generated description for concept referred to by key \"PojoNoFieldEvent:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "PojoTooManyFieldsEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoTooManyFieldsEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "1d33d978-297f-3253-b9c6-f0bc9dc63e24",
+ "description" : "Generated description for concept referred to by key \"PojoTooManyFieldsEvent:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "UUID" : "ad74efe5-833f-30e5-837c-0d9ae607e4a2",
+ "description" : "Generated description for concept referred to by key \"TestPojoListType:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "TestPojoType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TestPojoType",
+ "version" : "0.0.1"
+ },
+ "UUID" : "254c248e-f172-3871-83aa-4de45f01b6c7",
+ "description" : "Generated description for concept referred to by key \"TestPojoType:0.0.1\""
+ }
+ } ]
+ }
+ },
+ "policies" : {
+ "key" : {
+ "name" : "PojoEventModel_Policies",
+ "version" : "0.0.1"
+ },
+ "policyMap" : {
+ "entry" : [ ]
+ }
+ },
+ "tasks" : {
+ "key" : {
+ "name" : "PojoEventModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "taskMap" : {
+ "entry" : [ ]
+ }
+ },
+ "events" : {
+ "key" : {
+ "name" : "PojoEventModel_Events",
+ "version" : "0.0.1"
+ },
+ "eventMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "PojoEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.service.engine.event.testpojos",
+ "source" : "Outside",
+ "target" : "Apex",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "POJO_PAR",
+ "value" : {
+ "key" : "POJO_PAR",
+ "fieldSchemaKey" : {
+ "name" : "TestPojoType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "PojoListEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoListEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.service.engine.event.testpojos",
+ "source" : "Outside",
+ "target" : "Apex",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "POJO_LIST_PAR",
+ "value" : {
+ "key" : "POJO_LIST_PAR",
+ "fieldSchemaKey" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "PojoNoFieldEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoNoFieldEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.service.engine.event.testpojos",
+ "source" : "Outside",
+ "target" : "Apex",
+ "parameter" : {
+ "entry" : [ ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "PojoTooManyFieldsEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "PojoTooManyFieldsEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.service.engine.event.testpojos",
+ "source" : "Outside",
+ "target" : "Apex",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "POJO_LIST_PAR0",
+ "value" : {
+ "key" : "POJO_LIST_PAR0",
+ "fieldSchemaKey" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ }, {
+ "key" : "POJO_LIST_PAR1",
+ "value" : {
+ "key" : "POJO_LIST_PAR1",
+ "fieldSchemaKey" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ } ]
+ }
+ },
+ "albums" : {
+ "key" : {
+ "name" : "PojoEventModel_Albums",
+ "version" : "0.0.1"
+ },
+ "albums" : {
+ "entry" : [ ]
+ }
+ },
+ "schemas" : {
+ "key" : {
+ "name" : "PojoEventModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "schemas" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TestPojoListType",
+ "version" : "0.0.1"
+ },
+ "schemaFlavour" : "Java",
+ "schemaDefinition" : "org.onap.policy.apex.service.engine.event.testpojos.TestPojoList"
+ }
+ }, {
+ "key" : {
+ "name" : "TestPojoType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "TestPojoType",
+ "version" : "0.0.1"
+ },
+ "schemaFlavour" : "Java",
+ "schemaDefinition" : "org.onap.policy.apex.service.engine.event.testpojos.TestPojo"
+ }
+ } ]
+ }
+ }
+ }
+}