aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-event')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java)12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java)65
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java)34
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java10
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java13
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java)60
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java33
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java)10
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java35
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java68
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java)20
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestor.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java)120
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java56
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json10
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java28
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java18
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java)6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java20
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java11
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java31
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java)4
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java)32
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java)15
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java)24
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java)28
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XMLEventConverter.java)18
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventProtocolParameters.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventProtocolParameters.java)8
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlEventHandler.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLEventHandler.java)50
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlTaggedEventConsumer.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLTaggedEventConsumer.java)244
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventGenerator.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventGenerator.java)27
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java79
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java2
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java83
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java26
42 files changed, 846 insertions, 510 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
index 93174b941..de324512b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
@@ -49,12 +49,12 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runnable {
+public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runnable {
// Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSConsumer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsConsumer.class);
// The Apex and JMS parameters read from the parameter service
- private JMSCarrierTechnologyParameters jmsConsumerProperties;
+ private JmsCarrierTechnologyParameters jmsConsumerProperties;
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -83,14 +83,14 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
this.name = consumerName;
// Check and get the JMS Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
final String errorMessage = "specified consumer properties of type \""
+ consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
+ "\" are not applicable to a JMS consumer";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- jmsConsumerProperties = (JMSCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ jmsConsumerProperties = (JmsCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Look up the JMS connection factory
InitialContext jmsContext = null;
@@ -212,7 +212,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
}
/**
- * The helper function to create a message consumer from a given JMS session
+ * The helper function to create a message consumer from a given JMS session.
*
* @param jmsSession a JMS session
*/
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
index 86e9555f9..7277a7dc3 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
@@ -47,13 +47,17 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexJMSProducer implements ApexEventProducer {
-
+public class ApexJmsProducer implements ApexEventProducer {
// Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSProducer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsProducer.class);
+
+ // Recurring string constants
+ private static final String COULD_NOT_SEND_PREFIX = "could not send event \"";
+ private static final String FOR_PRODUCER_TAG = "\" for producer (";
+ private static final String JMS_MESSAGE_PRODUCER_TAG = "\" on JMS message producer ";
// The JMS parameters read from the parameter service
- private JMSCarrierTechnologyParameters jmsProducerProperties;
+ private JmsCarrierTechnologyParameters jmsProducerProperties;
// The connection to the JMS server
private Connection connection;
@@ -78,16 +82,17 @@ public class ApexJMSProducer implements ApexEventProducer {
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the JMS Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) {
- final String errorMessage = "specified producer properties are not applicable to a JMS producer (" + this.name + ")";
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
+ final String errorMessage = "specified producer properties are not applicable to a JMS producer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- jmsProducerProperties = (JMSCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ jmsProducerProperties = (JmsCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Look up the JMS connection factory
InitialContext jmsContext = null;
@@ -99,12 +104,12 @@ public class ApexJMSProducer implements ApexEventProducer {
// Check if we actually got a connection factory
if (connectionFactory == null) {
throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
- + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -117,12 +122,12 @@ public class ApexJMSProducer implements ApexEventProducer {
// Check if we actually got a topic
if (jmsOutgoingTopic == null) {
throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
- + "\" for producer (" + this.name + ")";
+ + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -130,11 +135,11 @@ public class ApexJMSProducer implements ApexEventProducer {
// Create and start a connection to the JMS server
try {
connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(),
- jmsProducerProperties.getSecurityCredentials());
+ jmsProducerProperties.getSecurityCredentials());
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -144,7 +149,7 @@ public class ApexJMSProducer implements ApexEventProducer {
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -153,8 +158,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
messageProducer = jmsSession.createProducer(jmsOutgoingTopic);
} catch (final Exception e) {
- final String errorMessage =
- "creation of producer for sending events to JMS server failed for JMS properties \""
+ final String errorMessage = "creation of producer for sending events "
+ + "to JMS server failed for JMS properties \""
+ jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -202,17 +207,17 @@ public class ApexJMSProducer implements ApexEventProducer {
@Override
public void sendEvent(final long executionId, final String eventname, final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
// Check if the object to be sent is serializable
if (!Serializable.class.isAssignableFrom(eventObject.getClass())) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", object of type \"" + eventObject.getClass().getCanonicalName()
- + "\" is not serializable";
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
+ + ", object of type \"" + eventObject.getClass().getCanonicalName()
+ + "\" is not serializable";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -226,8 +231,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject);
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", could not create JMS Object Message for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG
+ + this.name + ", could not create JMS Object Message for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -236,8 +241,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
jmsMessage = jmsSession.createTextMessage(eventObject.toString());
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", could not create JMS Text Message for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG
+ + this.name + ", could not create JMS Text Message for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -246,8 +251,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
messageProducer.send(jmsMessage);
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", send failed for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
+ + ", send failed for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java
index 80977b5d8..8b120ca3a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java
@@ -30,8 +30,8 @@ import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
- * <p>
- * The parameters for this plugin are:
+ *
+ * <p>The parameters for this plugin are:
* <ol>
* <li>initialContextFactory: JMS uses a naming {@link Context} object to look up the locations of JMS servers and JMS
* topics. An Initial Context Factory is used to when creating a {@link Context} object that can be used for JMS
@@ -69,28 +69,28 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters {
/** The label of this carrier technology. */
public static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS";
/** The producer plugin class for the JMS carrier technology. */
- public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJMSProducer.class.getCanonicalName();
+ public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getCanonicalName();
/** The consumer plugin class for the JMS carrier technology. */
- public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJMSConsumer.class.getCanonicalName();
+ public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getCanonicalName();
// @formatter:off
// Default parameter values
- private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
- private static final String DEFAULT_INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
- private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447";
- private static final String DEFAULT_SECURITY_PRINCIPAL = "userid";
- private static final String DEFAULT_SECURITY_CREDENTIALS = "password";
- private static final String DEFAULT_CONSUMER_TOPIC = "apex-in";
- private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
- private static final int DEFAULT_CONSUMER_WAIT_TIME = 100;
- private static final boolean DEFAULT_TO_OBJECT_MESSAGE_SENDING = true;
+ private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
+ private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
+ private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447";
+ private static final String DEFAULT_SECURITY_PRINCIPAL = "userid";
+ private static final String DEFAULT_SECURITY_CREDENTIALS = "password";
+ private static final String DEFAULT_CONSUMER_TOPIC = "apex-in";
+ private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
+ private static final int DEFAULT_CONSUMER_WAIT_TIME = 100;
+ private static final boolean DEFAULT_TO_OBJECT_MSG_SENDING = true;
// Parameter property map tokens
private static final String PROPERTY_INITIAL_CONTEXT_FACTORY = Context.INITIAL_CONTEXT_FACTORY;
@@ -100,21 +100,21 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
// JMS carrier parameters
private String connectionFactory = DEFAULT_CONNECTION_FACTORY;
- private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY;
+ private String initialContextFactory = DEFAULT_INITIAL_CTXT_FACTORY;
private String providerUrl = DEFAULT_PROVIDER_URL;
private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL;
private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
private String consumerTopic = DEFAULT_CONSUMER_TOPIC;
private int consumerWaitTime = DEFAULT_CONSUMER_WAIT_TIME;
- private boolean objectMessageSending = DEFAULT_TO_OBJECT_MESSAGE_SENDING;
+ private boolean objectMessageSending = DEFAULT_TO_OBJECT_MSG_SENDING;
// @formatter:on
/**
* Constructor to create a jms carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public JMSCarrierTechnologyParameters() {
+ public JmsCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the JMS carrier technology
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java
index 3351a58e9..dfb12617c 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java
@@ -47,7 +47,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexKafkaConsumer.class);
// The Kafka parameters read from the parameter service
- private KAFKACarrierTechnologyParameters kafkaConsumerProperties;
+ private KafkaCarrierTechnologyParameters kafkaConsumerProperties;
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -79,7 +79,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable {
this.name = consumerName;
// Check and get the Kafka Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof KAFKACarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) {
LOGGER.warn("specified consumer properties of type \""
+ consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
+ "\" are not applicable to a Kafka consumer");
@@ -88,10 +88,10 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable {
+ "\" are not applicable to a Kafka consumer");
}
kafkaConsumerProperties =
- (KAFKACarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ (KafkaCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Kick off the Kafka consumer
- kafkaConsumer = new KafkaConsumer<String, String>(kafkaConsumerProperties.getKafkaConsumerProperties());
+ kafkaConsumer = new KafkaConsumer<>(kafkaConsumerProperties.getKafkaConsumerProperties());
kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicList());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: "
@@ -153,7 +153,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable {
@Override
public void run() {
// Kick off the Kafka consumer
- kafkaConsumer = new KafkaConsumer<String, String>(kafkaConsumerProperties.getKafkaConsumerProperties());
+ kafkaConsumer = new KafkaConsumer<>(kafkaConsumerProperties.getKafkaConsumerProperties());
kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicList());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: "
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java
index fb851bc70..c83c0ae1e 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java
@@ -46,7 +46,7 @@ public class ApexKafkaProducer implements ApexEventProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexKafkaProducer.class);
// The Kafka parameters read from the parameter service
- private KAFKACarrierTechnologyParameters kafkaProducerProperties;
+ private KafkaCarrierTechnologyParameters kafkaProducerProperties;
// The Kafka Producer used to send events using Kafka
private Producer<String, Object> kafkaProducer;
@@ -63,13 +63,14 @@ public class ApexKafkaProducer implements ApexEventProducer {
this.name = producerName;
// Check and get the Kafka Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof KAFKACarrierTechnologyParameters)) {
- LOGGER.warn("specified producer properties are not applicable to a Kafka producer (" + this.name + ")");
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) {
+ String message = "specified producer properties are not applicable to a Kafka producer (" + this.name + ")";
+ LOGGER.warn(message);
throw new ApexEventException(
- "specified producer properties are not applicable to a Kafka producer (" + this.name + ")");
+ message);
}
kafkaProducerProperties =
- (KAFKACarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ (KafkaCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
}
/*
@@ -122,7 +123,7 @@ public class ApexKafkaProducer implements ApexEventProducer {
// Kafka producer must be started in the same thread as it is stopped, so we must start it here
if (kafkaProducer == null) {
// Kick off the Kafka producer
- kafkaProducer = new KafkaProducer<String, Object>(kafkaProducerProperties.getKafkaProducerProperties());
+ kafkaProducer = new KafkaProducer<>(kafkaProducerProperties.getKafkaProducerProperties());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("event producer " + this.name + " is ready to send to topics: "
+ kafkaProducerProperties.getProducerTopic());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java
index 5ce96662e..9d7cc77f3 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java
@@ -33,7 +33,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameters {
// @formatter:off
/** The label of this carrier technology. */
public static final String KAFKA_CARRIER_TECHNOLOGY_LABEL = "KAFKA";
@@ -48,23 +48,23 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string";
// Default parameter values
- private static final String DEFAULT_ACKS = "all";
- private static final String DEFAULT_BOOTSTRAP_SERVERS = "localhost:9092";
- private static final int DEFAULT_RETRIES = 0;
- private static final int DEFAULT_BATCH_SIZE = 16384;
- private static final int DEFAULT_LINGER_TIME = 1;
- private static final long DEFAULT_BUFFER_MEMORY = 33554432;
- private static final String DEFAULT_GROUP_ID = "default-group-id";
- private static final boolean DEFAULT_ENABLE_AUTO_COMMIT = true;
- private static final int DEFAULT_AUTO_COMMIT_TIME = 1000;
- private static final int DEFAULT_SESSION_TIMEOUT = 30000;
- private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
- private static final int DEFAULT_CONSUMER_POLL_TIME = 100;
- private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = {"apex-in"};
- private static final String DEFAULT_KEY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer";
- private static final String DEFAULT_VALUE_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer";
- private static final String DEFAULT_KEY_DESERIALIZER = "org.apache.kafka.common.serialization.StringDeserializer";
- private static final String DEFAULT_VALUE_DESERIALIZER = "org.apache.kafka.common.serialization.StringDeserializer";
+ private static final String DEFAULT_ACKS = "all";
+ private static final String DEFAULT_BOOT_SERVERS = "localhost:9092";
+ private static final int DEFAULT_RETRIES = 0;
+ private static final int DEFAULT_BATCH_SIZE = 16384;
+ private static final int DEFAULT_LINGER_TIME = 1;
+ private static final long DEFAULT_BUFFER_MEMORY = 33554432;
+ private static final String DEFAULT_GROUP_ID = "default-group-id";
+ private static final boolean DEFAULT_ENABLE_AUTOCMIT = true;
+ private static final int DEFAULT_AUTO_COMMIT_TIME = 1000;
+ private static final int DEFAULT_SESSION_TIMEOUT = 30000;
+ private static final String DEFAULT_PROD_TOPIC = "apex-out";
+ private static final int DEFAULT_CONS_POLL_TIME = 100;
+ private static final String[] DEFAULT_CONS_TOPICLIST = {"apex-in"};
+ private static final String DEFAULT_KEY_SERZER = "org.apache.kafka.common.serialization.StringSerializer";
+ private static final String DEFAULT_VAL_SERZER = "org.apache.kafka.common.serialization.StringSerializer";
+ private static final String DEFAULT_KEY_DESZER = "org.apache.kafka.common.serialization.StringDeserializer";
+ private static final String DEFAULT_VALUE_DESZER = "org.apache.kafka.common.serialization.StringDeserializer";
// Parameter property map tokens
private static final String PROPERTY_BOOTSTRAP_SERVERS = "bootstrap.servers";
@@ -83,30 +83,30 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
private static final String PROPERTY_VALUE_DESERIALIZER = "value.deserializer";
// kafka carrier parameters
- private String bootstrapServers = DEFAULT_BOOTSTRAP_SERVERS;
+ private String bootstrapServers = DEFAULT_BOOT_SERVERS;
private String acks = DEFAULT_ACKS;
private int retries = DEFAULT_RETRIES;
private int batchSize = DEFAULT_BATCH_SIZE;
private int lingerTime = DEFAULT_LINGER_TIME;
private long bufferMemory = DEFAULT_BUFFER_MEMORY;
private String groupId = DEFAULT_GROUP_ID;
- private boolean enableAutoCommit = DEFAULT_ENABLE_AUTO_COMMIT;
+ private boolean enableAutoCommit = DEFAULT_ENABLE_AUTOCMIT;
private int autoCommitTime = DEFAULT_AUTO_COMMIT_TIME;
private int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
- private String producerTopic = DEFAULT_PRODUCER_TOPIC;
- private int consumerPollTime = DEFAULT_CONSUMER_POLL_TIME;
- private String[] consumerTopicList = DEFAULT_CONSUMER_TOPIC_LIST;
- private String keySerializer = DEFAULT_KEY_SERIALIZER;
- private String valueSerializer = DEFAULT_VALUE_SERIALIZER;
- private String keyDeserializer = DEFAULT_KEY_DESERIALIZER;
- private String valueDeserializer = DEFAULT_VALUE_DESERIALIZER;
+ private String producerTopic = DEFAULT_PROD_TOPIC;
+ private int consumerPollTime = DEFAULT_CONS_POLL_TIME;
+ private String[] consumerTopicList = DEFAULT_CONS_TOPICLIST;
+ private String keySerializer = DEFAULT_KEY_SERZER;
+ private String valueSerializer = DEFAULT_VAL_SERZER;
+ private String keyDeserializer = DEFAULT_KEY_DESZER;
+ private String valueDeserializer = DEFAULT_VALUE_DESZER;
// @formatter:on
/**
* Constructor to create a kafka carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public KAFKACarrierTechnologyParameters() {
+ public KafkaCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the kafka carrier technology
@@ -394,7 +394,7 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
return result;
}
-
+
private void validateConsumerTopicList(final GroupValidationResult result) {
if (consumerTopicList == null || consumerTopicList.length == 0) {
result.setResult("consumerTopicList", ValidationStatus.INVALID,
@@ -414,6 +414,6 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
}
private boolean isNullOrBlank(final String stringValue) {
- return stringValue == null || stringValue.trim().length() == 0;
+ return stringValue == null || stringValue.trim().length() == 0;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
index af5d4d861..13edea8a6 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
@@ -52,7 +52,7 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
private static final long REST_CLIENT_WAIT_SLEEP_TIME = 50;
// The REST parameters read from the parameter service
- private RESTClientCarrierTechnologyParameters restConsumerProperties;
+ private RestClientCarrierTechnologyParameters restConsumerProperties;
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -77,22 +77,22 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
this.name = consumerName;
// Check and get the REST Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RESTClientCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) {
final String errorMessage = "specified consumer properties are not applicable to REST client consumer ("
+ this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restConsumerProperties = (RESTClientCarrierTechnologyParameters) consumerParameters
+ restConsumerProperties = (RestClientCarrierTechnologyParameters) consumerParameters
.getCarrierTechnologyParameters();
// Check if the HTTP method has been set
if (restConsumerProperties.getHttpMethod() == null) {
- restConsumerProperties.setHttpMethod(RESTClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD);
+ restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD);
}
if (!restConsumerProperties.getHttpMethod()
- .equalsIgnoreCase(RESTClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD)) {
+ .equalsIgnoreCase(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD)) {
final String errorMessage = "specified HTTP method of \"" + restConsumerProperties.getHttpMethod()
+ "\" is invalid, only HTTP method \"GET\" "
+ "is supported for event reception on REST client consumer (" + this.name + ")";
@@ -214,17 +214,17 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
}
// Get the event we received
- final String eventJSONString = response.readEntity(String.class);
+ final String eventJsonString = response.readEntity(String.class);
// Check there is content
- if (eventJSONString == null || eventJSONString.trim().length() == 0) {
+ if (eventJsonString == null || eventJsonString.trim().length() == 0) {
final String errorMessage = "received an empty event from URL \"" + restConsumerProperties.getUrl()
+ "\"";
throw new ApexEventRuntimeException(errorMessage);
}
// Send the event into Apex
- eventReceiver.receiveEvent(eventJSONString);
+ eventReceiver.receiveEvent(eventJsonString);
} catch (final Exception e) {
LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
index 2765fe9e7..82c3cf331 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
@@ -51,7 +51,7 @@ public class ApexRestClientProducer implements ApexEventProducer {
private Client client;
// The REST carrier properties
- private RESTClientCarrierTechnologyParameters restProducerProperties;
+ private RestClientCarrierTechnologyParameters restProducerProperties;
// The name for this producer
private String name = null;
@@ -67,29 +67,29 @@ public class ApexRestClientProducer implements ApexEventProducer {
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the REST Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof RESTClientCarrierTechnologyParameters)) {
- final String errorMessage =
- "specified consumer properties are not applicable to REST client producer (" + this.name + ")";
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) {
+ final String errorMessage = "specified consumer properties are not applicable to REST client producer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restProducerProperties =
- (RESTClientCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ restProducerProperties = (RestClientCarrierTechnologyParameters) producerParameters
+ .getCarrierTechnologyParameters();
// Check if the HTTP method has been set
if (restProducerProperties.getHttpMethod() == null) {
- restProducerProperties.setHttpMethod(RESTClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD);
+ restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD);
}
if (!restProducerProperties.getHttpMethod().equalsIgnoreCase("POST")
- && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) {
+ && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) {
final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod()
- + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted for event sending on REST client producer ("
- + this.name + ")";
+ + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
+ + "for event sending on REST client producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
@@ -139,8 +139,8 @@ public class ApexRestClientProducer implements ApexEventProducer {
@Override
public void sendEvent(final long executionId, final String eventName, final Object event) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
@@ -151,15 +151,16 @@ public class ApexRestClientProducer implements ApexEventProducer {
// Check that the request worked
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
final String errorMessage = "send of event to URL \"" + restProducerProperties.getUrl() + "\" using HTTP \""
- + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus()
- + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event;
+ + restProducerProperties.getHttpMethod() + "\" failed with status code "
+ + response.getStatus() + " and message \"" + response.readEntity(String.class)
+ + "\", event:\n" + event;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name,
- restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
+ restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
index d260cbeca..86c8bb4cf 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
@@ -37,7 +37,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Joss Armstrong (joss.armstrong@ericsson.com)
*/
-public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class RestClientCarrierTechnologyParameters extends CarrierTechnologyParameters {
/** The label of this carrier technology. */
public static final String RESTCLIENT_CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
@@ -61,7 +61,7 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public RESTClientCarrierTechnologyParameters() {
+ public RestClientCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the web socket carrier technology
@@ -83,10 +83,10 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
/**
* Sets the URL for the REST request.
*
- * @param incomingURL the URL
+ * @param incomingUrl the URL
*/
- public void setURL(final String incomingURL) {
- this.url = incomingURL;
+ public void setUrl(final String incomingUrl) {
+ this.url = incomingUrl;
}
/**
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java
index 12b9a695c..4b16d30d4 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java
@@ -31,32 +31,67 @@ public class ApexRestRequest {
private Object event;
private long timestamp;
+ /**
+ * Instantiates a new apex rest request.
+ *
+ * @param executionId the execution id
+ * @param eventName the event name
+ * @param event the event
+ */
public ApexRestRequest(final long executionId, final String eventName, final Object event) {
this.executionId = executionId;
this.eventName = eventName;
this.event = event;
}
+ /**
+ * Gets the execution id.
+ *
+ * @return the execution id
+ */
public long getExecutionId() {
return executionId;
}
+ /**
+ * Gets the event name.
+ *
+ * @return the event name
+ */
public String getEventName() {
return eventName;
}
+ /**
+ * Gets the event.
+ *
+ * @return the event
+ */
public Object getEvent() {
return event;
}
+ /**
+ * Gets the timestamp.
+ *
+ * @return the timestamp
+ */
public long getTimestamp() {
return timestamp;
}
+ /**
+ * Sets the timestamp.
+ *
+ * @param timestamp the new timestamp
+ */
public void setTimestamp(final long timestamp) {
this.timestamp = timestamp;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
return "ApexRestRequest [executionId=" + executionId + ", eventName=" + eventName + ", event=" + event
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
index 9998349db..dea839ebb 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
@@ -49,8 +49,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class implements an Apex event consumer that issues a REST request and returns the REST
- * response to APEX as an event.
+ * This class implements an Apex event consumer that issues a REST request and returns the REST response to APEX as an
+ * event.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -63,10 +63,10 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
private static final long REST_REQUESTOR_WAIT_SLEEP_TIME = 50;
// The REST parameters read from the parameter service
- private RESTRequestorCarrierTechnologyParameters restConsumerProperties;
+ private RestRequestorCarrierTechnologyParameters restConsumerProperties;
// The timeout for REST requests
- private long restRequestTimeout = RESTRequestorCarrierTechnologyParameters.DEFAULT_REST_REQUEST_TIMEOUT;
+ private long restRequestTimeout = RestRequestorCarrierTechnologyParameters.DEFAULT_REST_REQUEST_TIMEOUT;
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -99,25 +99,25 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
this.eventReceiver = incomingEventReceiver;
this.name = consumerName;
// Check and get the REST Properties
if (!(consumerParameters
- .getCarrierTechnologyParameters() instanceof RESTRequestorCarrierTechnologyParameters)) {
- final String errorMessage =
- "specified consumer properties are not applicable to REST Requestor consumer (" + this.name + ")";
+ .getCarrierTechnologyParameters() instanceof RestRequestorCarrierTechnologyParameters)) {
+ final String errorMessage = "specified consumer properties are not applicable to REST Requestor consumer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restConsumerProperties =
- (RESTRequestorCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ restConsumerProperties = (RestRequestorCarrierTechnologyParameters) consumerParameters
+ .getCarrierTechnologyParameters();
// Check if we are in peered mode
if (!consumerParameters.isPeeredMode(EventHandlerPeeredMode.REQUESTOR)) {
final String errorMessage = "REST Requestor consumer (" + this.name
- + ") must run in peered requestor mode with a REST Requestor producer";
+ + ") must run in peered requestor mode with a REST Requestor producer";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
@@ -125,7 +125,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
// Check if the HTTP method has been set
if (restConsumerProperties.getHttpMethod() == null) {
restConsumerProperties
- .setHttpMethod(RESTRequestorCarrierTechnologyParameters.DEFAULT_REQUESTOR_HTTP_METHOD);
+ .setHttpMethod(RestRequestorCarrierTechnologyParameters.DEFAULT_REQUESTOR_HTTP_METHOD);
}
// Check if the HTTP URL has been set
@@ -164,8 +164,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
try {
incomingRestRequestQueue.add(restRequest);
} catch (final Exception e) {
- final String errorMessage =
- "could not queue request \"" + restRequest + "\" on REST Requestor consumer (" + this.name + ")";
+ final String errorMessage = "could not queue request \"" + restRequest + "\" on REST Requestor consumer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -196,7 +196,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
}
/**
- * Get the number of events received to date
+ * Get the number of events received to date.
*
* @return the number of events received
*/
@@ -238,8 +238,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
while (consumerThread.isAlive() && !stopOrderedFlag) {
try {
// Take the next event from the queue
- final ApexRestRequest restRequest =
- incomingRestRequestQueue.poll(REST_REQUESTOR_WAIT_SLEEP_TIME, TimeUnit.MILLISECONDS);
+ final ApexRestRequest restRequest = incomingRestRequestQueue.poll(REST_REQUESTOR_WAIT_SLEEP_TIME,
+ TimeUnit.MILLISECONDS);
if (restRequest == null) {
// Poll timed out, check for request timeouts
timeoutExpiredRequests();
@@ -268,7 +268,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
}
/**
- * This method times out REST requests that have expired
+ * This method times out REST requests that have expired.
*/
private void timeoutExpiredRequests() {
// Hold a list of timed out requests
@@ -284,8 +284,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
// Interrupt timed out requests and remove them from the ongoing map
for (final ApexRestRequest timedoutRequest : timedoutRequestList) {
- final String errorMessage =
- "REST Requestor consumer (" + this.name + "), REST request timed out: " + timedoutRequest;
+ final String errorMessage = "REST Requestor consumer (" + this.name + "), REST request timed out: "
+ + timedoutRequest;
LOGGER.warn(errorMessage);
ongoingRestRequestMap.remove(timedoutRequest);
@@ -321,7 +321,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
private Thread restRequestThread;
/**
- * Constructor, initialise the request runner with the request
+ * Constructor, initialise the request runner with the request.
*
* @param request the request this runner will issue
*/
@@ -341,28 +341,29 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
try {
// Execute the REST request
- final Response response = sendEventAsRESTRequest();
+ final Response response = sendEventAsRestRequest();
// Check that the event request worked
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
final String errorMessage = "reception of response to \"" + request + "\" from URL \""
- + restConsumerProperties.getUrl() + "\" failed with status code " + response.getStatus()
- + " and message \"" + response.readEntity(String.class) + "\"";
+ + restConsumerProperties.getUrl() + "\" failed with status code "
+ + response.getStatus() + " and message \"" + response.readEntity(String.class)
+ + "\"";
throw new ApexEventRuntimeException(errorMessage);
}
// Get the event we received
- final String eventJSONString = response.readEntity(String.class);
+ final String eventJsonString = response.readEntity(String.class);
// Check there is content
- if (eventJSONString == null || eventJSONString.trim().length() == 0) {
+ if (eventJsonString == null || eventJsonString.trim().length() == 0) {
final String errorMessage = "received an enpty response to \"" + request + "\" from URL \""
- + restConsumerProperties.getUrl() + "\"";
+ + restConsumerProperties.getUrl() + "\"";
throw new ApexEventRuntimeException(errorMessage);
}
// Send the event into Apex
- eventReceiver.receiveEvent(request.getExecutionId(), eventJSONString);
+ eventReceiver.receiveEvent(request.getExecutionId(), eventJsonString);
synchronized (eventsReceivedLock) {
eventsReceived++;
@@ -376,7 +377,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
}
/**
- * Stop the REST request
+ * Stop the REST request.
*/
private void stop() {
restRequestThread.interrupt();
@@ -387,21 +388,24 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
*
* @return the response to the REST request
*/
- public Response sendEventAsRESTRequest() {
+ public Response sendEventAsRestRequest() {
switch (restConsumerProperties.getHttpMethod()) {
case GET:
return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON).get();
case PUT:
return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON)
- .put(Entity.json(request.getEvent()));
+ .put(Entity.json(request.getEvent()));
case POST:
return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON)
- .post(Entity.json(request.getEvent()));
+ .post(Entity.json(request.getEvent()));
case DELETE:
return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON).delete();
+
+ default:
+ break;
}
return null;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java
index 721dfb683..69ad05b27 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java
@@ -44,7 +44,7 @@ public class ApexRestRequestorProducer implements ApexEventProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestRequestorProducer.class);
// The REST carrier properties
- private RESTRequestorCarrierTechnologyParameters restProducerProperties;
+ private RestRequestorCarrierTechnologyParameters restProducerProperties;
// The name for this producer
private String name = null;
@@ -68,14 +68,14 @@ public class ApexRestRequestorProducer implements ApexEventProducer {
// Check and get the REST Properties
if (!(producerParameters
- .getCarrierTechnologyParameters() instanceof RESTRequestorCarrierTechnologyParameters)) {
+ .getCarrierTechnologyParameters() instanceof RestRequestorCarrierTechnologyParameters)) {
final String errorMessage =
"specified consumer properties are not applicable to REST requestor producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
restProducerProperties =
- (RESTRequestorCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ (RestRequestorCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if we are in peered mode
if (!producerParameters.isPeeredMode(EventHandlerPeeredMode.REQUESTOR)) {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
index 65eb731ed..acd5e52e8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
@@ -37,9 +37,9 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class RestRequestorCarrierTechnologyParameters extends CarrierTechnologyParameters {
/** The supported HTTP methods. */
- public enum HTTP_METHOD {
+ public enum HttpMethod {
GET, PUT, POST, DELETE
}
@@ -55,19 +55,19 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
ApexRestRequestorConsumer.class.getCanonicalName();
/** The default HTTP method for request events. */
- public static final HTTP_METHOD DEFAULT_REQUESTOR_HTTP_METHOD = HTTP_METHOD.GET;
+ public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
/** The default timeout for REST requests. */
public static final long DEFAULT_REST_REQUEST_TIMEOUT = 500;
private String url = null;
- private HTTP_METHOD httpMethod = null;
+ private HttpMethod httpMethod = null;
/**
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public RESTRequestorCarrierTechnologyParameters() {
+ public RestRequestorCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the web socket carrier technology
@@ -88,10 +88,10 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
/**
* Sets the URL for the REST request.
*
- * @param incomingURL the URL
+ * @param incomingUrl the URL
*/
- public void setURL(final String incomingURL) {
- this.url = incomingURL;
+ public void setUrl(final String incomingUrl) {
+ this.url = incomingUrl;
}
/**
@@ -99,7 +99,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
*
* @return the HTTP method
*/
- public HTTP_METHOD getHttpMethod() {
+ public HttpMethod getHttpMethod() {
return httpMethod;
}
@@ -108,7 +108,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
*
* @param httpMethod the HTTP method
*/
- public void setHttpMethod(final HTTP_METHOD httpMethod) {
+ public void setHttpMethod(final HttpMethod httpMethod) {
this.httpMethod = httpMethod;
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestor.java
index 3db0f1467..051647339 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestor.java
@@ -48,7 +48,10 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
-public class TestRESTRequestor {
+/**
+ * The Class TestRestRequestor.
+ */
+public class TestRestRequestor {
private static final String BASE_URI = "http://localhost:32801/TestRESTRequestor";
private static HttpServer server;
@@ -58,6 +61,11 @@ public class TestRESTRequestor {
private final PrintStream stdout = System.out;
private final PrintStream stderr = System.err;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@BeforeClass
public static void setUp() throws Exception {
final ResourceConfig rc = new ResourceConfig(TestRestRequestorEndpoint.class);
@@ -68,6 +76,11 @@ public class TestRESTRequestor {
}
}
+ /**
+ * Tear down.
+ *
+ * @throws Exception the exception
+ */
@AfterClass
public static void tearDown() throws Exception {
server.shutdownNow();
@@ -77,16 +90,27 @@ public class TestRESTRequestor {
new File("src/test/resources/events/EventsOutMulti1.json").delete();
}
+ /**
+ * Reset counters.
+ */
@Before
public void resetCounters() {
TestRestRequestorEndpoint.resetCounters();
}
+ /**
+ * Test rest requestor get.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorGet() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorGet() throws MessagingException, ApexException, IOException {
final Client client = ClientBuilder.newClient();
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGet.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FileGet.json" };
final ApexMain apexMain = new ApexMain(args);
// Wait for the required amount of events to be received or for 10 seconds
@@ -95,7 +119,7 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(100);
final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
@@ -115,11 +139,19 @@ public class TestRESTRequestor {
assertEquals(Double.valueOf(50.0), getsSoFar);
}
+ /**
+ * Test REST requestor put.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorPut() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorPut() throws MessagingException, ApexException, IOException {
final Client client = ClientBuilder.newClient();
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FilePut.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FilePut.json" };
final ApexMain apexMain = new ApexMain(args);
// Wait for the required amount of events to be received or for 10 seconds
@@ -128,7 +160,7 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(100);
final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
@@ -148,11 +180,19 @@ public class TestRESTRequestor {
assertEquals(Double.valueOf(50.0), putsSoFar);
}
+ /**
+ * Test REST requestor post.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorPost() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorPost() throws MessagingException, ApexException, IOException {
final Client client = ClientBuilder.newClient();
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FilePost.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FilePost.json" };
final ApexMain apexMain = new ApexMain(args);
// Wait for the required amount of events to be received or for 10 seconds
@@ -161,7 +201,7 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(100);
final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
@@ -181,11 +221,19 @@ public class TestRESTRequestor {
assertEquals(Double.valueOf(50.0), postsSoFar);
}
+ /**
+ * Test REST requestor delete.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorDelete() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorDelete() throws MessagingException, ApexException, IOException {
final Client client = ClientBuilder.newClient();
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileDelete.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FileDelete.json" };
final ApexMain apexMain = new ApexMain(args);
// Wait for the required amount of events to be received or for 10 seconds
@@ -194,7 +242,7 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(100);
final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
@@ -214,11 +262,19 @@ public class TestRESTRequestor {
assertEquals(Double.valueOf(50.0), deletesSoFar);
}
+ /**
+ * Test REST requestor multi inputs.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorMultiInputs() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorMultiInputs() throws MessagingException, ApexException, IOException {
final Client client = ClientBuilder.newClient();
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json" };
final ApexMain apexMain = new ApexMain(args);
// Wait for the required amount of events to be received or for 10 seconds
@@ -227,7 +283,7 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(100);
final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
@@ -249,12 +305,20 @@ public class TestRESTRequestor {
ThreadUtilities.sleep(1000);
}
+ /**
+ * Test REST requestor producer alone.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorProducerAlone() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorProducerAlone() throws MessagingException, ApexException, IOException {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json" };
final ApexMain apexMain = new ApexMain(args);
ThreadUtilities.sleep(200);
@@ -265,16 +329,24 @@ public class TestRESTRequestor {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(
- "REST Requestor producer (RestRequestorProducer) must run in peered requestor mode with a REST Requestor consumer"));
+ assertTrue(outString.contains("REST Requestor producer (RestRequestorProducer) "
+ + "must run in peered requestor mode with a REST Requestor consumer"));
}
+ /**
+ * Test REST requestor consumer alone.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
- public void testRESTRequestorConsumerAlone() throws MessagingException, ApexException, IOException {
+ public void testRestRequestorConsumerAlone() throws MessagingException, ApexException, IOException {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
- final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json" };
+ final String[] args =
+ { "src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json" };
final ApexMain apexMain = new ApexMain(args);
ThreadUtilities.sleep(200);
@@ -285,7 +357,7 @@ public class TestRESTRequestor {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(
- "peer \"RestRequestorProducer for peered mode REQUESTOR does not exist or is not defined with the same peered mode"));
+ assertTrue(outString.contains("peer \"RestRequestorProducer for peered mode REQUESTOR "
+ + "does not exist or is not defined with the same peered mode"));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java
index 4977b3efb..0de34eb9b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java
@@ -34,6 +34,9 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
+/**
+ * The Class TestRestRequestorEndpoint.
+ */
@Path("/apex")
public class TestRestRequestorEndpoint {
@@ -50,6 +53,9 @@ public class TestRestRequestorEndpoint {
+ "\"TestMatchCase\": 2,\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + ",\n"
+ "\"TestTemperature\": 9080.866\n" + "}";
+ /**
+ * Reset counters.
+ */
public static void resetCounters() {
postMessagesReceived = 0;
putMessagesReceived = 0;
@@ -58,6 +64,11 @@ public class TestRestRequestorEndpoint {
deleteMessagesReceived = 0;
}
+ /**
+ * Service get stats.
+ *
+ * @return the response
+ */
@Path("/event/Stats")
@GET
public Response serviceGetStats() {
@@ -71,6 +82,11 @@ public class TestRestRequestorEndpoint {
.build();
}
+ /**
+ * Service get event.
+ *
+ * @return the response
+ */
@Path("/event/GetEvent")
@GET
public Response serviceGetEvent() {
@@ -81,18 +97,34 @@ public class TestRestRequestorEndpoint {
return Response.status(200).entity(EVENT_STRING).build();
}
+ /**
+ * Service get empty event.
+ *
+ * @return the response
+ */
@Path("/event/GetEmptyEvent")
@GET
public Response serviceGetEmptyEvent() {
return Response.status(200).build();
}
+ /**
+ * Service get event bad response.
+ *
+ * @return the response
+ */
@Path("/event/GetEventBadResponse")
@GET
public Response serviceGetEventBadResponse() {
return Response.status(400).build();
}
+ /**
+ * Service post request.
+ *
+ * @param jsonString the json string
+ * @return the response
+ */
@Path("/event/PostEvent")
@POST
public Response servicePostRequest(final String jsonString) {
@@ -111,12 +143,24 @@ public class TestRestRequestorEndpoint {
return Response.status(200).entity(EVENT_STRING).build();
}
+ /**
+ * Service post request bad response.
+ *
+ * @param jsonString the json string
+ * @return the response
+ */
@Path("/event/PostEventBadResponse")
@POST
public Response servicePostRequestBadResponse(final String jsonString) {
return Response.status(400).build();
}
+ /**
+ * Service put request.
+ *
+ * @param jsonString the json string
+ * @return the response
+ */
@Path("/event/PutEvent")
@PUT
public Response servicePutRequest(final String jsonString) {
@@ -135,6 +179,12 @@ public class TestRestRequestorEndpoint {
return Response.status(200).entity(EVENT_STRING).build();
}
+ /**
+ * Service delete request.
+ *
+ * @param jsonString the json string
+ * @return the response
+ */
@Path("/event/DeleteEvent")
@DELETE
public Response serviceDeleteRequest(final String jsonString) {
@@ -145,6 +195,12 @@ public class TestRestRequestorEndpoint {
return Response.status(200).entity(EVENT_STRING).build();
}
+ /**
+ * Service delete request bad response.
+ *
+ * @param jsonString the json string
+ * @return the response
+ */
@Path("/event/DeleteEventBadResponse")
@DELETE
public Response serviceDeleteRequestBadResponse(final String jsonString) {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json
index 6e12c0b1f..46da3970a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/DeleteEvent",
"httpMethod": "DELETE",
@@ -49,7 +49,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json
index d0879eb73..3c1d314fe 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
"httpMethod": "GET",
@@ -49,7 +49,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json
index b957b61de..9ebe89df5 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
"httpMethod": "GET",
@@ -49,7 +49,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json
index ba1c997f5..424d2b454 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer0": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
"httpMethod": "GET",
@@ -58,7 +58,7 @@
"RestRequestorConsumer1": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
"httpMethod": "GET",
@@ -78,7 +78,7 @@
"RestRequestorProducer0": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
@@ -103,7 +103,7 @@
"RestRequestorProducer1": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json
index a635e6c72..4fcbf59d9 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -31,7 +31,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json
index 9db89ce89..fe5af67ee 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/PostEvent",
"httpMethod": "POST",
@@ -49,7 +49,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json
index 3eebe3d8a..e78446447 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json
@@ -9,7 +9,7 @@
"engineParameters": {
"executorParameters": {
"MVEL": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
}
}
}
@@ -29,7 +29,7 @@
"RestRequestorConsumer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
"parameters": {
"url": "http://localhost:32801/TestRESTRequestor/apex/event/PutEvent",
"httpMethod": "PUT",
@@ -49,7 +49,7 @@
"RestRequestorProducer": {
"carrierTechnologyParameters": {
"carrierTechnology": "RESTREQUESTOR",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
},
"eventProtocolParameters": {
"eventProtocol": "JSON"
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
index 8cf0c8f9c..94063af20 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
@@ -56,9 +56,6 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// The amount of time to wait in milliseconds between checks that the consumer thread has stopped
private static final long REST_SERVER_CONSUMER_WAIT_SLEEP_TIME = 50;
- // The REST parameters read from the parameter service
- private RESTServerCarrierTechnologyParameters restConsumerProperties;
-
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -84,7 +81,7 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
*
* @return the next candidate value for a Execution ID
*/
- private static synchronized long getNextExecutionID() {
+ private static synchronized long getNextExecutionId() {
return nextExecutionID.getAndIncrement();
}
@@ -102,14 +99,16 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
this.name = consumerName;
// Check and get the REST Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) {
final String errorMessage =
"specified consumer properties are not applicable to REST Server consumer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restConsumerProperties =
- (RESTServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+
+ // The REST parameters read from the parameter service
+ RestServerCarrierTechnologyParameters restConsumerProperties =
+ (RestServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Check if we are in synchronous mode
if (!consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) {
@@ -131,12 +130,12 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
}
// Compose the URI for the standalone server
- final String baseURI = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(),
+ final String baseUrl = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(),
restConsumerProperties.getPort());
// Instantiate the standalone server
final ResourceConfig rc = new ResourceConfig(RestServerEndpoint.class, AccessControlFilter.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseURI), rc);
+ server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUrl), rc);
while (!server.isStarted()) {
ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME);
@@ -201,10 +200,11 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
*/
public Response receiveEvent(final String event) {
// Get an execution ID for the event
- final long executionId = getNextExecutionID();
+ final long executionId = getNextExecutionId();
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event);
+ String message = name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event;
+ LOGGER.debug(message);
}
try {
@@ -222,7 +222,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// Wait until the event is in the cache of events sent to apex
do {
ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME);
- } while (!synchronousEventCache.existsEventToApex(executionId));
+ }
+ while (!synchronousEventCache.existsEventToApex(executionId));
// Now wait for the reply or for the event to time put
do {
@@ -238,7 +239,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// Return the event as a response to the call
return Response.status(Response.Status.OK.getStatusCode()).entity(responseEvent.toString()).build();
}
- } while (synchronousEventCache.existsEventToApex(executionId));
+ }
+ while (synchronousEventCache.existsEventToApex(executionId));
// The event timed out
final String errorMessage = "processing of event on event consumer " + name + " timed out, event=" + event;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
index e51482ce4..cacdb3408 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
@@ -41,9 +41,6 @@ import org.slf4j.LoggerFactory;
public class ApexRestServerProducer implements ApexEventProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestServerProducer.class);
- // The REST carrier properties
- private RESTServerCarrierTechnologyParameters restProducerProperties;
-
// The name for this producer
private String name = null;
@@ -62,14 +59,16 @@ public class ApexRestServerProducer implements ApexEventProducer {
this.name = producerName;
// Check and get the REST Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) {
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) {
final String errorMessage =
"specified producer properties are not applicable to REST Server producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restProducerProperties =
- (RESTServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+
+ // The REST carrier properties
+ RestServerCarrierTechnologyParameters restProducerProperties =
+ (RestServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if host and port are defined
if (restProducerProperties.getHost() != null || restProducerProperties.getPort() != -1
@@ -131,7 +130,8 @@ public class ApexRestServerProducer implements ApexEventProducer {
@Override
public void sendEvent(final long executionId, final String eventName, final Object event) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event);
+ String message = name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event;
+ LOGGER.debug(message);
}
// If we are not synchronized, then exit
@@ -163,5 +163,7 @@ public class ApexRestServerProducer implements ApexEventProducer {
* @see org.onap.policy.apex.service.engine.event.ApexEventProducer#stop()
*/
@Override
- public void stop() {}
+ public void stop() {
+ // Implementation not required on this class
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
index cd7f388f2..76ec577b8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
@@ -27,7 +27,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
*
- * The parameters for this plugin are:
+ * <p>The parameters for this plugin are:
* <ol>
* <li>standalone: A flag indicating if APEX should start a standalone HTTP server to process REST requests (true) or
* whether it should use an underlying servlet infrastructure such as Apache Tomcat (False). This parameter is legal
@@ -40,7 +40,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class RestServerCarrierTechnologyParameters extends CarrierTechnologyParameters {
// @formatter:off
private static final int MIN_USER_PORT = 1024;
private static final int MAX_USER_PORT = 65535;
@@ -64,7 +64,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public RESTServerCarrierTechnologyParameters() {
+ public RestServerCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the web socket carrier technology
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
index beee10fd0..f8524fcfd 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
@@ -57,21 +57,21 @@ public class RestServerEndpoint {
// This map is used to hold all the REST server event inputs. This is used to determine which consumer to send input
// events to
private static Map<String, ApexRestServerConsumer> consumerMap =
- new LinkedHashMap<String, ApexRestServerConsumer>();
+ new LinkedHashMap<>();
// The ID of this event input. This gets injected from the URL.
@PathParam("eventInput")
- private String eventInputID = null;
+ private String eventInputId = null;
/**
* Register an Apex consumer with the REST server end point.
*
- * @param consumerEventInputID The event input ID that indicates this consumer shoud be used
+ * @param consumerEventInputId The event input ID that indicates this consumer shoud be used
* @param consumer The consumer to register
*/
- public static void registerApexRestServerConsumer(final String consumerEventInputID,
+ public static void registerApexRestServerConsumer(final String consumerEventInputId,
final ApexRestServerConsumer consumer) {
- consumerMap.put(consumerEventInputID, consumer);
+ consumerMap.put(consumerEventInputId, consumer);
}
/**
@@ -102,7 +102,8 @@ public class RestServerEndpoint {
postEventMessagesReceived++;
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("event input " + eventInputID + ", received POST of event \"" + jsonString + "\"");
+ String message = "event input " + eventInputId + ", received POST of event \"" + jsonString + "\"";
+ LOGGER.debug(message);
}
// Common handler method for POST and PUT requests
@@ -121,7 +122,8 @@ public class RestServerEndpoint {
putEventMessagesReceived++;
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("event input \"" + eventInputID + "\", received PUT of event \"" + jsonString + "\"");
+ String message = "event input \"" + eventInputId + "\", received PUT of event \"" + jsonString + "\"";
+ LOGGER.debug(message);
}
// Common handler method for POST and PUT requests
@@ -136,10 +138,10 @@ public class RestServerEndpoint {
*/
private Response handleEvent(final String jsonString) {
// Find the correct consumer for this REST message
- final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputID);
+ final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputId);
if (eventConsumer == null) {
final String errorMessage =
- "event input " + eventInputID + " is not defined in the Apex configuration file";
+ "event input " + eventInputId + " is not defined in the Apex configuration file";
LOGGER.warn(errorMessage);
return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("{'errorMessage', '" + errorMessage + "'}").build();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
index e80efa2ee..fe3e47b82 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
@@ -50,9 +50,6 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketConsumer.class);
- // The Web Socket properties
- private WEBSOCKETCarrierTechnologyParameters webSocketConsumerProperties;
-
// The web socket messager, may be WS a server or a client
private WsStringMessager wsStringMessager;
@@ -79,12 +76,14 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage
this.name = consumerName;
// Check and get the Kafka Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WEBSOCKETCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) {
LOGGER.warn("specified consumer properties are not applicable to a web socket consumer");
throw new ApexEventException("specified consumer properties are not applicable to a web socket consumer");
}
- webSocketConsumerProperties =
- (WEBSOCKETCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+
+ // The Web Socket properties
+ WebSocketCarrierTechnologyParameters webSocketConsumerProperties =
+ (WebSocketCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Check if this is a server or a client Web Socket
if (webSocketConsumerProperties.isWsClient()) {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java
index 6be8a3d1a..7dd1ab947 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java
@@ -46,9 +46,6 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class);
- // The Web Socket properties
- private WEBSOCKETCarrierTechnologyParameters webSocketProducerProperties;
-
// The web socket messager, may be WS a server or a client
private WsStringMessager wsStringMessager;
@@ -60,23 +57,25 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the web socket Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof WEBSOCKETCarrierTechnologyParameters)) {
- LOGGER.warn(
- "specified producer properties for " + this.name + "are not applicable to a web socket producer");
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) {
+ String message = "specified producer properties for " + this.name
+ + "are not applicable to a web socket producer";
+ LOGGER.warn(message);
throw new ApexEventException("specified producer properties are not applicable to a web socket producer");
}
- webSocketProducerProperties =
- (WEBSOCKETCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ // The Web Socket properties
+ WebSocketCarrierTechnologyParameters webSocketProducerProperties =
+ (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if this is a server or a client Web Socket
if (webSocketProducerProperties.isWsClient()) {
// Create a WS client
wsStringMessager = new WsStringMessageClient(webSocketProducerProperties.getHost(),
- webSocketProducerProperties.getPort());
+ webSocketProducerProperties.getPort());
} else {
wsStringMessager = new WsStringMessageServer(webSocketProducerProperties.getPort());
}
@@ -85,7 +84,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage
try {
wsStringMessager.start(this);
} catch (final MessagingException e) {
- LOGGER.warn("could not start web socket producer (" + this.name + ")");
+ String message = "could not start web socket producer (" + this.name + ")";
+ LOGGER.warn(message);
}
}
@@ -130,8 +130,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage
@Override
public void sendEvent(final long executionId, final String eventName, final Object event) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
@@ -160,7 +160,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage
*/
@Override
public void receiveString(final String messageString) {
- LOGGER.warn("received message \"" + messageString + "\" on web socket producer (" + this.name
- + ") , no messages should be received on a web socket producer");
+ String message = "received message \"" + messageString + "\" on web socket producer (" + this.name
+ + ") , no messages should be received on a web socket producer";
+ LOGGER.warn(message);
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java
index e04a81d1d..9febeb45b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java
@@ -29,7 +29,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters {
// @formatter:off
private static final int MIN_USER_PORT = 1024;
private static final int MAX_USER_PORT = 65535;
@@ -57,7 +57,7 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* Constructor to create a web socket carrier technology parameters instance and register the instance with the
* parameter service.
*/
- public WEBSOCKETCarrierTechnologyParameters() {
+ public WebSocketCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the web socket carrier technology
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
index 6c21070c2..ca02709fe 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
@@ -33,24 +33,23 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of
- * object message events for JMS.
+ * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of object message
+ * events for JMS.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConverter {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSObjectEventConverter.class);
+public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConverter {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsObjectEventConverter.class);
// JMS event protocol parameters on the consumer (JMS->Apex) sides
- private JMSObjectEventProtocolParameters eventProtocolParameters = null;
+ private JmsObjectEventProtocolParameters eventProtocolParameters = null;
/**
* Constructor to create the Apex to JMS Object converter.
*
- * @throws ApexEventException
- * the apex event exception
+ * @throws ApexEventException the apex event exception
*/
- public Apex2JMSObjectEventConverter() throws ApexEventException {
+ public Apex2JmsObjectEventConverter() throws ApexEventException {
// Nothing specific to initiate for this plugin
}
@@ -59,13 +58,13 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv
// Check if properties have been set for JMS object event conversion as a consumer. They may not be set because
// JMS may not be in use
// on both sides of Apex
- if (!(parameters instanceof JMSObjectEventProtocolParameters)) {
+ if (!(parameters instanceof JmsObjectEventProtocolParameters)) {
final String errormessage = "specified Event Protocol Parameters properties of type \""
+ parameters.getClass().getCanonicalName() + "\" are not applicable to a "
- + Apex2JMSObjectEventConverter.class.getName() + " converter";
+ + Apex2JmsObjectEventConverter.class.getName() + " converter";
LOGGER.error(errormessage);
} else {
- this.eventProtocolParameters = (JMSObjectEventProtocolParameters) parameters;
+ this.eventProtocolParameters = (JmsObjectEventProtocolParameters) parameters;
}
}
@@ -101,7 +100,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv
// Check that the consumer parameters for JMS->Apex messaging have been set
if (eventProtocolParameters == null) {
- final String errorMessage = "consumer parameters for JMS events consumed by Apex are not set in the Apex configuration for this engine";
+ final String errorMessage = "consumer parameters for JMS events consumed by "
+ + "Apex are not set in the Apex configuration for this engine";
LOGGER.debug(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -114,7 +114,7 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv
jmsIncomingObject.toString().getClass().getPackage().getName(),
eventProtocolParameters.getIncomingEventSource(),
eventProtocolParameters.getIncomingEventTarget());
- // @formattter:on
+ // @formatter:on
// Set the data on the apex event as the incoming object
apexEvent.put(jmsIncomingObject.getClass().getSimpleName(), jmsIncomingObject);
@@ -128,7 +128,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy.apex.service.engine.event.ApexEvent)
+ * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent
+ * (org.onap.policy.apex.service.engine.event.ApexEvent)
*/
@Override
public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException {
@@ -140,7 +141,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv
// Check that the Apex event has a single parameter
if (apexEvent.size() != 1) {
- final String errorMessage = "event processing failed, Apex event must have one and only one parameter for JMS Object handling";
+ final String errorMessage = "event processing failed, "
+ + "Apex event must have one and only one parameter for JMS Object handling";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java
index e845a4a08..1c44dd111 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java
@@ -26,26 +26,19 @@ import java.util.List;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
-import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
* The Class Apex2JMSTextEventConverter converts {@link ApexEvent} instances into string instances of
* text message events for JMS. It is a proxy for the built in
- * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter} plugin.
+ * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter} plugin.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public final class Apex2JMSTextEventConverter extends Apex2JSONEventConverter {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSTextEventConverter.class);
-
- /**
- * Constructor to create the Apex to JMS Object converter.
- *
- * @throws ApexEventException the apex event exception
- */
- public Apex2JMSTextEventConverter() throws ApexEventException {}
+public final class Apex2JmsTextEventConverter extends Apex2JsonEventConverter {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsTextEventConverter.class);
/*
* (non-Javadoc)
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java
index 83aef4e9d..3c15a7825 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java
@@ -25,8 +25,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
/**
* Event protocol parameters for JMS Object messages as an event protocol.
*
- * <p>
- * On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows:
+ * <p>On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows:
* <ol>
* <li>It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.</li>
* <li>It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.</li>
@@ -40,11 +39,11 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
* <li>It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being
* the key of the entry and the actual incoming object as the value of the entry.</li>
* </ol>
- * <p>
- * When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin marshals
- * the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance.
- * <p>
- * The parameters for this plugin are:
+ *
+ * <p>When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin
+ * marshals the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance.
+ *
+ * <p>The parameters for this plugin are:
* <ol>
* <li>incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are
* encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.</li>
@@ -58,7 +57,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class JMSObjectEventProtocolParameters extends EventProtocolParameters {
+public class JmsObjectEventProtocolParameters extends EventProtocolParameters {
/** The label of this event protocol. */
public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT";
@@ -77,16 +76,17 @@ public class JMSObjectEventProtocolParameters extends EventProtocolParameters {
//@formatter:off
/**
- * 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 JMSObjectEventProtocolParameters() {
- super(JMSObjectEventProtocolParameters.class.getCanonicalName());
+ public JmsObjectEventProtocolParameters() {
+ super(JmsObjectEventProtocolParameters.class.getCanonicalName());
// Set the event protocol properties for the JMS Text event protocol
this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL);
// Set the event protocol plugin class
- this.setEventProtocolPluginClass(Apex2JMSObjectEventConverter.class.getCanonicalName());
+ this.setEventProtocolPluginClass(Apex2JmsObjectEventConverter.class.getCanonicalName());
}
/**
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java
index b3a9154ff..67b211a08 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java
@@ -20,23 +20,23 @@
package org.onap.policy.apex.plugins.event.protocol.jms;
-import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
+import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
/**
* Event protocol parameters for JMS Text messages as an event protocol.
- * <p>
- * Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can understand.
- * Therefore this plugin is a subclass of the built in JSON event protocol plugin.
- * <p>
- * On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS text
- * message and passes it to its JSON superclass unmarshaling for processing.
- * <p>
- * When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string and
- * passes that string to the JSON carrier plugin for sending.
+ *
+ * <p>Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can
+ * understand. Therefore this plugin is a subclass of the built in JSON event protocol plugin.
+ *
+ * <p>On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS
+ * text message and passes it to its JSON superclass unmarshaling for processing.
+ *
+ * <p>When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string
+ * and passes that string to the JSON carrier plugin for sending.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class JMSTextEventProtocolParameters extends JSONEventProtocolParameters {
+public class JmsTextEventProtocolParameters extends JsonEventProtocolParameters {
/** The label of this event protocol. */
public static final String JMS_TEXT_EVENT_PROTOCOL_LABEL = "JMSTEXT";
@@ -44,13 +44,13 @@ public class JMSTextEventProtocolParameters extends JSONEventProtocolParameters
* Constructor to create a JSON event protocol parameter instance and register the instance with the parameter
* service.
*/
- public JMSTextEventProtocolParameters() {
- super(JMSTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL);
+ public JmsTextEventProtocolParameters() {
+ super(JmsTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL);
// Set the event protocol properties for the JMS Text event protocol
this.setLabel(JMS_TEXT_EVENT_PROTOCOL_LABEL);
// Set the event protocol plugin class
- this.setEventProtocolPluginClass(Apex2JMSTextEventConverter.class.getCanonicalName());
+ this.setEventProtocolPluginClass(Apex2JmsTextEventConverter.class.getCanonicalName());
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XMLEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
index 76bae6833..767c24fdd 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XMLEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
@@ -56,8 +56,8 @@ import org.xml.sax.SAXException;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public final class Apex2XMLEventConverter implements ApexEventProtocolConverter {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2XMLEventConverter.class);
+public final class Apex2XmlEventConverter implements ApexEventProtocolConverter {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2XmlEventConverter.class);
private static final String MODEL_SCHEMA_NAME = "xml/apex-event.xsd";
@@ -71,11 +71,11 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter
*
* @throws ApexEventException the apex event exception
*/
- public Apex2XMLEventConverter() throws ApexEventException {
+ public Apex2XmlEventConverter() throws ApexEventException {
try {
- final URL schemaURL = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME);
+ final URL schemaUrl = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME);
final Schema apexEventSchema =
- SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL);
+ SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl);
final JAXBContext jaxbContext = JAXBContext.newInstance(XMLApexEvent.class);
@@ -101,7 +101,9 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter
* parameters. eventprotocol.EventProtocolParameters)
*/
@Override
- public void init(final EventProtocolParameters parameters) {}
+ public void init(final EventProtocolParameters parameters) {
+ // No initialization necessary on this class
+ }
/*
* (non-Javadoc)
@@ -149,7 +151,7 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter
}
// Return the event in a single element
- final ArrayList<ApexEvent> eventList = new ArrayList<ApexEvent>();
+ final ArrayList<ApexEvent> eventList = new ArrayList<>();
eventList.add(apexEvent);
return eventList;
}
@@ -170,7 +172,7 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter
}
// Get the Apex event data
- final List<XMLApexEventData> xmlDataList = new ArrayList<XMLApexEventData>();
+ final List<XMLApexEventData> xmlDataList = new ArrayList<>();
try {
for (final Entry<String, Object> apexDataEntry : apexEvent.entrySet()) {
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventProtocolParameters.java
index 0eeb497a1..9f0ee0795 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventProtocolParameters.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventProtocolParameters.java
@@ -27,7 +27,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTo
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters {
+public class XmlEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters {
/** The label of this carrier technology. */
public static final String XML_EVENT_PROTOCOL_LABEL = "XML";
@@ -38,8 +38,8 @@ public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedP
* Constructor to create a JSON event protocol parameter instance and register the instance with the parameter
* service.
*/
- public XMLEventProtocolParameters() {
- super(XMLEventProtocolParameters.class.getCanonicalName());
+ public XmlEventProtocolParameters() {
+ super(XmlEventProtocolParameters.class.getCanonicalName());
// Set the event protocol properties for the XML event protocol
this.setLabel(XML_EVENT_PROTOCOL_LABEL);
@@ -48,6 +48,6 @@ public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedP
this.setStartDelimiterToken(XML_TEXT_DELIMITER_TOKEN);
// Set the event protocol plugin class
- this.setEventProtocolPluginClass(Apex2XMLEventConverter.class.getCanonicalName());
+ this.setEventProtocolPluginClass(Apex2XmlEventConverter.class.getCanonicalName());
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLEventHandler.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlEventHandler.java
index a62cc24cf..1e42bef30 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLEventHandler.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlEventHandler.java
@@ -38,8 +38,8 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestXMLEventHandler {
- private static final XLogger logger = XLoggerFactory.getXLogger(TestXMLEventHandler.class);
+public class TestXmlEventHandler {
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestXmlEventHandler.class);
/**
* Test XML to apex event.
@@ -47,16 +47,16 @@ public class TestXMLEventHandler {
* @throws ApexException on Apex event handling errors
*/
@Test
- public void testXMLtoApexEvent() throws ApexException {
+ public void testXmltoApexEvent() throws ApexException {
try {
- final Apex2XMLEventConverter xmlEventConverter = new Apex2XMLEventConverter();
+ final Apex2XmlEventConverter xmlEventConverter = new Apex2XmlEventConverter();
assertNotNull(xmlEventConverter);
- final String apexEventXMLStringIn = XMLEventGenerator.xmlEvent();
+ final String apexEventXmlStringIn = XmlEventGenerator.xmlEvent();
- logger.debug("input event\n" + apexEventXMLStringIn);
+ logger.debug("input event\n" + apexEventXmlStringIn);
- for (final ApexEvent apexEvent : xmlEventConverter.toApexEvent("XMLEventName", apexEventXMLStringIn)) {
+ for (final ApexEvent apexEvent : xmlEventConverter.toApexEvent("XMLEventName", apexEventXmlStringIn)) {
assertNotNull(apexEvent);
logger.debug(apexEvent.toString());
@@ -83,9 +83,9 @@ public class TestXMLEventHandler {
* @throws ApexException on Apex event handling errors
*/
@Test
- public void testApexEventToXML() throws ApexException {
+ public void testApexEventToXml() throws ApexException {
try {
- final Apex2XMLEventConverter xmlEventConverter = new Apex2XMLEventConverter();
+ final Apex2XmlEventConverter xmlEventConverter = new Apex2XmlEventConverter();
assertNotNull(xmlEventConverter);
final Date event0000StartTime = new Date();
@@ -99,16 +99,16 @@ public class TestXMLEventHandler {
new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex");
apexEvent0000.putAll(event0000DataMap);
- final String apexEvent0000XMLString = xmlEventConverter.fromApexEvent(apexEvent0000);
+ final String apexEvent0000XmlString = xmlEventConverter.fromApexEvent(apexEvent0000);
- logger.debug(apexEvent0000XMLString);
+ logger.debug(apexEvent0000XmlString);
- assertTrue(apexEvent0000XMLString.contains("<name>Event0000</name>"));
- assertTrue(apexEvent0000XMLString.contains("<version>0.0.1</version>"));
- assertTrue(apexEvent0000XMLString.contains("<value>This is a test slogan</value>"));
- assertTrue(apexEvent0000XMLString.contains("<value>12345</value>"));
- assertTrue(apexEvent0000XMLString.contains("<value>" + event0000StartTime.getTime() + "</value>"));
- assertTrue(apexEvent0000XMLString.contains("<value>34.5445667</value>"));
+ assertTrue(apexEvent0000XmlString.contains("<name>Event0000</name>"));
+ assertTrue(apexEvent0000XmlString.contains("<version>0.0.1</version>"));
+ assertTrue(apexEvent0000XmlString.contains("<value>This is a test slogan</value>"));
+ assertTrue(apexEvent0000XmlString.contains("<value>12345</value>"));
+ assertTrue(apexEvent0000XmlString.contains("<value>" + event0000StartTime.getTime() + "</value>"));
+ assertTrue(apexEvent0000XmlString.contains("<value>34.5445667</value>"));
final Date event0004StartTime = new Date(1434363272000L);
final Map<String, Object> event0004DataMap = new HashMap<String, Object>();
@@ -129,16 +129,16 @@ public class TestXMLEventHandler {
new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
apexEvent0004.putAll(event0004DataMap);
- final String apexEvent0004XMLString = xmlEventConverter.fromApexEvent(apexEvent0004);
+ final String apexEvent0004XmlString = xmlEventConverter.fromApexEvent(apexEvent0004);
- logger.debug(apexEvent0004XMLString);
+ logger.debug(apexEvent0004XmlString);
- assertTrue(apexEvent0004XMLString.contains("<name>Event0004</name>"));
- assertTrue(apexEvent0004XMLString.contains("<version>0.0.1</version>"));
- assertTrue(apexEvent0004XMLString.contains("<value>Test slogan for External Event</value>"));
- assertTrue(apexEvent0004XMLString.contains("<value>1434370506078</value>"));
- assertTrue(apexEvent0004XMLString.contains("<value>" + event0004StartTime.getTime() + "</value>"));
- assertTrue(apexEvent0004XMLString.contains("<value>1064.43</value>"));
+ assertTrue(apexEvent0004XmlString.contains("<name>Event0004</name>"));
+ assertTrue(apexEvent0004XmlString.contains("<version>0.0.1</version>"));
+ assertTrue(apexEvent0004XmlString.contains("<value>Test slogan for External Event</value>"));
+ assertTrue(apexEvent0004XmlString.contains("<value>1434370506078</value>"));
+ assertTrue(apexEvent0004XmlString.contains("<value>" + event0004StartTime.getTime() + "</value>"));
+ assertTrue(apexEvent0004XmlString.contains("<value>1064.43</value>"));
} catch (final Exception e) {
e.printStackTrace();
throw new ApexException("Exception reading Apex event xml file", e);
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLTaggedEventConsumer.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlTaggedEventConsumer.java
index e02c86a45..475373a7c 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLTaggedEventConsumer.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlTaggedEventConsumer.java
@@ -34,9 +34,15 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock;
/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
+ * The Class TestXmlTaggedEventConsumer.
*/
-public class TestXMLTaggedEventConsumer {
+public class TestXmlTaggedEventConsumer {
+
+ /**
+ * Test garbage text line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testGarbageTextLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream("hello there".getBytes());
@@ -49,10 +55,15 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test partial event line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testPartialEventLine() throws IOException {
- final InputStream xmlInputStream =
- new ByteArrayInputStream("1469781869268</TestTimestamp></MainTag>".getBytes());
+ final InputStream xmlInputStream = new ByteArrayInputStream(
+ "1469781869268</TestTimestamp></MainTag>".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -62,23 +73,33 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
+ "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(), "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>");
+ assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>", textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage before line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageBeforeLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
+ "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -87,10 +108,16 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage before after line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageBeforeAfterLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes());
+ "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish"
+ .getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -99,20 +126,30 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage after line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageAfterLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes());
+ "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish");
+ assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test garbage text multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testGarbageTextMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream("hello\nthere".getBytes());
@@ -124,10 +161,15 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test partial event multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testPartialEventMultiLine() throws IOException {
- final InputStream xmlInputStream =
- new ByteArrayInputStream("1469781869268\n</TestTimestamp>\n</MainTag>".getBytes());
+ final InputStream xmlInputStream = new ByteArrayInputStream(
+ "1469781869268\n</TestTimestamp>\n</MainTag>".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -136,68 +178,95 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes());
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage before multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageBeforeMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes());
+ "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n"
+ .getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage before after multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageBeforeAfterMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish\n\n"
- .getBytes());
+ String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>"
+ + "\n</MainTag>\nRubbish\n\n";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full event garbage after multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventGarbageAfterMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish".getBytes());
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"
+ .getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test partial events line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testPartialEventsLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "1469781869268</TestTimestamp></MainTag><?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
- .getBytes());
+ String garbageString = "1469781869268</TestTimestamp></MainTag><?xml><MainTag>"
+ + "<TestTimestamp>1469781869268</TestTimestamp>";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -206,11 +275,16 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage before line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageBeforeLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag><?xml><MainTag><TestTimestamp>"
- .getBytes());
+ String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>"
+ + "<?xml><MainTag><TestTimestamp>";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -219,11 +293,16 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage before after line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageBeforeAfterLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse"
- .getBytes());
+ String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
+ + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
@@ -232,105 +311,136 @@ public class TestXMLTaggedEventConsumer {
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage after line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageAfterLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse"
- .getBytes());
+ String garbageString = "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
+ + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse");
+ assertEquals(textBlock.getText(), garbageString);
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test partial events multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testPartialEventsMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>".getBytes());
+ "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>".getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(), "<?xml>\n<MainTag>\n<TestTimestamp>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>", textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n"
- .getBytes());
+ String garbageString = "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ + "</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertFalse(textBlock.isEndOfText());
textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage before multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageBeforeMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n"
- .getBytes());
+ String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ + "</MainTag>\n\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertFalse(textBlock.isEndOfText());
textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage before after multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageBeforeAfterMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse\n"
- .getBytes());
+ String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ + "</MainTag>\nRubbish\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ + "</MainTag>\nRefuse\n";
+ final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ textBlock.getText());
assertFalse(textBlock.isEndOfText());
textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
+ /**
+ * Test full events garbage after multi line.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testFullEventsGarbageAfterMultiLine() throws IOException {
final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish".getBytes());
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"
+ .getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(),
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
+ assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ textBlock.getText());
assertTrue(textBlock.isEndOfText());
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventGenerator.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventGenerator.java
index 765f098de..f85d9119e 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventGenerator.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventGenerator.java
@@ -23,11 +23,17 @@ package org.onap.policy.apex.plugins.event.protocol.xml;
import java.util.Random;
/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
+ * The Class XmlEventGenerator.
*/
-public class XMLEventGenerator {
+public class XmlEventGenerator {
private static int nextEventNo = 0;
+ /**
+ * Xml events.
+ *
+ * @param eventCount the event count
+ * @return the string
+ */
public static String xmlEvents(final int eventCount) {
final StringBuilder builder = new StringBuilder();
@@ -41,6 +47,11 @@ public class XMLEventGenerator {
return builder.toString();
}
+ /**
+ * Xml event.
+ *
+ * @return the string
+ */
public static String xmlEvent() {
final Random rand = new Random();
@@ -65,7 +76,7 @@ public class XMLEventGenerator {
builder.append(" </data>\n");
builder.append(" <data>\n");
builder.append(" <key>TestMatchCase</key>\n");
- builder.append(" <value>" + nextMatchCase + "</value>\n");
+ builder.append(" <value>" + nextMatchCase + "</value>\n");
builder.append(" </data>\n");
builder.append(" <data>\n");
builder.append(" <key>TestTimestamp</key>\n");
@@ -80,6 +91,11 @@ public class XMLEventGenerator {
return builder.toString();
}
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
public static void main(final String[] args) {
if (args.length != 1) {
System.err.println("usage EventGenerator #events");
@@ -98,6 +114,11 @@ public class XMLEventGenerator {
System.out.println(xmlEvents(eventCount));
}
+ /**
+ * Gets the next event no.
+ *
+ * @return the next event no
+ */
public static int getNextEventNo() {
return nextEventNo;
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
index f81c3a914..4bf10e4ae 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
@@ -38,9 +38,8 @@ import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import org.yaml.snakeyaml.Yaml;
-
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.Yaml;
/**
* The Class Apex2YamlEventConverter converts {@link ApexEvent} instances to and from YAML string representations of
@@ -104,11 +103,10 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
// If the incoming YAML did not create a map it is a primitive type or a collection so we
// convert it into a map for processing
Map<?, ?> yamlMap;
- if (yamlObject != null && yamlObject instanceof Map) {
+ if (yamlObject instanceof Map) {
// We already have a map so just cast the object
yamlMap = (Map<?, ?>) yamlObject;
- }
- else {
+ } else {
// Create a single entry map, new map creation and assignment is to avoid a
// type checking warning
LinkedHashMap<String, Object> newYamlMap = new LinkedHashMap<>();
@@ -173,7 +171,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
continue;
}
- yamlMap.put(fieldName, apexEvent.get(fieldName));
+ yamlMap.put(fieldName, apexEvent.get(fieldName));
}
// Use Snake YAML to convert the APEX event to YAML
@@ -187,11 +185,9 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
* @param eventName the name of the event
* @param yamlMap the YAML map that holds the event
* @return the apex event that we have converted the JSON object into
- * @throws ApexEventException
- * thrown on unmarshaling exceptions
+ * @throws ApexEventException thrown on unmarshaling exceptions
*/
- private ApexEvent yamlMap2ApexEvent(final String eventName, final Map<?, ?> yamlMap)
- throws ApexEventException {
+ private ApexEvent yamlMap2ApexEvent(final String eventName, final Map<?, ?> yamlMap) throws ApexEventException {
// Process the mandatory Apex header
final ApexEvent apexEvent = processApexEventHeader(eventName, yamlMap);
@@ -236,16 +232,10 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
* @throws ApexEventRuntimeException the apex event runtime exception
* @throws ApexEventException on invalid events with missing header fields
*/
- private ApexEvent processApexEventHeader(final String eventName, final Map<?, ?> yamlMap)
+ private ApexEvent processApexEventHeader(final String eventName, final Map<?, ?> yamlMap)
throws ApexEventException {
- // Get the event header fields
- // @formatter:off
- String name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(), ApexEvent.NAME_REGEXP, false);
- String version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(), ApexEvent.VERSION_REGEXP, false);
- String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false);
- String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(), ApexEvent.SOURCE_REGEXP, false);
- String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(), ApexEvent.TARGET_REGEXP, false);
- // @formatter:on
+ String name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(),
+ ApexEvent.NAME_REGEXP, false);
// Check that an event name has been specified
if (name == null && eventName == null) {
@@ -256,14 +246,16 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
// Check if an event name was specified on the event parameters
if (eventName != null) {
if (name != null && !eventName.equals(name)) {
- LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\", using configured event name",
- name, eventName);
+ LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\", "
+ + "using configured event name", name, eventName);
}
name = eventName;
}
// Now, find the event definition in the model service. If version is null, the newest event
// definition in the model service is used
+ String version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(),
+ ApexEvent.VERSION_REGEXP, false);
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(name, version);
if (eventDefinition == null) {
throw new ApexEventRuntimeException("an event definition for an event named \"" + name
@@ -276,6 +268,8 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
}
// Check the name space is OK if it is defined, if not, use the name space from the model
+ String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(),
+ ApexEvent.NAMESPACE_REGEXP, false);
if (namespace != null) {
if (!namespace.equals(eventDefinition.getNameSpace())) {
throw new ApexEventRuntimeException("namespace \"" + namespace + "\" on event \"" + name
@@ -287,11 +281,15 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
}
// For source, use the defined source only if the source is not found on the incoming event
+ String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(),
+ ApexEvent.SOURCE_REGEXP, false);
if (source == null) {
source = eventDefinition.getSource();
}
// For target, use the defined source only if the source is not found on the incoming event
+ String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(),
+ ApexEvent.TARGET_REGEXP, false);
if (target == null) {
target = eventDefinition.getTarget();
}
@@ -302,22 +300,16 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
/**
* This method gets an event string field from a JSON object.
*
- * @param yamlMap
- * the YAML containing the YAML representation of the incoming event
- * @param fieldName
- * the field name to find in the event
- * @param fieldAlias
- * the alias for the field to find in the event, overrides the field name if it is not null
- * @param fieldRE
- * the regular expression to check the field against for validity
- * @param mandatory
- * true if the field is mandatory
+ * @param yamlMap the YAML containing the YAML representation of the incoming event
+ * @param fieldName the field name to find in the event
+ * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null
+ * @param fieldRegexp the regular expression to check the field against for validity
+ * @param mandatory true if the field is mandatory
* @return the value of the field in the JSON object or null if the field is optional
- * @throws ApexEventRuntimeException
- * the apex event runtime exception
+ * @throws ApexEventRuntimeException the apex event runtime exception
*/
private String getYamlStringField(final Map<?, ?> yamlMap, final String fieldName, final String fieldAlias,
- final String fieldRE, final boolean mandatory) {
+ final String fieldRegexp, final boolean mandatory) {
// Get the YAML field for the string field
final Object yamlField = getYamlField(yamlMap, fieldName, fieldAlias, mandatory);
@@ -335,12 +327,12 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
final String fieldValueString = (String) yamlField;
// Is regular expression checking required
- if (fieldRE == null) {
+ if (fieldRegexp == null) {
return fieldValueString;
}
// Check the event field against its regular expression
- if (!fieldValueString.matches(fieldRE)) {
+ if (!fieldValueString.matches(fieldRegexp)) {
throw new ApexEventRuntimeException(
"field \"" + fieldName + "\" with value \"" + fieldValueString + "\" is invalid");
}
@@ -351,17 +343,12 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
/**
* This method gets an event field from a YAML object.
*
- * @param yamlMap
- * the YAML containing the YAML representation of the incoming event
- * @param fieldName
- * the field name to find in the event
- * @param fieldAlias
- * the alias for the field to find in the event, overrides the field name if it is not null
- * @param mandatory
- * true if the field is mandatory
+ * @param yamlMap the YAML containing the YAML representation of the incoming event
+ * @param fieldName the field name to find in the event
+ * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null
+ * @param mandatory true if the field is mandatory
* @return the value of the field in the YAML object or null if the field is optional
- * @throws ApexEventRuntimeException
- * the apex event runtime exception
+ * @throws ApexEventRuntimeException the apex event runtime exception
*/
private Object getYamlField(final Map<?, ?> yamlMap, final String fieldName, final String fieldAlias,
final boolean mandatory) {
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
index 861e9cd8f..09a7f54aa 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
@@ -25,7 +25,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTo
/**
* Event protocol parameters for YAML as an event protocol.
*
- * The parameters for this plugin are:
+ * <p>The parameters for this plugin are:
* <ol>
* <li>nameAlias: The field in a YAML event to use as an alias for the event name. This parameter is
* optional.
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
index c5f6cb781..1d2a1d9f7 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
@@ -49,7 +49,16 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock;
import org.onap.policy.common.parameters.ParameterService;
+/**
+ * The Class TestYamlEventProtocol.
+ */
public class TestYamlEventProtocol {
+
+ /**
+ * Register test events and schemas.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@BeforeClass
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
@@ -62,20 +71,20 @@ public class TestYamlEventProtocol {
"java.lang.Integer");
schemas.getSchemasMap().put(simpleIntSchema.getKey(), simpleIntSchema);
- AxContextSchema simpleDoubleSchema = new AxContextSchema(new AxArtifactKey("SimpleDoubleSchema", "0.0.1"), "JAVA",
- "java.lang.Double");
+ AxContextSchema simpleDoubleSchema = new AxContextSchema(new AxArtifactKey("SimpleDoubleSchema", "0.0.1"),
+ "JAVA", "java.lang.Double");
schemas.getSchemasMap().put(simpleDoubleSchema.getKey(), simpleDoubleSchema);
- AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA",
- "java.lang.String");
+ AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"),
+ "JAVA", "java.lang.String");
schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema);
AxContextSchema arrayListSchema = new AxContextSchema(new AxArtifactKey("ArrayListSchema", "0.0.1"), "JAVA",
"java.util.ArrayList");
schemas.getSchemasMap().put(arrayListSchema.getKey(), arrayListSchema);
- AxContextSchema linkedHashMapSchema = new AxContextSchema(new AxArtifactKey("LinkedHashMapSchema", "0.0.1"), "JAVA",
- "java.util.LinkedHashMap");
+ AxContextSchema linkedHashMapSchema = new AxContextSchema(new AxArtifactKey("LinkedHashMapSchema", "0.0.1"),
+ "JAVA", "java.util.LinkedHashMap");
schemas.getSchemasMap().put(linkedHashMapSchema.getKey(), linkedHashMapSchema);
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -105,11 +114,9 @@ public class TestYamlEventProtocol {
AxEvent testEvent3 = new AxEvent(new AxArtifactKey("TestEvent3", "0.0.1"));
testEvent3.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml");
- AxField te3Field0 = new AxField(new AxReferenceKey(testEvent3.getKey(), "american"),
- arrayListSchema.getKey());
+ AxField te3Field0 = new AxField(new AxReferenceKey(testEvent3.getKey(), "american"), arrayListSchema.getKey());
testEvent3.getParameterMap().put("american", te3Field0);
- AxField te3Field1 = new AxField(new AxReferenceKey(testEvent3.getKey(), "national"),
- arrayListSchema.getKey());
+ AxField te3Field1 = new AxField(new AxReferenceKey(testEvent3.getKey(), "national"), arrayListSchema.getKey());
testEvent3.getParameterMap().put("national", te3Field1);
events.getEventMap().put(testEvent3.getKey(), testEvent3);
@@ -139,24 +146,19 @@ public class TestYamlEventProtocol {
AxEvent testEvent7 = new AxEvent(new AxArtifactKey("TestEvent7", "0.0.1"));
testEvent7.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml");
- AxField te7Field0 = new AxField(new AxReferenceKey(testEvent7.getKey(), "time"),
- simpleIntSchema.getKey());
+ AxField te7Field0 = new AxField(new AxReferenceKey(testEvent7.getKey(), "time"), simpleIntSchema.getKey());
testEvent7.getParameterMap().put("time", te7Field0);
- AxField te7Field1 = new AxField(new AxReferenceKey(testEvent7.getKey(), "player"),
- simpleStringSchema.getKey());
+ AxField te7Field1 = new AxField(new AxReferenceKey(testEvent7.getKey(), "player"), simpleStringSchema.getKey());
testEvent7.getParameterMap().put("player", te7Field1);
- AxField te7Field2 = new AxField(new AxReferenceKey(testEvent7.getKey(), "action"),
- simpleStringSchema.getKey());
+ AxField te7Field2 = new AxField(new AxReferenceKey(testEvent7.getKey(), "action"), simpleStringSchema.getKey());
testEvent7.getParameterMap().put("action", te7Field2);
events.getEventMap().put(testEvent7.getKey(), testEvent7);
AxEvent testEvent8 = new AxEvent(new AxArtifactKey("TestEvent8", "0.0.1"));
testEvent8.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml");
- AxField te8Field0 = new AxField(new AxReferenceKey(testEvent8.getKey(), "hr"),
- arrayListSchema.getKey());
+ AxField te8Field0 = new AxField(new AxReferenceKey(testEvent8.getKey(), "hr"), arrayListSchema.getKey());
testEvent8.getParameterMap().put("hr", te8Field0);
- AxField te8Field1 = new AxField(new AxReferenceKey(testEvent8.getKey(), "rbi"),
- arrayListSchema.getKey());
+ AxField te8Field1 = new AxField(new AxReferenceKey(testEvent8.getKey(), "rbi"), arrayListSchema.getKey());
testEvent8.getParameterMap().put("rbi", te8Field1);
events.getEventMap().put(testEvent8.getKey(), testEvent8);
@@ -196,12 +198,21 @@ public class TestYamlEventProtocol {
ModelService.registerModel(AxEvents.class, events);
}
+ /**
+ * Unregister test events and schemas.
+ */
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
ParameterService.clear();
}
+ /**
+ * Test yaml processing.
+ *
+ * @throws ApexEventException the apex event exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Test
public void testYamlProcessing() throws ApexEventException, IOException {
try {
@@ -227,8 +238,18 @@ public class TestYamlEventProtocol {
testYamlDecodeEncode("TestEvent11", 1, 4, "TOSCA0");
}
- private void testYamlDecodeEncode(final String eventName, final int eventCount, final int parCount, final String fileName)
- throws ApexEventException, IOException {
+ /**
+ * Test yaml decode encode.
+ *
+ * @param eventName the event name
+ * @param eventCount the event count
+ * @param parCount the par count
+ * @param fileName the file name
+ * @throws ApexEventException the apex event exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ private void testYamlDecodeEncode(final String eventName, final int eventCount, final int parCount,
+ final String fileName) throws ApexEventException, IOException {
YamlEventProtocolParameters parameters = new YamlEventProtocolParameters();
parameters.setDelimiterAtStart(false);
@@ -239,16 +260,17 @@ public class TestYamlEventProtocol {
FileInputStream fileInputStream = new FileInputStream(new File(filePath));
HeaderDelimitedTextBlockReader reader = new HeaderDelimitedTextBlockReader(parameters);
reader.init(fileInputStream);
-
+
List<ApexEvent> eventList = new ArrayList<>();
-
+
TextBlock textBlock;
do {
- textBlock = reader.readTextBlock();
-
- eventList.addAll(converter.toApexEvent(eventName, textBlock.getText()));
- } while (!textBlock.isEndOfText());
-
+ textBlock = reader.readTextBlock();
+
+ eventList.addAll(converter.toApexEvent(eventName, textBlock.getText()));
+ }
+ while (!textBlock.isEndOfText());
+
fileInputStream.close();
assertEquals(eventCount, eventList.size());
@@ -257,7 +279,8 @@ public class TestYamlEventProtocol {
assertEquals(parCount, eventList.get(0).size());
String eventYaml = (String) converter.fromApexEvent(eventList.get(eventNo));
- String expectedYaml = TextFileUtils.getTextFileAsString("src/test/resources/yaml_out/" + fileName + '_' + eventNo + ".yaml");
+ String expectedYaml = TextFileUtils
+ .getTextFileAsString("src/test/resources/yaml_out/" + fileName + '_' + eventNo + ".yaml");
assertEquals(expectedYaml.replaceAll("\\s*", ""), eventYaml.replaceAll("\\s*", ""));
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
index 57b4b72d6..d033de56d 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
@@ -17,6 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.apex.plugins.event.protocol.yaml;
import static org.junit.Assert.assertEquals;
@@ -44,9 +45,17 @@ import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
import org.onap.policy.common.parameters.ParameterService;
+/**
+ * The Class TestYamlPluginStability.
+ */
public class TestYamlPluginStability {
static AxEvent testEvent;
+ /**
+ * Register test events and schemas.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@BeforeClass
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
@@ -69,8 +78,6 @@ public class TestYamlPluginStability {
ModelService.registerModel(AxContextSchemas.class, schemas);
- AxEvents events = new AxEvents();
-
testEvent = new AxEvent(new AxArtifactKey("TestEvent", "0.0.1"));
testEvent.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml");
AxField teField0 = new AxField(new AxReferenceKey(testEvent.getKey(), "intValue"), simpleIntSchema.getKey());
@@ -81,17 +88,27 @@ public class TestYamlPluginStability {
AxField teField2 = new AxField(new AxReferenceKey(testEvent.getKey(), "stringValue"),
simpleStringSchema.getKey(), true);
testEvent.getParameterMap().put("stringValue", teField2);
+
+ AxEvents events = new AxEvents();
events.getEventMap().put(testEvent.getKey(), testEvent);
ModelService.registerModel(AxEvents.class, events);
}
+ /**
+ * Unregister test events and schemas.
+ */
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
ParameterService.clear();
}
+ /**
+ * Test stability.
+ *
+ * @throws ApexEventException the apex event exception
+ */
@Test
public void testStability() throws ApexEventException {
Apex2YamlEventConverter converter = new Apex2YamlEventConverter();
@@ -220,7 +237,8 @@ public class TestYamlPluginStability {
e.getMessage().substring(0, 77));
}
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: org.onap.policy.apex.plugins.event.protocol.yaml";
+ yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n"
+ + "stringValue: org.onap.policy.apex.plugins.event.protocol.yaml";
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("org.onap.policy.apex.plugins.event.protocol.yaml", eventList.get(0).getNameSpace());
@@ -249,7 +267,7 @@ public class TestYamlPluginStability {
}
pars.setTargetAlias(null);
- yamlInputString = "doubleValue: 123.45\n" + "intValue: ~\n"+ "stringValue: MyString";
+ yamlInputString = "doubleValue: 123.45\n" + "intValue: ~\n" + "stringValue: MyString";
try {
converter.toApexEvent("TestEvent", yamlInputString);
fail("this test should throw an exception");