aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 15:25:32 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 15:26:47 +0100
commit4cfa2e2d98f6877d54da304ef17f096284430908 (patch)
treec9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /plugins/plugins-event/plugins-event-carrier
parent0e23f7634e1e1fb31454c516974613335fcea1a4 (diff)
Sonar/Checkstyle in service/plugins
Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier')
-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
29 files changed, 450 insertions, 270 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