aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src')
-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.java12
-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.java48
-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.java59
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java63
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java20
6 files changed, 117 insertions, 131 deletions
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 d7b418a78..fe779eb89 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,18 +22,18 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the ApexRestRequest class.
*/
-public class ApexRestRequestTest {
+class ApexRestRequestTest {
@Test
- public void testApexRestRequest() {
+ void testApexRestRequest() {
final String eventName = "EventName";
final String eventString = "The Event String";
@@ -50,6 +50,6 @@ public class ApexRestRequestTest {
assertEquals(1234567, rr.getTimestamp());
assertEquals("ApexRestRequest(executionId=1, eventName=EventName, event=The Event String, timestamp=1234567)",
- rr.toString());
+ rr.toString());
}
}
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 e72fa9030..47f90454c 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
@@ -23,13 +23,13 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
@@ -38,45 +38,40 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
/**
* Test the ApexRestRequestorConsumer class.
- *
*/
-public class ApexRestRequestorConsumerTest {
+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 {
+ void testApexRestRequestorConsumerSetup() throws ApexEventException {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
EventHandlerParameters consumerParameters = new EventHandlerParameters();
ApexEventReceiver incomingEventReceiver = null;
- assertThatThrownBy(() -> {
- consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
- }).hasMessage("specified consumer properties are not applicable to REST Requestor consumer (ConsumerName)");
+ assertThatThrownBy(() -> consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
+ .hasMessage("specified consumer properties are not applicable to REST Requestor consumer (ConsumerName)");
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(rrctp);
- assertThatThrownBy(() -> {
- consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
- }).hasMessage("REST Requestor consumer (ConsumerName) must run in peered requestor mode "
- + "with a REST Requestor producer");
+ assertThatThrownBy(() -> consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
+ .hasMessage("REST Requestor consumer (ConsumerName) must run in peered requestor mode "
+ + "with a REST Requestor producer");
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
rrctp.setHttpMethod(null);
- assertThatThrownBy(() -> {
- consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
- }).hasMessage("no URL has been specified on REST Requestor consumer (ConsumerName)");
+ assertThatThrownBy(() -> consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
+ .hasMessage("no URL has been specified on REST Requestor consumer (ConsumerName)");
rrctp.setHttpMethod(RestRequestorCarrierTechnologyParameters.HttpMethod.GET);
rrctp.setUrl("ZZZZ");
- assertThatThrownBy(() -> {
- consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
- }).hasMessage("invalid URL has been specified on REST Requestor consumer (ConsumerName)");
+ assertThatThrownBy(() -> consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
+ .hasMessage("invalid URL has been specified on REST Requestor consumer (ConsumerName)");
rrctp.setHttpMethod(RestRequestorCarrierTechnologyParameters.HttpMethod.GET);
rrctp.setUrl("http://www.onap.org");
@@ -85,9 +80,8 @@ public class ApexRestRequestorConsumerTest {
consumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
- assertThatThrownBy(() -> {
- consumer.processRestRequest(null);
- }).hasMessage("could not queue request \"null\" on REST Requestor consumer (ConsumerName)");
+ assertThatThrownBy(() -> consumer.processRestRequest(null))
+ .hasMessage("could not queue request \"null\" on REST Requestor consumer (ConsumerName)");
assertEquals(CONSUMER_NAME, consumer.getName());
assertEquals(0, consumer.getEventsReceived());
@@ -95,7 +89,7 @@ public class ApexRestRequestorConsumerTest {
}
@Test
- public void testApexRestRequestorConsumerRequest() throws ApexEventException {
+ void testApexRestRequestorConsumerRequest() throws ApexEventException {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
@@ -119,7 +113,7 @@ public class ApexRestRequestorConsumerTest {
}
@Test
- public void testApexRestRequestorConsumerUrlUpdate() throws ApexEventException {
+ void testApexRestRequestorConsumerUrlUpdate() throws ApexEventException {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
@@ -145,7 +139,7 @@ public class ApexRestRequestorConsumerTest {
}
@Test
- public void testApexRestRequestorConsumerUrlUpdateError() throws ApexEventException {
+ void testApexRestRequestorConsumerUrlUpdateError() throws ApexEventException {
ApexRestRequestorConsumer consumer = new ApexRestRequestorConsumer();
assertNotNull(consumer);
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 450a21f01..0e57a31e9 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,12 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.PeeredReference;
@@ -38,33 +39,30 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
/**
* Test the ApexRestRequestorProducer class.
*/
-public class ApexRestRequestorProducerTest {
+class ApexRestRequestorProducerTest {
// String constants
private static final String PRODUCER_NAME = "ProducerName";
@Test
- public void testApexRestRequestorProducerMethods() throws ApexEventException {
+ void testApexRestRequestorProducerMethods() throws ApexEventException {
ApexRestRequestorProducer producer = new ApexRestRequestorProducer();
assertNotNull(producer);
EventHandlerParameters producerParameters = new EventHandlerParameters();
- assertThatThrownBy(() -> {
- producer.init(PRODUCER_NAME, producerParameters);
- }).hasMessage("specified producer properties are not applicable to REST requestor producer (ProducerName)");
+ assertThatThrownBy(() -> producer.init(PRODUCER_NAME, producerParameters))
+ .hasMessage("specified producer properties are not applicable to REST requestor producer (ProducerName)");
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
producerParameters.setCarrierTechnologyParameters(rrctp);
- assertThatThrownBy(() -> {
- producer.init(PRODUCER_NAME, producerParameters);
- }).hasMessage("REST Requestor producer (ProducerName) must run in peered requestor mode "
- + "with a REST Requestor consumer");
+ assertThatThrownBy(() -> producer.init(PRODUCER_NAME, producerParameters))
+ .hasMessage("REST Requestor producer (ProducerName) must run in peered requestor mode "
+ + "with a REST Requestor consumer");
producerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
rrctp.setUrl("ZZZZ");
- assertThatThrownBy(() -> {
- producer.init(PRODUCER_NAME, producerParameters);
- }).hasMessage("URL may not be specified on REST Requestor producer (ProducerName)");
+ assertThatThrownBy(() -> producer.init(PRODUCER_NAME, producerParameters))
+ .hasMessage("URL may not be specified on REST Requestor producer (ProducerName)");
rrctp.setUrl(null);
rrctp.setHttpMethod(RestRequestorCarrierTechnologyParameters.HttpMethod.GET);
@@ -80,11 +78,11 @@ public class ApexRestRequestorProducerTest {
assertEquals(PRODUCER_NAME, producer.getName());
assertEquals(0, producer.getEventsSent());
- assertEquals(null, producer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
+ assertNull(producer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testApexRestRequestorProducerRequest() throws ApexEventException {
+ void testApexRestRequestorProducerRequest() throws ApexEventException {
EventHandlerParameters producerParameters = new EventHandlerParameters();
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
@@ -100,9 +98,8 @@ public class ApexRestRequestorProducerTest {
String eventName = "EventName";
String event = "This is the event";
- assertThatThrownBy(() -> {
- producer.sendEvent(12345, null, eventName, event);
- }).hasMessage("send of event failed, REST response consumer is not defined\n" + "This is the event");
+ assertThatThrownBy(() -> producer.sendEvent(12345, null, eventName, event))
+ .hasMessage("send of event failed, REST response consumer is not defined\n" + "This is the event");
ApexEventConsumer consumer = new ApexFileEventConsumer();
SynchronousEventCache eventCache =
@@ -111,9 +108,8 @@ public class ApexRestRequestorProducerTest {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR, consumer, producer);
producer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference);
- assertThatThrownBy(() -> {
- producer.sendEvent(12345, null, eventName, event);
- }).hasMessage("send of event failed, REST response consumer "
- + "is not an instance of ApexRestRequestorConsumer\n" + "This is the event");
+ assertThatThrownBy(() -> producer.sendEvent(12345, null, eventName, event))
+ .hasMessage("send of event failed, REST response consumer "
+ + "is not an instance of ApexRestRequestorConsumer\n" + "This is the event");
}
}
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 f17721bdc..d953cf8ce 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -24,12 +24,13 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.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;
@@ -38,24 +39,24 @@ import org.onap.policy.common.parameters.ParameterException;
/**
* Test REST Requestor carrier technology parameters.
*/
-public class RestRequestorCarrierTechnologyParametersTest {
+class RestRequestorCarrierTechnologyParametersTest {
@Test
- public void testRestRequestorCarrierTechnologyParametersBadList() {
+ void testRestRequestorCarrierTechnologyParametersBadList() {
verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderBadList.json",
- "item \"entry 2\" value \"null\" INVALID, is null");
+ "item \"entry 2\" value \"null\" INVALID, is null");
}
@Test
- public void testRestRequestorCarrierTechnologyParametersNotKvPairs() {
+ void testRestRequestorCarrierTechnologyParametersNotKvPairs() {
verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNotKvPairs.json",
- "item \"entry 0\" value \"[aaa, bbb, ccc]\" INVALID, must have one key");
+ "item \"entry 0\" value \"[aaa, bbb, ccc]\" INVALID, must have one key");
}
@Test
- public void testRestRequestorCarrierTechnologyParametersNulls() {
+ void testRestRequestorCarrierTechnologyParametersNulls() {
verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNulls.json",
- "\"key\"");
+ "\"key\"");
}
private void verifyException(String fileName, String expectedMsg) {
@@ -64,11 +65,11 @@ public class RestRequestorCarrierTechnologyParametersTest {
arguments.setRelativeFileRoot(".");
assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).describedAs(fileName)
- .hasMessageContaining(expectedMsg);
+ .hasMessageContaining(expectedMsg);
}
@Test
- public void testRestRequestorCarrierTechnologyParametersOk() throws ParameterException {
+ void testRestRequestorCarrierTechnologyParametersOk() throws ParameterException {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderOK.json");
arguments.setRelativeFileRoot(".");
@@ -88,7 +89,7 @@ public class RestRequestorCarrierTechnologyParametersTest {
}
@Test
- public void testRestClientCarrierTechnologyParameterFilterInvalid() {
+ void testRestClientCarrierTechnologyParameterFilterInvalid() {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPFilterInvalid.json");
arguments.setRelativeFileRoot(".");
@@ -103,11 +104,11 @@ public class RestRequestorCarrierTechnologyParametersTest {
}
@Test
- public void testGettersAndSetters() {
+ void testGettersAndSetters() {
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
rrctp.setHttpHeaders(null);
- assertEquals(null, rrctp.getHttpHeadersAsMultivaluedMap());
+ assertNull(rrctp.getHttpHeadersAsMultivaluedMap());
rrctp.setUrl("http://some.where");
assertEquals("http://some.where", rrctp.getUrl());
@@ -146,7 +147,7 @@ public class RestRequestorCarrierTechnologyParametersTest {
}
@Test
- public void testUrlValidation() {
+ void testUrlValidation() {
RestRequestorCarrierTechnologyParameters rrctp = new RestRequestorCarrierTechnologyParameters();
rrctp.setUrl("http://some.where.no.tag.in.url");
@@ -164,30 +165,28 @@ public class RestRequestorCarrierTechnologyParametersTest {
assertEquals("ccc", rrctp.getHttpHeaders()[1][0]);
assertEquals("ddd", rrctp.getHttpHeaders()[1][1]);
- assertEquals(true, rrctp.validate().isValid());
+ assertTrue(rrctp.validate().isValid());
rrctp.setUrl("http://{place}.{that}/is{that}.{one}");
- assertEquals(true, rrctp.validate().isValid());
+ assertTrue(rrctp.validate().isValid());
Set<String> keymap = rrctp.getKeysFromUrl();
- assertEquals(true, keymap.contains("place"));
- assertEquals(true, keymap.contains("that"));
- assertEquals(true, keymap.contains("one"));
+ assertTrue(keymap.contains("place") && keymap.contains("that") && keymap.contains("one"));
rrctp.setUrl("http://{place.{that}/{is}.{not}/{what}.{exist}");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://{place}.{that}/{is}.{not}/{what}.{exist");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://place.that/is.not/what.{exist");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://place}.{that}/{is}.{not}/{what}.{exist}");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://{place}.{that}/is}.{not}/{what}.{exist}");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://{place}.{that}/{}.{not}/{what}.{exist}");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
rrctp.setUrl("http://{place}.{that}/{ }.{not}/{what}.{exist}");
- assertEquals(false, rrctp.validate().isValid());
+ assertFalse(rrctp.validate().isValid());
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java
index 257e533c4..3fe836485 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java
@@ -24,7 +24,7 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.Gson;
import jakarta.ws.rs.client.Client;
@@ -34,11 +34,11 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -50,12 +50,12 @@ import org.onap.policy.common.utils.network.NetworkUtil;
/**
* The Class TestRestRequestor.
*/
-public class RestRequestorTest {
+class RestRequestorTest {
private static final int PORT = 32801;
private static HttpServletServer server;
- private ByteArrayOutputStream outContent = new ByteArrayOutputStream();
- private ByteArrayOutputStream errContent = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
private final PrintStream stdout = System.out;
private final PrintStream stderr = System.err;
@@ -65,8 +65,8 @@ public class RestRequestorTest {
*
* @throws Exception the exception
*/
- @BeforeClass
- public static void setUp() throws Exception {
+ @BeforeAll
+ static void setUp() throws Exception {
server = HttpServletServerFactoryInstance.getServerFactory().build(null, false, null, PORT, false,
"/TestRESTRequestor", false, false);
@@ -82,10 +82,9 @@ public class RestRequestorTest {
/**
* Tear down.
- *
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
if (server != null) {
server.stop();
}
@@ -94,8 +93,8 @@ public class RestRequestorTest {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
SupportRestRequestorEndpoint.resetCounters();
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
@@ -104,8 +103,8 @@ public class RestRequestorTest {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
System.setOut(stdout);
System.setErr(stderr);
}
@@ -114,10 +113,10 @@ public class RestRequestorTest {
* Test rest requestor get.
*
* @throws MessagingException the messaging exception
- * @throws Exception an exception
+ * @throws Exception an exception
*/
@Test
- public void testRestRequestorGet() throws Exception {
+ void testRestRequestorGet() throws Exception {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGet.json"};
@@ -139,7 +138,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorGetEmpty() throws ApexException {
+ void testRestRequestorGetEmpty() throws ApexException {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetEmpty.json"};
@@ -149,7 +148,7 @@ public class RestRequestorTest {
Response response = null;
// Wait for the required amount of events to be received or for 10 seconds
- double getsSoFar = 0.0;
+ double getsSoFar;
for (int i = 0; i < 40; i++) {
response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats")
.request("application/json").get();
@@ -160,8 +159,8 @@ public class RestRequestorTest {
final String responseString = response.readEntity(String.class);
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap =
+ new Gson().fromJson(responseString, Map.class);
getsSoFar = Double.parseDouble(jsonMap.get("GET").toString());
if (getsSoFar >= 50.0) {
@@ -183,7 +182,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorPut() throws ApexException {
+ void testRestRequestorPut() throws ApexException {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FilePut.json"};
@@ -205,7 +204,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorPost() throws ApexException {
+ void testRestRequestorPost() throws ApexException {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FilePost.json"};
@@ -227,7 +226,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorDelete() throws ApexException {
+ void testRestRequestorDelete() throws ApexException {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileDelete.json"};
@@ -250,7 +249,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorMultiInputs() throws ApexException {
+ void testRestRequestorMultiInputs() throws ApexException {
final Client client = ClientBuilder.newClient();
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json"};
@@ -272,7 +271,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorProducerAlone() throws ApexException {
+ void testRestRequestorProducerAlone() throws ApexException {
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json"};
@@ -291,7 +290,7 @@ public class RestRequestorTest {
* @throws ApexException the apex exception
*/
@Test
- public void testRestRequestorConsumerAlone() throws ApexException {
+ void testRestRequestorConsumerAlone() throws ApexException {
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json"};
ApexMain apexMain = new ApexMain(args);
apexMain.shutdown();
@@ -307,8 +306,8 @@ public class RestRequestorTest {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
final String responseString = response.readEntity(String.class);
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap =
+ new Gson().fromJson(responseString, Map.class);
return Double.parseDouble(jsonMap.get(statToGet).toString());
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
index b05c24333..f82add13f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
@@ -46,9 +46,9 @@ public class SupportRestRequestorEndpoint {
private static int getMessagesReceived = 0;
private static int deleteMessagesReceived = 0;
- private static String EVENT_STRING = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.events\",\n"
- + "\"name\": \"ResponseEvent\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_"
- + getMessagesReceived + "\",\n" + "\"target\": \"apex\",\n" + "\"intPar\": 9080\n" + "}";
+ private static final String EVENT_STRING = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.events\",\n"
+ + "\"name\": \"ResponseEvent\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_"
+ + getMessagesReceived + "\",\n" + "\"target\": \"apex\",\n" + "\"intPar\": 9080\n" + "}";
/**
* Reset counters.
@@ -73,10 +73,10 @@ public class SupportRestRequestorEndpoint {
statMessagesReceived++;
}
return Response.status(200)
- .entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": "
- + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + ",\"DELETE\": "
- + deleteMessagesReceived + "}")
- .build();
+ .entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": "
+ + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + ",\"DELETE\": "
+ + deleteMessagesReceived + "}")
+ .build();
}
/**
@@ -129,8 +129,7 @@ public class SupportRestRequestorEndpoint {
postMessagesReceived++;
}
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class);
assertTrue(jsonMap.containsKey("name"));
assertEquals("0.0.1", jsonMap.get("version"));
assertEquals("org.onap.policy.apex.events", jsonMap.get("nameSpace"));
@@ -165,8 +164,7 @@ public class SupportRestRequestorEndpoint {
putMessagesReceived++;
}
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class);
assertTrue(jsonMap.containsKey("name"));
assertEquals("0.0.1", jsonMap.get("version"));
assertEquals("org.onap.policy.apex.events", jsonMap.get("nameSpace"));