diff options
24 files changed, 86 insertions, 88 deletions
diff --git a/client/client-deployment/pom.xml b/client/client-deployment/pom.xml index aef5450ed..118d0870f 100644 --- a/client/client-deployment/pom.xml +++ b/client/client-deployment/pom.xml @@ -68,7 +68,6 @@ <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> - <version>3.13.2</version> <scope>test</scope> </dependency> diff --git a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestResource.java b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestResource.java index 55cabe900..4f6e71b2f 100644 --- a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestResource.java +++ b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestResource.java @@ -95,7 +95,6 @@ public class ApexDeploymentRestResource { * @param hostName the host name of the engine service to connect to. * @param port the port number of the engine service to connect to. * @param uploadedInputStream input stream - * @param fileDetail details on the file * @param ignoreConflicts conflict policy * @param forceUpdate update policy * @return a response object in plain text confirming the upload was successful diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentExceptionTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentExceptionTest.java index fc941acf0..d89f1faa6 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentExceptionTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentExceptionTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.client.deployment.rest; import static org.junit.Assert.assertEquals; + import org.junit.Test; /** diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java index 2ca12ab9a..12fe8e528 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.client.deployment.rest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.catchThrowable; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestParameterTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestParameterTest.java index 4fddffaef..16a7b2897 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestParameterTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestParameterTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.client.deployment.rest; import static org.junit.Assert.assertEquals; + import org.junit.Test; /** diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/ParameterCheckTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/ParameterCheckTest.java index a0c4c9c3e..9218347df 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/ParameterCheckTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/ParameterCheckTest.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.client.deployment.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; + import java.util.LinkedHashMap; import java.util.Map; import org.junit.Test; diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/RestResourceTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/RestResourceTest.java index e8625af5e..019ccc8cb 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/RestResourceTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/RestResourceTest.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.client.deployment.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.InputStream; import javax.ws.rs.core.Response; diff --git a/client/client-full/pom.xml b/client/client-full/pom.xml index c4591af85..56d00dc20 100644 --- a/client/client-full/pom.xml +++ b/client/client-full/pom.xml @@ -80,7 +80,6 @@ <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> - <version>3.13.2</version> <scope>test</scope> </dependency> diff --git a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ParameterCheckTest.java b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ParameterCheckTest.java index 0be0ac91c..7203fdcc3 100644 --- a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ParameterCheckTest.java +++ b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ParameterCheckTest.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.client.full.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; + import java.util.LinkedHashMap; import java.util.Map; import org.junit.Test; diff --git a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesExceptionTest.java b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesExceptionTest.java index 7ae8e7143..7504a7271 100644 --- a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesExceptionTest.java +++ b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesExceptionTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.client.full.rest; import static org.junit.Assert.assertEquals; + import org.junit.Test; /** diff --git a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java index f6b3373ce..1c5c440b4 100644 --- a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java +++ b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.client.full.rest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.catchThrowable; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; diff --git a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestParameterTest.java b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestParameterTest.java index 777a9c170..4c06d246f 100644 --- a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestParameterTest.java +++ b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestParameterTest.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.client.full.rest; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; + import org.junit.Test; /** 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()); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java index bafce8d06..dd46f7f74 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -22,7 +22,7 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.kafka; import com.salesforce.kafka.test.junit4.SharedKafkaTestResource; -import java.util.concurrent.TimeUnit; +import java.time.Duration; import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerRecord; @@ -85,7 +85,7 @@ public class KafkaEventProducer implements Runnable { } } - producer.close(1000, TimeUnit.MILLISECONDS); + producer.close(Duration.ofMillis(1000)); } /** diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java index 8db6919f0..dbe8d0294 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -82,7 +82,7 @@ public class KafkaEventSubscriber implements Runnable { while (subscriberThread.isAlive() && !subscriberThread.isInterrupted()) { try { - final ConsumerRecords<String, String> records = consumer.poll(POLL_DURATION.toMillis()); + final ConsumerRecords<String, String> records = consumer.poll(POLL_DURATION); for (final ConsumerRecord<String, String> record : records) { eventsReceivedCount++; System.out.println("****** Received event No. " + eventsReceivedCount + " ******"); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java index 0ba41db81..bc5b602e3 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient; import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.net.URI; @@ -118,7 +119,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadUrl.json"}; + final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadUrl.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -142,7 +143,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json"}; + final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1000); @@ -167,7 +168,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json"}; + final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -190,7 +191,8 @@ public class TestExecutionPropertyRest { public void testReplaceUrlTag() throws Exception { final Client client = ClientBuilder.newClient(); - final String[] args = {"src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json"}; + final String[] args = + { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1000); apexMain.shutdown(); @@ -215,7 +217,7 @@ public class TestExecutionPropertyRest { public void testReplaceUrlMultiTag() throws Exception { final Client client = ClientBuilder.newClient(); final String[] args = - {"src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json"}; + { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1500); apexMain.shutdown(); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java index f19410fb5..dc8d962dd 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import com.google.gson.Gson; import java.util.Map; import java.util.Random; diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/events/EventsOut.json b/testsuites/integration/integration-uservice-test/src/test/resources/events/EventsOut.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/resources/events/EventsOut.json |