aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-08-21 09:39:44 +0000
committerliamfallon <liam.fallon@est.tech>2019-08-21 09:39:44 +0000
commit5bf11a7500944b8b306c5d4f478e4bc45ef1fb51 (patch)
tree18b13026a9e84f8a34afec69d5767bd31f702087 /plugins/plugins-event
parent02bef1fc9ac105939f3f3859265ddd0d6f12068b (diff)
Fix checkstyle warnings in apex-pdp
Unit tests introduced some checkstyle warnings, this review resolves those warnings. Issue-ID: POLICY-1942 Change-Id: I16438621c1db0adfbe70bc8b237d05bd7cc72697 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event')
-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.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java27
-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.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestTest.java4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java46
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducerTest.java21
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java29
7 files changed, 60 insertions, 71 deletions
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 787ac4ef5..17738f194 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
@@ -149,7 +149,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable {
while (consumerThread.isAlive() && !stopOrderedFlag) {
try {
final ConsumerRecords<String, String> records =
- kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration().toMillis());
+ kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration());
for (final ConsumerRecord<String, String> record : records) {
traceIfTraceEnabled(record);
eventReceiver.receiveEvent(new Properties(), record.value());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
index 9db565ba8..ef0384f9c 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
@@ -26,14 +26,14 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Set;
+
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.common.parameters.ParameterException;
-import java.util.Set;
-
/**
* Test REST Requestor carrier technology parameters.
*/
@@ -65,9 +65,9 @@ public class RestClientCarrierTechnologyParametersTest {
fail("test should throw an exception here");
} catch (ParameterException pe) {
assertTrue(pe.getMessage()
- .contains("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]"));
+ .contains("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]"));
assertTrue(pe.getMessage().trim()
- .endsWith("HTTP header array entries must have one key and one value: [aaa]"));
+ .endsWith("HTTP header array entries must have one key and one value: [aaa]"));
}
}
@@ -96,11 +96,11 @@ public class RestClientCarrierTechnologyParametersTest {
new ApexParameterHandler().getParameters(arguments);
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
- RestClientCarrierTechnologyParameters rrctp0 = (RestClientCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
+ parameters.getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
fail("test should throw an exception here");
} catch (ParameterException pe) {
- assertTrue(pe.getMessage().contains("Invalid HTTP code filter, the filter must be specified as a three digit regular expression: "));
+ assertTrue(pe.getMessage().contains(
+ "Invalid HTTP code filter, the filter must be specified as a three digit regular expression: "));
}
}
@@ -113,11 +113,11 @@ public class RestClientCarrierTechnologyParametersTest {
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
RestClientCarrierTechnologyParameters rrctp0 = (RestClientCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
+ .getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
assertEquals(0, rrctp0.getHttpHeaders().length);
RestClientCarrierTechnologyParameters rrctp1 = (RestClientCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestClientConsumer1").getCarrierTechnologyParameters();
+ .getEventInputParameters().get("RestClientConsumer1").getCarrierTechnologyParameters();
assertEquals(3, rrctp1.getHttpHeaders().length);
assertEquals("bbb", rrctp1.getHttpHeadersAsMultivaluedMap().get("aaa").get(0));
assertEquals("ddd", rrctp1.getHttpHeadersAsMultivaluedMap().get("ccc").get(0));
@@ -136,7 +136,7 @@ public class RestClientCarrierTechnologyParametersTest {
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
RestClientCarrierTechnologyParameters rrctp1 = (RestClientCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestClientConsumer1").getCarrierTechnologyParameters();
+ .getEventInputParameters().get("RestClientConsumer1").getCarrierTechnologyParameters();
assertEquals("[1-5][0][0-5]", rrctp1.getHttpCodeFilter());
}
@@ -176,14 +176,13 @@ public class RestClientCarrierTechnologyParametersTest {
assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.DELETE, rrctp.getHttpMethod());
assertEquals("RestClientCarrierTechnologyParameters "
- + "[url=http://some.where, httpMethod=DELETE, httpHeaders=[[aaa, bbb], [ccc, ddd]], "
- + "httpCodeFilter=[1-5][0][0-5]]", rrctp.toString());
+ + "[url=http://some.where, httpMethod=DELETE, httpHeaders=[[aaa, bbb], [ccc, ddd]], "
+ + "httpCodeFilter=[1-5][0][0-5]]", rrctp.toString());
}
@Test
public void testUrlValidation() {
- RestClientCarrierTechnologyParameters rrctp =
- new RestClientCarrierTechnologyParameters();
+ RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters();
rrctp.setUrl("http://some.where.no.tag.in.url");
assertEquals("http://some.where.no.tag.in.url", rrctp.getUrl());
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 f60abc24c..e382c0269 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
@@ -372,7 +372,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
// Check that the request worked
if (!isPass.matches()) {
- final String errorMessage ="reception of event from URL \"" + restConsumerProperties.getUrl()
+ final String errorMessage = "reception of event from URL \"" + restConsumerProperties.getUrl()
+ "\" failed with status code " + response.getStatus() + " and message \""
+ response.readEntity(String.class) + "\"";
throw new ApexEventRuntimeException(errorMessage);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestTest.java
index dc55c06f7..59449b86a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestTest.java
@@ -23,10 +23,10 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor;
import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
import java.util.Properties;
+import org.junit.Test;
+
/**
* Test the ApexRestRequest class.
*/
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java
index 07818d068..46390f9d6 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java
@@ -39,39 +39,41 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
*
*/
public class ApexRestRequestorConsumerTest {
+ // String constants
+ private static final String CONSUMER_NAME = "ConsumerName";
+ private static final String EVENT_NAME = "EventName";
+ private static final String EVENT_BODY = "Event body";
@Test
public void testApexRestRequestorConsumerSetup() throws ApexEventException {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
- String consumerName = "ConsumerName";
-
EventHandlerParameters consumerParameters = new EventHandlerParameters();
ApexEventReceiver incomingEventReceiver = null;
try {
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("specified consumer properties are not applicable to REST Requestor consumer (ConsumerName)",
- aee.getMessage());
+ aee.getMessage());
}
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(rrctp);
try {
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("REST Requestor consumer (ConsumerName) must run in peered requestor mode "
- + "with a REST Requestor producer", aee.getMessage());
+ + "with a REST Requestor producer", aee.getMessage());
}
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
rrctp.setHttpMethod(null);
try {
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("no URL has been specified on REST Requestor consumer (ConsumerName)", aee.getMessage());
@@ -80,7 +82,7 @@ public class ApexRestRequestorConsumerTest {
rrctp.setHttpMethod(RestRequestorCarrierTechnologyParameters.HttpMethod.GET);
rrctp.setUrl("ZZZZ");
try {
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("invalid URL has been specified on REST Requestor consumer (ConsumerName)", aee.getMessage());
@@ -91,17 +93,16 @@ public class ApexRestRequestorConsumerTest {
rrctp.setHttpCodeFilter("[1-5][0][0-5]");
consumerParameters.setPeerTimeout(EventHandlerPeeredMode.REQUESTOR, 0);
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
try {
consumer.processRestRequest(null);
fail("test should throw an exception here");
} catch (Exception ex) {
- assertEquals("could not queue request \"null\" on REST Requestor consumer (ConsumerName)",
- ex.getMessage());
+ assertEquals("could not queue request \"null\" on REST Requestor consumer (ConsumerName)", ex.getMessage());
}
- assertEquals("ConsumerName", consumer.getName());
+ assertEquals(CONSUMER_NAME, consumer.getName());
assertEquals(0, consumer.getEventsReceived());
assertEquals(null, consumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@@ -111,10 +112,7 @@ public class ApexRestRequestorConsumerTest {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
- String consumerName = "ConsumerName";
-
EventHandlerParameters consumerParameters = new EventHandlerParameters();
- ApexEventReceiver incomingEventReceiver = null;
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(rrctp);
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
@@ -124,9 +122,9 @@ public class ApexRestRequestorConsumerTest {
consumerParameters.setPeerTimeout(EventHandlerPeeredMode.REQUESTOR, 0);
// Test should time out requests
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, null);
consumer.start();
- ApexRestRequest request = new ApexRestRequest(123, null, "EventName", "Event body");
+ ApexRestRequest request = new ApexRestRequest(123, null, EVENT_NAME, EVENT_BODY);
consumer.processRestRequest(request);
ThreadUtilities.sleep(200);
consumer.stop();
@@ -138,10 +136,7 @@ public class ApexRestRequestorConsumerTest {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
- String consumerName = "ConsumerName";
-
EventHandlerParameters consumerParameters = new EventHandlerParameters();
- ApexEventReceiver incomingEventReceiver = null;
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(rrctp);
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
@@ -153,9 +148,9 @@ public class ApexRestRequestorConsumerTest {
properties.put("site", "onap");
properties.put("net", "org");
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, null);
consumer.start();
- ApexRestRequest request = new ApexRestRequest(123, properties,"EventName", "Event body");
+ ApexRestRequest request = new ApexRestRequest(123, properties, EVENT_NAME, EVENT_BODY);
consumer.processRestRequest(request);
ThreadUtilities.sleep(2000);
consumer.stop();
@@ -167,10 +162,7 @@ public class ApexRestRequestorConsumerTest {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
- String consumerName = "ConsumerName";
-
EventHandlerParameters consumerParameters = new EventHandlerParameters();
- ApexEventReceiver incomingEventReceiver = null;
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(rrctp);
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
@@ -181,9 +173,9 @@ public class ApexRestRequestorConsumerTest {
Properties properties = new Properties();
properties.put("site", "onap");
- consumer.init(consumerName, consumerParameters, incomingEventReceiver);
+ consumer.init(CONSUMER_NAME, consumerParameters, null);
consumer.start();
- ApexRestRequest request = new ApexRestRequest(123, properties,"EventName", "Event body");
+ ApexRestRequest request = new ApexRestRequest(123, properties, EVENT_NAME, EVENT_BODY);
consumer.processRestRequest(request);
ThreadUtilities.sleep(2000);
consumer.stop();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducerTest.java
index af0074794..d168f2444 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducerTest.java
@@ -37,17 +37,18 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
* Test the ApexRestRequestorProducer class.
*/
public class ApexRestRequestorProducerTest {
+ // String constants
+ private static final String PRODUCER_NAME = "ProducerName";
@Test
public void testApexRestRequestorProducerMethods() throws ApexEventException {
ApexRestRequestorProducer producer = new ApexRestRequestorProducer();
assertNotNull(producer);
- String producerName = "ProducerName";
EventHandlerParameters producerParameters = new EventHandlerParameters();
try {
- producer.init(producerName, producerParameters);
+ producer.init(PRODUCER_NAME, producerParameters);
} catch (ApexEventException aee) {
assertEquals("specified producer properties are not applicable to REST requestor producer (ProducerName)",
aee.getMessage());
@@ -56,7 +57,7 @@ public class ApexRestRequestorProducerTest {
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
producerParameters.setCarrierTechnologyParameters(rrctp);
try {
- producer.init(producerName, producerParameters);
+ producer.init(PRODUCER_NAME, producerParameters);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("REST Requestor producer (ProducerName) must run in peered requestor mode "
@@ -66,7 +67,7 @@ public class ApexRestRequestorProducerTest {
producerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
rrctp.setUrl("ZZZZ");
try {
- producer.init(producerName, producerParameters);
+ producer.init(PRODUCER_NAME, producerParameters);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("URL may not be specified on REST Requestor producer (ProducerName)", aee.getMessage());
@@ -75,7 +76,7 @@ public class ApexRestRequestorProducerTest {
rrctp.setUrl(null);
rrctp.setHttpMethod(RestRequestorCarrierTechnologyParameters.HttpMethod.GET);
try {
- producer.init(producerName, producerParameters);
+ producer.init(PRODUCER_NAME, producerParameters);
fail("test should throw an exception here");
} catch (ApexEventException aee) {
assertEquals("HTTP method may not be specified on REST Requestor producer (ProducerName)",
@@ -83,19 +84,16 @@ public class ApexRestRequestorProducerTest {
}
rrctp.setHttpMethod(null);
- producer.init(producerName, producerParameters);
+ producer.init(PRODUCER_NAME, producerParameters);
producer.stop();
- assertEquals("ProducerName", producer.getName());
+ assertEquals(PRODUCER_NAME, producer.getName());
assertEquals(0, producer.getEventsSent());
assertEquals(null, producer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
public void testApexRestRequestorProducerRequest() throws ApexEventException {
- ApexRestRequestorProducer producer = new ApexRestRequestorProducer();
-
- String producerName = "ProducerName";
EventHandlerParameters producerParameters = new EventHandlerParameters();
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
@@ -104,7 +102,8 @@ public class ApexRestRequestorProducerTest {
rrctp.setUrl(null);
rrctp.setHttpMethod(null);
- producer.init(producerName, producerParameters);
+ ApexRestRequestorProducer producer = new ApexRestRequestorProducer();
+ producer.init(PRODUCER_NAME, producerParameters);
producer.stop();
String eventName = "EventName";
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
index 3044907fb..96cf8490b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
@@ -26,14 +26,14 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Set;
+
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.common.parameters.ParameterException;
-import java.util.Set;
-
/**
* Test REST Requestor carrier technology parameters.
*/
@@ -65,9 +65,9 @@ public class RestRequestorCarrierTechnologyParametersTest {
fail("test should throw an exception here");
} catch (ParameterException pe) {
assertTrue(pe.getMessage()
- .contains("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]"));
+ .contains("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]"));
assertTrue(pe.getMessage().trim()
- .endsWith("HTTP header array entries must have one key and one value: [aaa]"));
+ .endsWith("HTTP header array entries must have one key and one value: [aaa]"));
}
}
@@ -95,11 +95,11 @@ public class RestRequestorCarrierTechnologyParametersTest {
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
RestRequestorCarrierTechnologyParameters rrctp0 = (RestRequestorCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestRequestorConsumer0").getCarrierTechnologyParameters();
+ .getEventInputParameters().get("RestRequestorConsumer0").getCarrierTechnologyParameters();
assertEquals(0, rrctp0.getHttpHeaders().length);
RestRequestorCarrierTechnologyParameters rrctp1 = (RestRequestorCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestRequestorConsumer1").getCarrierTechnologyParameters();
+ .getEventInputParameters().get("RestRequestorConsumer1").getCarrierTechnologyParameters();
assertEquals(3, rrctp1.getHttpHeaders().length);
assertEquals("bbb", rrctp1.getHttpHeadersAsMultivaluedMap().get("aaa").get(0));
assertEquals("ddd", rrctp1.getHttpHeadersAsMultivaluedMap().get("ccc").get(0));
@@ -116,11 +116,11 @@ public class RestRequestorCarrierTechnologyParametersTest {
new ApexParameterHandler().getParameters(arguments);
ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
- RestRequestorCarrierTechnologyParameters rrctp0 = (RestRequestorCarrierTechnologyParameters) parameters
- .getEventInputParameters().get("RestRequestorConsumer0").getCarrierTechnologyParameters();
+ parameters.getEventInputParameters().get("RestRequestorConsumer0").getCarrierTechnologyParameters();
fail("test should throw an exception here");
} catch (ParameterException pe) {
- assertTrue(pe.getMessage().contains("Invalid HTTP code filter, the filter must be specified as a three digit regular expression: "));
+ assertTrue(pe.getMessage().contains(
+ "Invalid HTTP code filter, the filter must be specified as a three digit regular expression: "));
}
}
@@ -129,13 +129,13 @@ public class RestRequestorCarrierTechnologyParametersTest {
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
rrctp.setHttpHeaders(null);
- assertEquals(null,rrctp.getHttpHeadersAsMultivaluedMap());
+ assertEquals(null, rrctp.getHttpHeadersAsMultivaluedMap());
rrctp.setUrl("http://some.where");
assertEquals("http://some.where", rrctp.getUrl());
rrctp.setHttpCodeFilter("[1-5][0][0-5]");
- assertEquals("[1-5][0][0-5]",rrctp.getHttpCodeFilter());
+ assertEquals("[1-5][0][0-5]", rrctp.getHttpCodeFilter());
String[][] httpHeaders = new String[2][2];
httpHeaders[0][0] = "aaa";
@@ -163,14 +163,13 @@ public class RestRequestorCarrierTechnologyParametersTest {
assertEquals(RestRequestorCarrierTechnologyParameters.HttpMethod.DELETE, rrctp.getHttpMethod());
assertEquals("RESTRequestorCarrierTechnologyParameters "
- + "[url=http://some.where, httpMethod=DELETE, httpHeaders=[[aaa, bbb], [ccc, ddd]],"
- + " httpCodeFilter=[1-5][0][0-5]]", rrctp.toString());
+ + "[url=http://some.where, httpMethod=DELETE, httpHeaders=[[aaa, bbb], [ccc, ddd]],"
+ + " httpCodeFilter=[1-5][0][0-5]]", rrctp.toString());
}
@Test
public void testUrlValidation() {
- RestRequestorCarrierTechnologyParameters rrctp =
- new RestRequestorCarrierTechnologyParameters();
+ RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
rrctp.setUrl("http://some.where.no.tag.in.url");
assertEquals("http://some.where.no.tag.in.url", rrctp.getUrl());