summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/plugins-context/plugins-context-persistence/pom.xml34
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java33
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java44
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java36
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java43
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java35
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java71
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java71
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java94
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java60
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java41
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java13
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java19
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java32
-rw-r--r--plugins/plugins-context/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java61
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java46
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java32
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java102
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java77
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java67
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducerTest.java37
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParametersTest.java421
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java)54
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java83
-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.java53
-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
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java20
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java110
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducerTest.java74
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java29
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/SupportApexEventReceiver.java2
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml16
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java57
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java38
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java14
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolTest.java26
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java97
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java21
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java27
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java25
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java31
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java26
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java14
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java49
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java54
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java31
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java34
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java16
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java35
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java25
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java25
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java38
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java4
64 files changed, 1480 insertions, 1483 deletions
diff --git a/plugins/plugins-context/plugins-context-persistence/pom.xml b/plugins/plugins-context/plugins-context-persistence/pom.xml
deleted file mode 100644
index 9d95195e7..000000000
--- a/plugins/plugins-context/plugins-context-persistence/pom.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2016-2018 Ericsson. All rights reserved.
- ================================================================================
- 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=========================================================
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
- <artifactId>plugins-context</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-persistence</groupId>
- <artifactId>plugins-context-persistence</artifactId>
- <packaging>pom</packaging>
-
- <name>${project.artifactId}</name>
- <description>Plugins for 3pps that persist context</description>
-</project>
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java
index 9051f3688..93bbe2054 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-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.
@@ -21,14 +21,14 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
import org.apache.avro.generic.GenericRecord;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -45,9 +45,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaAai.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaAaiTest {
+class AvroSchemaAaiTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String aaiInventoryResponseSchema;
@@ -57,20 +56,20 @@ public class AvroSchemaAaiTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
aaiInventoryResponseSchema =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +80,8 @@ public class AvroSchemaAaiTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +91,9 @@ public class AvroSchemaAaiTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAaiResponsePolicy() throws IOException {
+ void testAaiResponsePolicy() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -105,7 +104,7 @@ public class AvroSchemaAaiTest {
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/AAIResponse4Policy.json");
final Array<?> newArrayFull = (Array<?>) schemaHelper.createNewInstance(inString);
final String vnfName = ((GenericRecord) ((GenericRecord) newArrayFull.get(0)).get("generic_DasH_vnf"))
- .get("vnf_DasH_name").toString();
+ .get("vnf_DasH_name").toString();
assertEquals("ZRDM2MMEX39", vnfName);
}
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java
index 8d7041c60..f2dd5b5e3 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-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.
@@ -21,13 +21,13 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -40,14 +40,12 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.TextFileUtils;
-// TODO: Auto-generated Javadoc
/**
* The Class TestAvroSchemaArray.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaArrayTest {
+class AvroSchemaArrayTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String longArraySchema;
@@ -58,8 +56,8 @@ public class AvroSchemaArrayTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
longArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleLong.avsc");
@@ -69,8 +67,8 @@ public class AvroSchemaArrayTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +79,8 @@ public class AvroSchemaArrayTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +90,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testArrayInit() throws IOException {
+ void testArrayInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -103,10 +101,10 @@ public class AvroSchemaArrayTest {
assertEquals(0, newArrayEmpty.size());
final String inString =
- TextFileUtils.getTextFileAsString("src/test/resources/data/ArrayExampleAddressFull.json");
+ TextFileUtils.getTextFileAsString("src/test/resources/data/ArrayExampleAddressFull.json");
final Array<?> newArrayFull = (Array<?>) schemaHelper.createNewInstance(inString);
assertEquals("{\"streetaddress\": \"1600 Pennsylvania Avenue\", \"city\": \"Washington DC\"}",
- newArrayFull.get(0).toString());
+ newArrayFull.get(0).toString());
}
/**
@@ -115,9 +113,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testLongArrayUnmarshalMarshal() throws IOException {
+ void testLongArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -132,9 +130,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressArrayUnmarshalMarshal() throws IOException {
+ void testAddressArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -147,7 +145,7 @@ public class AvroSchemaArrayTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java
index d3cd7a482..43d68f223 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,13 +23,13 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.EnumSymbol;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -42,14 +42,12 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.TextFileUtils;
-// TODO: Auto-generated Javadoc
/**
* The Class TestAvroSchemaEnum.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaEnumTest {
+class AvroSchemaEnumTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String enumSchema;
@@ -59,8 +57,8 @@ public class AvroSchemaEnumTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
enumSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/EnumSchema.avsc");
@@ -69,8 +67,8 @@ public class AvroSchemaEnumTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +79,8 @@ public class AvroSchemaEnumTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +90,9 @@ public class AvroSchemaEnumTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testEnumInit() throws IOException {
+ void testEnumInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -112,9 +110,9 @@ public class AvroSchemaEnumTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testEnumUnmarshalMarshal() throws IOException {
+ void testEnumUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -135,7 +133,7 @@ public class AvroSchemaEnumTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
index 93797fba1..ba04226c7 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,14 +23,14 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Fixed;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -47,9 +47,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaFixed.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaFixedTest {
+class AvroSchemaFixedTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String fixedSchema;
@@ -59,8 +58,8 @@ public class AvroSchemaFixedTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
fixedSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/FixedSchema.avsc");
@@ -69,8 +68,8 @@ public class AvroSchemaFixedTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +80,8 @@ public class AvroSchemaFixedTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,17 +91,17 @@ public class AvroSchemaFixedTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFixedInit() throws IOException {
+ void testFixedInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
- assertThatThrownBy(() -> schemaHelper.createNewInstance())
+ assertThatThrownBy(schemaHelper::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance "
- + "of class \"org.apache.avro.generic.GenericData$Fixed\" "
- + "using the default constructor \"Fixed()\"");
+ + "of class \"org.apache.avro.generic.GenericData$Fixed\" "
+ + "using the default constructor \"Fixed()\"");
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/FixedExampleGood.json");
final Fixed newFixedFull = (Fixed) schemaHelper.createNewInstance(inString);
assertTrue(newFixedFull.toString().startsWith("[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65"));
@@ -115,9 +114,9 @@ public class AvroSchemaFixedTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFixedUnmarshalMarshal() throws IOException {
+ void testFixedUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -140,7 +139,7 @@ public class AvroSchemaFixedTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java
index 5bbaf97fa..fd9d5b6e5 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-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.
@@ -23,9 +23,9 @@ package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -40,17 +40,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperBadSchemas.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperBadSchemasTest {
+class AvroSchemaHelperBadSchemasTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -58,20 +57,20 @@ public class AvroSchemaHelperBadSchemasTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
}
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -79,7 +78,7 @@ public class AvroSchemaHelperBadSchemasTest {
* Bad schema test.
*/
@Test
- public void badSchemaTest() {
+ void badSchemaTest() {
final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "AVRO", "}");
schemas.getSchemasMap().put(avroBadSchema0.getKey(), avroBadSchema0);
@@ -91,25 +90,25 @@ public class AvroSchemaHelperBadSchemasTest {
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema1.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad1:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema2 =
- new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
+ new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
schemas.getSchemasMap().put(avroBadSchema2.getKey(), avroBadSchema2);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema2.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad2:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema3 =
- new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
+ new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
schemas.getSchemasMap().put(avroBadSchema3.getKey(), avroBadSchema3);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema3.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad3:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema4 =
- new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema4.getKey(), avroBadSchema4);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema4.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad4:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema5 =
- new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema5.getKey(), avroBadSchema5);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema5.getKey()))
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
index 06848c9a9..4cb5c9dd3 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,11 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -43,17 +43,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperMarshal.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperMarshalTest {
+class AvroSchemaHelperMarshalTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -61,8 +60,8 @@ public class AvroSchemaHelperMarshalTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -73,8 +72,8 @@ public class AvroSchemaHelperMarshalTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -82,13 +81,13 @@ public class AvroSchemaHelperMarshalTest {
* Test null marshal.
*/
@Test
- public void testNullMarshal() {
+ void testNullMarshal() {
final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
+ new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
assertEquals("null", schemaHelper0.marshal2String(null));
assertEquals("null", schemaHelper0.marshal2String(123));
@@ -99,13 +98,13 @@ public class AvroSchemaHelperMarshalTest {
* Test boolean marshal.
*/
@Test
- public void testBooleanMarshal() {
+ void testBooleanMarshal() {
final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
assertEquals("true", schemaHelper1.marshal2String(true));
assertEquals("false", schemaHelper1.marshal2String(false));
@@ -119,13 +118,13 @@ public class AvroSchemaHelperMarshalTest {
* Test int marshal.
*/
@Test
- public void testIntMarshal() {
+ void testIntMarshal() {
final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
+ new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
assertEquals("0", schemaHelper2.marshal2String(0));
assertEquals("1", schemaHelper2.marshal2String(1));
@@ -144,13 +143,13 @@ public class AvroSchemaHelperMarshalTest {
* Test long marshal.
*/
@Test
- public void testLongMarshal() {
+ void testLongMarshal() {
final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
+ new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
assertEquals("0", schemaHelper3.marshal2String(0L));
assertEquals("1", schemaHelper3.marshal2String(1L));
@@ -167,13 +166,13 @@ public class AvroSchemaHelperMarshalTest {
* Test float marshal.
*/
@Test
- public void testFloatMarshal() {
+ void testFloatMarshal() {
final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
+ new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
assertEquals("0.0", schemaHelper4.marshal2String(0F));
assertEquals("1.0", schemaHelper4.marshal2String(1F));
@@ -194,13 +193,13 @@ public class AvroSchemaHelperMarshalTest {
* Test double marshal.
*/
@Test
- public void testDoubleMarshal() {
+ void testDoubleMarshal() {
final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
+ new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
assertEquals("0.0", schemaHelper5.marshal2String(0D));
assertEquals("1.0", schemaHelper5.marshal2String(1D));
@@ -221,13 +220,13 @@ public class AvroSchemaHelperMarshalTest {
* Test string marshal.
*/
@Test
- public void testStringMarshal() {
+ void testStringMarshal() {
final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
assertEquals("\"0\"", schemaHelper7.marshal2String("0"));
assertEquals("\"1\"", schemaHelper7.marshal2String("1"));
@@ -247,9 +246,9 @@ public class AvroSchemaHelperMarshalTest {
* Test bytes marshal.
*/
@Test
- public void testBytesMarshal() {
+ void testBytesMarshal() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
index 23ac9a855..7dd1e1aca 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,12 +23,12 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.avro.util.Utf8;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -44,17 +44,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperUnmarshal.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperUnmarshalTest {
+class AvroSchemaHelperUnmarshalTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -62,8 +61,8 @@ public class AvroSchemaHelperUnmarshalTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -74,8 +73,8 @@ public class AvroSchemaHelperUnmarshalTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -83,13 +82,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test null unmarshal.
*/
@Test
- public void testNullUnmarshal() {
+ void testNullUnmarshal() {
final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO",
- "{\"type\": \"null\"}");
+ "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroNullSchema.getKey());
+ avroNullSchema.getKey());
assertThatThrownBy(schemaHelper0::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance, schema class for the schema is null");
@@ -103,13 +102,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test boolean unmarshal.
*/
@Test
- public void testBooleanUnmarshal() {
+ void testBooleanUnmarshal() {
final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO",
- "{\"type\": \"boolean\"}");
+ "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroBooleanSchema.getKey());
+ avroBooleanSchema.getKey());
assertThatThrownBy(schemaHelper1::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" "
@@ -128,13 +127,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test int unmarshal.
*/
@Test
- public void testIntUnmarshal() {
+ void testIntUnmarshal() {
final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO",
- "{\"type\": \"int\"}");
+ "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroIntSchema.getKey());
+ avroIntSchema.getKey());
assertThatThrownBy(schemaHelper2::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" "
@@ -160,13 +159,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test long unmarshal.
*/
@Test
- public void testLongUnmarshal() {
+ void testLongUnmarshal() {
final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO",
- "{\"type\": \"long\"}");
+ "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroLongSchema.getKey());
+ avroLongSchema.getKey());
assertThatThrownBy(schemaHelper3::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" "
@@ -194,13 +193,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test float unmarshal.
*/
@Test
- public void testFloatUnmarshal() {
+ void testFloatUnmarshal() {
final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO",
- "{\"type\": \"float\"}");
+ "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroFloatSchema.getKey());
+ avroFloatSchema.getKey());
assertThatThrownBy(schemaHelper4::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" "
@@ -226,13 +225,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test double unmarshal.
*/
@Test
- public void testDoubleUnmarshal() {
+ void testDoubleUnmarshal() {
final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO",
- "{\"type\": \"double\"}");
+ "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroDoubleSchema.getKey());
+ avroDoubleSchema.getKey());
assertThatThrownBy(schemaHelper5::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" "
@@ -258,13 +257,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test string unmarshal.
*/
@Test
- public void testStringUnmarshal() {
+ void testStringUnmarshal() {
final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
- "{\"type\": \"string\"}");
+ "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroStringSchema.getKey());
+ avroStringSchema.getKey());
assertEquals("", schemaHelper7.createNewInstance(""));
assertEquals("1.2345E06", schemaHelper7.createNewInstance("1.2345E06"));
@@ -288,9 +287,9 @@ public class AvroSchemaHelperUnmarshalTest {
* Test bytes unmarshal.
*/
@Test
- public void testBytesUnmarshal() {
+ void testBytesUnmarshal() {
final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
- "{\"type\": \"bytes\"}");
+ "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
index a3e85ed91..2411b0bb2 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2023-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,18 +22,19 @@
package org.onap.policy.apex.plugins.context.schema.avro;
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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.util.Utf8;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
@@ -51,9 +52,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaMap.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaMapTest {
+class AvroSchemaMapTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String longMapSchema;
@@ -65,21 +65,21 @@ public class AvroSchemaMapTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
longMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleLong.avsc");
addressMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddress.avsc");
addressMapSchemaInvalidFields =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -89,8 +89,8 @@ public class AvroSchemaMapTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -100,15 +100,15 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testValidSubstitutions() throws IOException {
+ void testValidSubstitutions() throws IOException {
final String subst1 = "{\"type\":\"record\",\"name\":\"Subst1\","
- + "\"fields\":[{\"name\": \"A_DasH_B\",\"type\":\"string\"}]}";
+ + "\"fields\":[{\"name\": \"A_DasH_B\",\"type\":\"string\"}]}";
final AxContextSchema avroSubstSchema1 = new AxContextSchema(
- new AxArtifactKey("AvroSubst1", "0.0.1"), "AVRO", subst1);
+ new AxArtifactKey("AvroSubst1", "0.0.1"), "AVRO", subst1);
schemas.getSchemasMap().put(avroSubstSchema1.getKey(), avroSubstSchema1);
SchemaHelper schemaHelperSubst1 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema1.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema1.getKey());
final GenericRecord subst1A = (GenericRecord) schemaHelperSubst1.unmarshal("{\"A-B\":\"foo\"}");
assertEquals(new Utf8("foo"), subst1A.get("A_DasH_B"));
assertThatThrownBy(() -> subst1A.get("A-B")).hasMessage("Not a valid schema field: A-B");
@@ -119,13 +119,13 @@ public class AvroSchemaMapTest {
assertEquals("Expected string. Got VALUE_NUMBER_INT", exception1.getCause().getMessage());
final String subst2 = "{\"type\":\"record\",\"name\":\"Subst2\","
- + "\"fields\":[{\"name\": \"C_DoT_D\",\"type\":\"int\"}]}";
+ + "\"fields\":[{\"name\": \"C_DoT_D\",\"type\":\"int\"}]}";
final AxContextSchema avroSubstSchema2 = new AxContextSchema(
- new AxArtifactKey("AvroSubst2", "0.0.1"), "AVRO", subst2);
+ new AxArtifactKey("AvroSubst2", "0.0.1"), "AVRO", subst2);
schemas.getSchemasMap().put(avroSubstSchema2.getKey(), avroSubstSchema2);
final SchemaHelper schemaHelperSubst2 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema2.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema2.getKey());
final GenericRecord subst2A = (GenericRecord) schemaHelperSubst2.unmarshal("{\"C.D\":123}");
assertEquals(123, subst2A.get("C_DoT_D"));
assertThatThrownBy(() -> subst2A.get("C.D")).hasMessage("Not a valid schema field: C.D");
@@ -136,13 +136,13 @@ public class AvroSchemaMapTest {
assertEquals("Expected int. Got VALUE_STRING", exception2.getCause().getMessage());
final String subst3 = "{\"type\":\"record\",\"name\":\"Subst3\","
- + "\"fields\":[{\"name\": \"E_ColoN_F\",\"type\":\"boolean\"}]}";
+ + "\"fields\":[{\"name\": \"E_ColoN_F\",\"type\":\"boolean\"}]}";
final AxContextSchema avroSubstSchema3 = new AxContextSchema(
- new AxArtifactKey("AvroSubst3", "0.0.1"), "AVRO", subst3);
+ new AxArtifactKey("AvroSubst3", "0.0.1"), "AVRO", subst3);
schemas.getSchemasMap().put(avroSubstSchema3.getKey(), avroSubstSchema3);
final SchemaHelper schemaHelperSubst3 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema3.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema3.getKey());
final GenericRecord subst3A = (GenericRecord) schemaHelperSubst3.unmarshal("{\"E:F\":true}");
assertEquals(true, subst3A.get("E_ColoN_F"));
assertThatThrownBy(() -> subst3A.get("E:F")).hasMessage("Not a valid schema field: E:F");
@@ -159,11 +159,11 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testInValidSubstitutions() throws IOException {
+ void testInValidSubstitutions() throws IOException {
final String fail1 = "{\"type\":\"record\",\"name\":\"Fail1\","
- + "\"fields\":[{\"name\": \"A-B\",\"type\":\"string\"}]}";
+ + "\"fields\":[{\"name\": \"A-B\",\"type\":\"string\"}]}";
final AxContextSchema avroFailSchema1 = new AxContextSchema(
- new AxArtifactKey("AvroFail1", "0.0.1"), "AVRO", fail1);
+ new AxArtifactKey("AvroFail1", "0.0.1"), "AVRO", fail1);
schemas.getSchemasMap().put(avroFailSchema1.getKey(), avroFailSchema1);
SchemaHelperFactory sh = new SchemaHelperFactory();
@@ -174,9 +174,9 @@ public class AvroSchemaMapTest {
assertEquals("Illegal character in: A-B", exception1.getCause().getMessage());
final String fail2 = "{\"type\":\"record\",\"name\":\"Fail2\","
- + "\"fields\":[{\"name\": \"C.D\",\"type\":\"int\"}]}";
+ + "\"fields\":[{\"name\": \"C.D\",\"type\":\"int\"}]}";
final AxContextSchema avroFailSchema2 = new AxContextSchema(
- new AxArtifactKey("AvroFail2", "0.0.1"), "AVRO", fail2);
+ new AxArtifactKey("AvroFail2", "0.0.1"), "AVRO", fail2);
schemas.getSchemasMap().put(avroFailSchema2.getKey(), avroFailSchema2);
AxArtifactKey ak2 = avroFailSchema2.getKey();
@@ -186,9 +186,9 @@ public class AvroSchemaMapTest {
assertEquals("Illegal character in: C.D", exception2.getCause().getMessage());
final String fail3 = "{\"type\":\"record\",\"name\":\"Fail3\","
- + "\"fields\":[{\"name\": \"E:F\",\"type\":\"boolean\"}]}";
+ + "\"fields\":[{\"name\": \"E:F\",\"type\":\"boolean\"}]}";
final AxContextSchema avroFailSchema3 = new AxContextSchema(
- new AxArtifactKey("AvroFail3", "0.0.1"), "AVRO", fail3);
+ new AxArtifactKey("AvroFail3", "0.0.1"), "AVRO", fail3);
schemas.getSchemasMap().put(avroFailSchema3.getKey(), avroFailSchema3);
AxArtifactKey ak3 = avroFailSchema3.getKey();
final Throwable exception3 = assertThrows(ContextRuntimeException.class,
@@ -203,9 +203,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testMapInit() throws IOException {
+ void testMapInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -217,7 +217,7 @@ public class AvroSchemaMapTest {
final HashMap<?, ?> newMapFull = (HashMap<?, ?>) schemaHelper.createNewInstance(inString);
assertEquals("{\"streetaddress\": \"221 B Baker St.\", \"city\": \"London\"}",
- newMapFull.get(new Utf8("address2")).toString());
+ newMapFull.get(new Utf8("address2")).toString());
}
/**
@@ -226,9 +226,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testLongMapUnmarshalMarshal() throws IOException {
+ void testLongMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -243,9 +243,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressMapUnmarshalMarshal() throws IOException {
+ void testAddressMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -260,9 +260,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testSubRecordCreateRecord() throws IOException {
+ void testSubRecordCreateRecord() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -278,9 +278,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
+ void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -290,7 +290,7 @@ public class AvroSchemaMapTest {
String vals = TextFileUtils.getTextFileAsString("src/test/resources/data/MapExampleAddressInvalidFields.json");
final HashMap<?, ?> newMapFull = (HashMap<?, ?>) schemaHelper.createNewInstance(vals);
final String expect = "{\"street_DasH_address\": \"Wayne Manor\", \"the_DoT_city\": \"Gotham City\", "
- + "\"the_ColoN_code\": \"BatCave7\"}";
+ + "\"the_ColoN_code\": \"BatCave7\"}";
assertEquals(expect, newMapFull.get(new Utf8("address_DoT_3")).toString());
}
@@ -298,7 +298,7 @@ public class AvroSchemaMapTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
@@ -311,7 +311,7 @@ public class AvroSchemaMapTest {
TextFileUtils.putStringAsFile(outString, tempOutFile);
final String decodeEncodeInString = TextFileUtils.getTextFileAsString(fileName);
- tempOutFile.delete();
+ assertTrue(tempOutFile.delete());
final HashMap<?, ?> secondDecodedMap = (HashMap<?, ?>) schemaHelper.unmarshal(decodeEncodeInString);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
index 3a81584f0..a2a8bdd61 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023-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,14 +22,15 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+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.io.IOException;
import org.apache.avro.generic.GenericRecord;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -46,9 +47,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaRecord.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaRecordTest {
+class AvroSchemaRecordTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String recordSchema;
@@ -61,22 +61,22 @@ public class AvroSchemaRecordTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
recordSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExample.avsc");
recordSchemaVpn = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc");
recordSchemaVpnReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc");
recordSchemaInvalidFields =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -87,8 +87,8 @@ public class AvroSchemaRecordTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -98,15 +98,15 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordInit() throws IOException {
+ void testRecordInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
final GenericRecord newRecordEmpty = (GenericRecord) schemaHelper.createNewInstance();
- assertEquals(null, newRecordEmpty.get("passwordHash"));
+ assertNull(newRecordEmpty.get("passwordHash"));
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/RecordExampleFull.json");
final GenericRecord newRecordFull = (GenericRecord) schemaHelper.createNewInstance(inString);
@@ -119,9 +119,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordUnmarshalMarshal() throws IOException {
+ void testRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -133,12 +133,11 @@ public class AvroSchemaRecordTest {
/**
* Test record create.
*
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordCreateRecord() throws IOException {
+ void testRecordCreateRecord() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -159,9 +158,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordUnmarshalMarshalInvalid() throws IOException {
+ void testRecordUnmarshalMarshalInvalid() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -175,9 +174,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testVpnRecordUnmarshalMarshal() throws IOException {
+ void testVpnRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpn);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpn);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -188,12 +187,11 @@ public class AvroSchemaRecordTest {
/**
* Test VPN record reuse.
*
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testVpnRecordReuse() throws IOException {
+ void testVpnRecordReuse() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse);
assertNotNull(avroSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
@@ -205,7 +203,7 @@ public class AvroSchemaRecordTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java
index 4691927eb..390381e1b 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-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.
@@ -21,16 +21,16 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.Record;
import org.apache.avro.generic.GenericRecord;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -48,7 +48,7 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class HealthCheckSchemaTest {
+class HealthCheckSchemaTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String healthCheckSchema;
@@ -58,8 +58,8 @@ public class HealthCheckSchemaTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -69,8 +69,8 @@ public class HealthCheckSchemaTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +81,8 @@ public class HealthCheckSchemaTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,14 +92,14 @@ public class HealthCheckSchemaTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testHealthCheck() throws IOException {
+ void testHealthCheck() throws IOException {
final AxContextSchema avroSchema =
new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", healthCheckSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
- testUnmarshalMarshal(schemaHelper, "src/test/resources/data/HealthCheckEvent.json");
+ testUnmarshalMarshal(schemaHelper);
final GenericRecord healthCheckRecord = (Record) schemaHelper.createNewInstance();
final Schema healthCheckRecordSchema = healthCheckRecord.getSchema();
@@ -107,7 +107,7 @@ public class HealthCheckSchemaTest {
final GenericRecord inputRecord = new GenericData.Record(healthCheckRecordSchema.getField("input").schema());
final Schema inputRecordRecordSchema = inputRecord.getSchema();
- final GenericRecord actionIndentifiersRecord =
+ final GenericRecord actionIdentifiersRecord =
new GenericData.Record(inputRecordRecordSchema.getField("action_DasH_identifiers").schema());
final GenericRecord commonHeaderRecord =
@@ -118,7 +118,7 @@ public class HealthCheckSchemaTest {
new GenericData.Record(commonHeaderRecordSchema.getField("flags").schema());
healthCheckRecord.put("input", inputRecord);
- inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord);
+ inputRecord.put("action_DasH_identifiers", actionIdentifiersRecord);
inputRecord.put("common_DasH_header", commonHeaderRecord);
commonHeaderRecord.put("flags", commonHeaderFlagsRecord);
@@ -126,7 +126,7 @@ public class HealthCheckSchemaTest {
inputRecord.put("payload", "{\"host-ip-address\":\"131.160.203.125\",\"input.url\":\"131.160.203.125/afr\","
+ "\"request-action-type\":\"GET\",\"request-action\":\"AFR\"}");
- actionIndentifiersRecord.put("vnf_DasH_id", "49414df5-3482-4fd8-9952-c463dff2770b");
+ actionIdentifiersRecord.put("vnf_DasH_id", "49414df5-3482-4fd8-9952-c463dff2770b");
commonHeaderRecord.put("request_DasH_id", "afr-request3");
commonHeaderRecord.put("originator_DasH_id", "AFR");
@@ -140,18 +140,17 @@ public class HealthCheckSchemaTest {
final String eventString = TextFileUtils.getTextFileAsString("src/test/resources/data/HealthCheckEvent.json");
final String outString = schemaHelper.marshal2String(healthCheckRecord);
- assertEquals(eventString.toString().replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
+ assertEquals(eventString.replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
}
/**
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
- private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
- final String inString = TextFileUtils.getTextFileAsString(fileName);
+ private void testUnmarshalMarshal(final SchemaHelper schemaHelper) throws IOException {
+ final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/HealthCheckEvent.json");
final GenericRecord decodedObject = (GenericRecord) schemaHelper.unmarshal(inString);
final String outString = schemaHelper.marshal2String(decodedObject);
assertEquals(inString.replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
index ce03678c9..7a7daa2bd 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -21,9 +22,9 @@
package org.onap.policy.apex.plugins.context.schema.json;
import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -62,7 +63,7 @@ public class CommonTestData {
/**
* Setup before all tests.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException {
COMMONHEADERTYPE_DRAFT04 =
TextFileUtils.getTextFileAsString("src/test/resources/schema/commonHeaderType_draft04.json");
@@ -81,7 +82,7 @@ public class CommonTestData {
/**
* Setup before test.
*/
- @Before
+ @BeforeEach
public void setUp() {
schemas = new AxContextSchemas(new AxArtifactKey("JsonSchema", VERSION));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -95,7 +96,7 @@ public class CommonTestData {
/**
* Teardown after test.
*/
- @After
+ @AfterEach
public void tearDown() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
ModelService.clear();
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
index 15458199a..b129330ce 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -28,16 +29,16 @@ import com.google.gson.JsonObject;
import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
-public class JsonSchemaHelperMarshalTest extends CommonTestData {
+class JsonSchemaHelperMarshalTest extends CommonTestData {
/**
* Test Boolean.
*/
@Test
- public void testBooleanMarshal() {
+ void testBooleanMarshal() {
var schemaHelper = createSchema(BOOLEAN_SCHEMA);
assertThat(schemaHelper.marshal2String(Boolean.TRUE)).isEqualTo("true");
}
@@ -46,7 +47,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* Test null.
*/
@Test
- public void testNullMarshal() {
+ void testNullMarshal() {
var schemaHelper = createSchema(NULL_SCHEMA);
assertThat(schemaHelper.marshal2String(null)).isEqualTo("null");
}
@@ -57,7 +58,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coder exception
*/
@Test
- public void testArrayMarshal() throws CoderException {
+ void testArrayMarshal() throws CoderException {
var schemaHelper = createSchema(MEASUREMENTGROUPS_TYPE);
var object = coder.decode(MEASUREMENTGROUPS, Object.class);
assertThat(object).isInstanceOf(ArrayList.class);
@@ -73,7 +74,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft04_valid() throws CoderException {
+ void testObjectSchemaDraft04_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndMarshal(COMMONHEADERTYPE_DRAFT04, dataAsObject, true);
assertThat(dataReturned).isEqualTo(COMMONHEADER);
@@ -85,7 +86,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_valid() throws CoderException {
+ void testObjectSchemaDraft07_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true);
assertThat(dataReturned).isEqualTo(COMMONHEADER);
@@ -98,7 +99,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_fieldMissing() throws CoderException {
+ void testObjectSchema_fieldMissing() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true))
@@ -112,7 +113,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_OptionalField() throws CoderException {
+ void testObjectSchema_OptionalField() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataAsjsonObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
index 11c8638de..d0059f26f 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -27,19 +28,19 @@ import com.google.gson.JsonObject;
import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.common.utils.coder.CoderException;
-public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
+class JsonSchemaHelperUnmarshalTest extends CommonTestData {
/**
* Test Boolean.
*/
@Test
- public void testBooleanUnmarshal() {
+ void testBooleanUnmarshal() {
var schemaHelper = createSchema(BOOLEAN_SCHEMA);
assertThat(schemaHelper.createNewInstance(BOOLEAN_DATA)).isInstanceOf(Boolean.class).isEqualTo(Boolean.TRUE);
}
@@ -48,30 +49,31 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* Test null.
*/
@Test
- public void testNullUnmarshal() {
+ void testNullUnmarshal() {
var schemaHelper = createSchema(NULL_SCHEMA);
- assertThat(schemaHelper.createNewInstance(NULL_DATA)).isEqualTo(null);
+ assertThat(schemaHelper.createNewInstance(NULL_DATA)).isNull();
}
/**
* Test Array.
*/
@Test
- public void testArrayUnmarshal() {
+ void testArrayUnmarshal() {
var schemaHelper = createSchema(MEASUREMENTGROUPS_TYPE);
var obj = schemaHelper.createNewInstance(MEASUREMENTGROUPS);
assertThat(obj).isInstanceOf(ArrayList.class);
}
/**
- * Test invlaid schema.
+ * Test invalid schema.
*/
@Test
- public void testSchemaInvalid() {
+ void testSchemaInvalid() {
String schemaDef = "{\"type\": \"object\"}";
final AxContextSchema jsonSchema =
new AxContextSchema(new AxArtifactKey("JsonObject", VERSION), JSON, schemaDef);
- assertThatThrownBy(() -> new JsonSchemaHelper().init(testKey, jsonSchema))
+ var jsonSchemaHelper = new JsonSchemaHelper();
+ assertThatThrownBy(() -> jsonSchemaHelper.init(testKey, jsonSchema))
.isInstanceOf(ContextRuntimeException.class).hasMessageContaining("schema is invalid");
}
@@ -81,7 +83,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft04_valid() throws CoderException {
+ void testObjectSchemaDraft04_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndUnmarshal(COMMONHEADERTYPE_DRAFT04, COMMONHEADER);
assertThat(dataReturned).isEqualTo(dataAsObject);
@@ -93,7 +95,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_valid() throws CoderException {
+ void testObjectSchemaDraft07_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, COMMONHEADER);
assertThat(dataReturned).isEqualTo(dataAsObject);
@@ -105,7 +107,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_invalid() throws CoderException {
+ void testObjectSchemaDraft07_invalid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.addProperty("requestId", "abcd");
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
@@ -119,7 +121,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testCreateNewInstanceInvalid() throws CoderException {
+ void testCreateNewInstanceInvalid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
.isInstanceOf(ContextRuntimeException.class).hasMessageContaining("not an instance of JsonObject");
@@ -131,7 +133,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_fieldMissing() throws CoderException {
+ void testObjectSchema_fieldMissing() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
@@ -145,7 +147,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_OptionalField() throws CoderException {
+ void testObjectSchema_OptionalField() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataAsjsonObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
diff --git a/plugins/plugins-context/pom.xml b/plugins/plugins-context/pom.xml
index 94a303b65..98195f77b 100644
--- a/plugins/plugins-context/pom.xml
+++ b/plugins/plugins-context/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 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.
@@ -44,6 +45,5 @@
<module>plugins-context-schema</module>
<module>plugins-context-distribution</module>
<module>plugins-context-locking</module>
- <module>plugins-context-persistence</module>
</modules>
</project>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
index bd4103f92..fd447a205 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * 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.
@@ -21,59 +21,59 @@
package org.onap.policy.apex.plugins.event.carrier.grpc;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+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 org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
import org.onap.policy.apex.service.engine.event.PeeredReference;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-public class ApexGrpcConsumerTest {
+class ApexGrpcConsumerTest {
private static final String CONSUMER_NAME = "TestApexGrpcConsumer";
private ApexGrpcConsumer grpcConsumer = null;
private ApexGrpcProducer grpcProducer = null;
private EventHandlerParameters consumerParameters = null;
- private ApexEventReceiver incomingEventReceiver = null;
+ private final ApexEventReceiver incomingEventReceiver = null;
/**
* Set up testing.
- *
- * @throws ApexEventException on test set up errors.
*/
- @Before
- public void setUp() throws ApexEventException {
+ @BeforeEach
+ void setUp() {
grpcConsumer = new ApexGrpcConsumer();
grpcProducer = new ApexGrpcProducer();
}
@Test
- public void testInit() {
- consumerParameters = populateConsumerParameters(true, true);
+ void testInit() {
+ consumerParameters = populateConsumerParameters(true);
Assertions.assertThatCode(() -> grpcConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.doesNotThrowAnyException();
}
@Test
- public void testInit_invalidPeeredMode() {
- consumerParameters = populateConsumerParameters(true, false);
+ void testInit_invalidPeeredMode() {
+ consumerParameters = populateConsumerParameters(false);
assertThatThrownBy(() -> grpcConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.hasMessageContaining(
"gRPC consumer (" + CONSUMER_NAME + ") must run in peered requestor mode with a gRPC producer");
}
@Test
- public void testGetName() {
- assertEquals(null, new ApexGrpcConsumer().getName());
+ void testGetName() {
+ assertNull(new ApexGrpcConsumer().getName());
}
@Test
- public void testPeeredReference() throws ApexEventException {
- consumerParameters = populateConsumerParameters(true, true);
+ void testPeeredReference() throws ApexEventException {
+ consumerParameters = populateConsumerParameters(true);
grpcConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR,
new PeeredReference(EventHandlerPeeredMode.REQUESTOR, grpcConsumer, grpcProducer));
grpcConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
@@ -83,19 +83,10 @@ public class ApexGrpcConsumerTest {
assertEquals(grpcProducer, peeredReference.getPeeredProducer());
}
- private EventHandlerParameters populateConsumerParameters(boolean isConsumer, boolean isPeeredMode) {
+ private EventHandlerParameters populateConsumerParameters(boolean isPeeredMode) {
consumerParameters = new EventHandlerParameters();
- GrpcCarrierTechnologyParameters params = new GrpcCarrierTechnologyParameters();
- params.setLabel("GRPC");
- params.setEventProducerPluginClass(ApexGrpcProducer.class.getName());
- params.setEventConsumerPluginClass(ApexGrpcConsumer.class.getName());
- if (!isConsumer) {
- params.setHost("hostname");
- params.setPort(3214);
- params.setUsername("dummyUser");
- params.setPassword("dummyPassword");
- params.setTimeout(1);
- }
+ GrpcCarrierTechnologyParameters params =
+ getGrpcCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(params);
if (isPeeredMode) {
consumerParameters.setPeeredMode(EventHandlerPeeredMode.REQUESTOR, true);
@@ -103,4 +94,12 @@ public class ApexGrpcConsumerTest {
}
return consumerParameters;
}
+
+ private static @NotNull GrpcCarrierTechnologyParameters getGrpcCarrierTechnologyParameters() {
+ GrpcCarrierTechnologyParameters params = new GrpcCarrierTechnologyParameters();
+ params.setLabel("GRPC");
+ params.setEventProducerPluginClass(ApexGrpcProducer.class.getName());
+ params.setEventConsumerPluginClass(ApexGrpcConsumer.class.getName());
+ return params;
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
index 31be69e3a..7411737fe 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,61 +22,61 @@
package org.onap.policy.apex.plugins.event.carrier.grpc;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.spy;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.cds.client.CdsProcessorGrpcClient;
-@RunWith(MockitoJUnitRunner.class)
-public class ApexGrpcProducerTest {
+@ExtendWith(MockitoExtension.class)
+class ApexGrpcProducerTest {
private static final String PRODUCER_NAME = "TestApexGrpcProducer";
private static final String HOST = "localhost";
@Mock
private CdsProcessorGrpcClient grpcClient;
- private ApexGrpcProducer apexGrpcProducer = spy(new ApexGrpcProducer());
+ private final ApexGrpcProducer apexGrpcProducer = spy(new ApexGrpcProducer());
@Mock
private EventHandlerParameters eventHandlerParameters;
/**
* Set up testing.
- *
- * @throws ApexEventException on test set up errors.
*/
- @Before
- public void setUp() throws ApexEventException {
- populateEventHandlerParameters(HOST, 5);
+ @BeforeEach
+ void setUp() {
+ populateEventHandlerParameters();
}
- @Test(expected = ApexEventException.class)
- public void testInit_fail() throws ApexEventException {
- apexGrpcProducer.init(PRODUCER_NAME, new EventHandlerParameters());
+ @Test
+ void testInit_fail() {
+ assertThrows(ApexEventException.class,
+ () -> apexGrpcProducer.init(PRODUCER_NAME, new EventHandlerParameters()));
}
@Test
- public void testInit_pass() {
+ void testInit_pass() {
// should not throw an exception
Assertions.assertThatCode(() -> apexGrpcProducer.init(PRODUCER_NAME, eventHandlerParameters))
.doesNotThrowAnyException();
}
@Test
- public void testStop() throws ApexEventException {
+ void testStop() throws ApexEventException {
apexGrpcProducer.init(PRODUCER_NAME, eventHandlerParameters);
// should not throw an exception
- Assertions.assertThatCode(() -> apexGrpcProducer.stop()).doesNotThrowAnyException();
+ Assertions.assertThatCode(apexGrpcProducer::stop).doesNotThrowAnyException();
}
@Test
- public void testSendEvent() throws ApexEventException {
+ void testSendEvent() throws ApexEventException {
apexGrpcProducer.init(PRODUCER_NAME, eventHandlerParameters);
Assertions
.assertThatCode(() -> apexGrpcProducer.sendEvent(123, null, "grpcEvent",
@@ -84,17 +84,17 @@ public class ApexGrpcProducerTest {
.doesNotThrowAnyException();
}
- private void populateEventHandlerParameters(String host, int timeout) {
+ private void populateEventHandlerParameters() {
eventHandlerParameters = new EventHandlerParameters();
GrpcCarrierTechnologyParameters params = new GrpcCarrierTechnologyParameters();
params.setLabel("GRPC");
params.setEventProducerPluginClass(ApexGrpcProducer.class.getName());
params.setEventConsumerPluginClass(ApexGrpcConsumer.class.getName());
- params.setHost(host);
+ params.setHost(ApexGrpcProducerTest.HOST);
params.setPort(3214);
params.setUsername("dummyUser");
params.setPassword("dummyPassword");
- params.setTimeout(timeout);
+ params.setTimeout(5);
eventHandlerParameters.setCarrierTechnologyParameters(params);
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java
index 7c79e95b6..22643fedd 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020, 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,16 +22,15 @@
package org.onap.policy.apex.plugins.event.carrier.grpc;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
-public class GrpcCarrierTechnologyParametersTest {
+class GrpcCarrierTechnologyParametersTest {
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
@@ -39,23 +38,26 @@ public class GrpcCarrierTechnologyParametersTest {
private GrpcCarrierTechnologyParameters params;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
params = new GrpcCarrierTechnologyParameters();
}
@Test
- public void testGrpcCarrierTechnologyParameters_invalid_producer_params() throws ApexEventException {
+ void testGrpcCarrierTechnologyParameters_invalid_producer_params() {
ValidationResult result = params.validate();
assertTrue(result.isValid());
assertThatThrownBy(() -> params.validateGrpcParameters(true))
- .hasMessage("Issues in specifying gRPC Producer parameters:\ntimeout should have a positive value.\n"
- + "port range should be between 1024 and 65535\n" + "host should be specified.\n"
- + "username should be specified.\n" + "password should be specified.\n");
+ .hasMessageContaining("Issues in specifying gRPC Producer parameters")
+ .hasMessageContaining("timeout should have a positive value")
+ .hasMessageContaining("port range should be between 1024 and 65535")
+ .hasMessageContaining("host should be specified")
+ .hasMessageContaining("username should be specified")
+ .hasMessageContaining("password should be specified");
}
@Test
- public void testGrpcCarrierTechnologyParameters_valid() {
+ void testGrpcCarrierTechnologyParameters_valid() {
assertEquals("GRPC", params.getName());
assertEquals(ApexGrpcConsumer.class.getName(), params.getEventConsumerPluginClass());
assertEquals(ApexGrpcProducer.class.getName(), params.getEventProducerPluginClass());
@@ -71,7 +73,7 @@ public class GrpcCarrierTechnologyParametersTest {
}
@Test
- public void testGrpcCarrierTechnologyParameters_invalid_values() {
+ void testGrpcCarrierTechnologyParameters_invalid_values() {
params.setHost(HOST);
params.setPassword(PASSWORD);
params.setTimeout(1000);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
index ab1155641..5ea2fab05 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023-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.
@@ -23,8 +23,8 @@ package org.onap.policy.apex.plugins.event.carrier.jms;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
@@ -34,8 +34,9 @@ import jakarta.jms.Topic;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -47,7 +48,7 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-public class ApexJmsConsumerTest {
+class ApexJmsConsumerTest {
private static final String CONSUMER_NAME = "TestApexJmsConsumer";
private ApexJmsConsumer apexJmsConsumer = null;
@@ -56,38 +57,36 @@ public class ApexJmsConsumerTest {
private ApexEventProducer apexJmsProducer = null;
private JmsCarrierTechnologyParameters jmsCarrierTechnologyParameters = null;
+ AutoCloseable closeable;
+
/**
* Set up testing.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
apexJmsConsumer = Mockito.spy(new ApexJmsConsumer());
consumerParameters = new EventHandlerParameters();
apexJmsProducer = new ApexJmsProducer();
}
@Test
- public void testInitWithNonJmsCarrierTechnologyParameters() {
+ void testInitWithNonJmsCarrierTechnologyParameters() {
consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {
});
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInitWithJmsCarrierTechnologyParameters() {
+ void testInitWithJmsCarrierTechnologyParameters() {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInitNoConnectionFactory() throws NamingException {
+ void testInitNoConnectionFactory() throws NamingException {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -95,14 +94,12 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(null).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(context).when(apexJmsConsumer).getInitialContext();
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInitNoConsumerTopic() throws NamingException {
+ void testInitNoConsumerTopic() throws NamingException {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -113,14 +110,12 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(null).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
Mockito.doReturn(context).when(apexJmsConsumer).getInitialContext();
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInitNoConnection() throws NamingException, JMSException {
+ void testInitNoConnection() throws NamingException, JMSException {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -130,21 +125,18 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doThrow(JMSException.class)
- .when(connectionFactory)
+ closeable = Mockito.doThrow(JMSException.class).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doReturn(context).when(apexJmsConsumer).getInitialContext();
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInitConnectionError() throws NamingException, JMSException {
+ void testInitConnectionError() throws NamingException, JMSException {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -155,21 +147,18 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doReturn(connection)
- .when(connectionFactory)
+ closeable = Mockito.doReturn(connection).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doThrow(JMSException.class).when(connection).start();
Mockito.doReturn(context).when(apexJmsConsumer).getInitialContext();
- assertThatThrownBy(
- () -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver)
- )
+ assertThatThrownBy(() -> apexJmsConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver))
.isInstanceOf(ApexEventException.class);
}
@Test
- public void testInit() throws NamingException, JMSException, ApexEventException {
+ void testInit() throws NamingException, JMSException, ApexEventException {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -180,8 +169,7 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doReturn(connection)
- .when(connectionFactory)
+ closeable = Mockito.doReturn(connection).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doNothing().when(connection).start();
@@ -193,22 +181,22 @@ public class ApexJmsConsumerTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertThatCode(apexJmsConsumer::start).doesNotThrowAnyException();
}
@Test
- public void testGetName() {
+ void testGetName() {
assertNull(apexJmsConsumer.getName());
}
@Test
- public void testGetPeeredReference() {
+ void testGetPeeredReference() {
assertNull(apexJmsConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testSetPeeredReference() {
+ void testSetPeeredReference() {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
apexJmsConsumer, apexJmsProducer);
apexJmsConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference);
@@ -216,19 +204,19 @@ public class ApexJmsConsumerTest {
}
@Test
- public void testRun() {
+ void testRun() {
assertThatThrownBy(apexJmsConsumer::run).isInstanceOf(ApexEventRuntimeException.class);
}
@Test
- public void testOnMessageUninitialized() {
+ void testOnMessageUninitialized() {
Message jmsMessage = null;
assertThatThrownBy(() -> apexJmsConsumer.onMessage(jmsMessage))
.isInstanceOf(ApexEventRuntimeException.class);
}
@Test
- public void testOnMessage() throws JMSException, NamingException, ApexEventException {
+ void testOnMessage() throws JMSException, NamingException, ApexEventException {
// prepare ApexJmsConsumer
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -242,8 +230,7 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doReturn(connection)
- .when(connectionFactory)
+ closeable = Mockito.doReturn(connection).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doNothing().when(connection).start();
@@ -260,7 +247,7 @@ public class ApexJmsConsumerTest {
}
@Test
- public void testConnectionError() throws NamingException, JMSException, ApexEventException {
+ void testConnectionError() throws NamingException, JMSException, ApexEventException {
// prepare ApexJmsConsumer
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -272,8 +259,7 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doReturn(connection)
- .when(connectionFactory)
+ closeable = Mockito.doReturn(connection).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doNothing().when(connection).start();
@@ -290,7 +276,7 @@ public class ApexJmsConsumerTest {
}
@Test
- public void testStop() throws NamingException, JMSException, ApexEventException {
+ void testStop() throws NamingException, JMSException, ApexEventException {
// prepare ApexJmsConsumer
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(jmsCarrierTechnologyParameters);
@@ -302,8 +288,7 @@ public class ApexJmsConsumerTest {
Mockito.doReturn(connectionFactory).when(context).lookup(jmsCarrierTechnologyParameters.getConnectionFactory());
Mockito.doReturn(topic).when(context).lookup(jmsCarrierTechnologyParameters.getConsumerTopic());
- Mockito.doReturn(connection)
- .when(connectionFactory)
+ closeable = Mockito.doReturn(connection).when(connectionFactory)
.createConnection(jmsCarrierTechnologyParameters.getSecurityPrincipal(),
jmsCarrierTechnologyParameters.getSecurityCredentials());
Mockito.doNothing().when(connection).start();
@@ -321,7 +306,14 @@ public class ApexJmsConsumerTest {
}
@Test
- public void testStopNoJmsProperties() {
+ void testStopNoJmsProperties() {
assertThatThrownBy(apexJmsConsumer::stop).isInstanceOf(NullPointerException.class);
}
+
+ @AfterEach
+ void after() throws Exception {
+ if (closeable != null) {
+ closeable.close();
+ }
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
index ffc5c5b1e..35130648f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,8 +25,8 @@ package org.onap.policy.apex.plugins.event.carrier.jms;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
@@ -43,9 +43,9 @@ import java.util.Random;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -71,14 +71,14 @@ public class ApexJmsProducerTest {
* Set up testing.
*
*/
- @Before
+ @BeforeEach
public void setUp() {
apexJmsConsumer = new ApexJmsConsumer();
producerParameters = new EventHandlerParameters();
apexJmsProducer = Mockito.spy(new ApexJmsProducer());
}
- @After
+ @AfterEach
public void tearDown() {
// restore system.out
System.setOut(out);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java
index 36f2e31ce..e8c223482 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019,2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2021, 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,32 +22,31 @@
package org.onap.policy.apex.plugins.event.carrier.jms;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
import javax.naming.Context;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.onap.policy.common.parameters.ValidationResult;
-public class JmsCarrierTechnologyParametersTest {
+class JmsCarrierTechnologyParametersTest {
JmsCarrierTechnologyParameters jmsCarrierTechnologyParameters = null;
- Properties jmsProducerProperties = null;
- Properties jmsConsumerProperties = null;
ValidationResult result = null;
- public static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS";
+ static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS";
- public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getName();
+ static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getName();
- public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getName();
+ static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getName();
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
@@ -61,13 +60,13 @@ public class JmsCarrierTechnologyParametersTest {
*
* @throws Exception on test set up errors.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
jmsCarrierTechnologyParameters = new JmsCarrierTechnologyParameters();
}
@Test
- public void testValidate() {
+ void testValidate() {
result = jmsCarrierTechnologyParameters.validate();
assertNotNull(result);
assertFalse(result.getStatus().isValid());
@@ -82,12 +81,12 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testJmsCarrierTechnologyParameters() {
+ void testJmsCarrierTechnologyParameters() {
assertNotNull(jmsCarrierTechnologyParameters);
}
@Test
- public void testGetJmsProducerProperties() {
+ void testGetJmsProducerProperties() {
Properties producerProperties = jmsCarrierTechnologyParameters.getJmsProducerProperties();
assertNotNull(producerProperties);
@@ -117,7 +116,7 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testGetJmsConsumerProperties() {
+ void testGetJmsConsumerProperties() {
Properties consumerProperties = jmsCarrierTechnologyParameters.getJmsConsumerProperties();
assertNotNull(consumerProperties);
assertNull(consumerProperties.get(Context.SECURITY_CREDENTIALS));
@@ -128,24 +127,24 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testEqualityOfJmsConsumerAndProducerProperties() {
+ void testEqualityOfJmsConsumerAndProducerProperties() {
assertEquals(jmsCarrierTechnologyParameters.getJmsProducerProperties(),
- jmsCarrierTechnologyParameters.getJmsConsumerProperties());
+ jmsCarrierTechnologyParameters.getJmsConsumerProperties());
}
@Test
- public void testGetConnectionFactory() {
+ void testGetConnectionFactory() {
assertEquals(DEFAULT_CONNECTION_FACTORY, jmsCarrierTechnologyParameters.getConnectionFactory());
}
@Test
- public void testSetConnectionFactory() {
+ void testSetConnectionFactory() {
jmsCarrierTechnologyParameters.setConnectionFactory("QueueConnectionFactory");
assertNotEquals(DEFAULT_CONNECTION_FACTORY, jmsCarrierTechnologyParameters.getConnectionFactory());
}
@Test
- public void testSetConsumerTopic() {
+ void testSetConsumerTopic() {
assertEquals(DEFAULT_CONSUMER_TOPIC, jmsCarrierTechnologyParameters.getConsumerTopic());
jmsCarrierTechnologyParameters.setConsumerTopic(null);
result = jmsCarrierTechnologyParameters.validate();
@@ -153,28 +152,28 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetConsumerWaitTime() {
+ void testSetConsumerWaitTime() {
assertEquals(DEFAULT_CONSUMER_WAIT_TIME, jmsCarrierTechnologyParameters.getConsumerWaitTime());
jmsCarrierTechnologyParameters.setConsumerWaitTime(-1);
assertNotEquals(DEFAULT_CONSUMER_WAIT_TIME, jmsCarrierTechnologyParameters.getConsumerWaitTime());
}
@Test
- public void testSetEventConsumerPluginClass() {
+ void testSetEventConsumerPluginClass() {
assertEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventConsumerPluginClass());
jmsCarrierTechnologyParameters.setEventConsumerPluginClass("TestEventConsumerPluginClass");
assertNotEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventConsumerPluginClass());
}
@Test
- public void testSetEventProducerPluginClass() {
+ void testSetEventProducerPluginClass() {
assertEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventProducerPluginClass());
jmsCarrierTechnologyParameters.setEventProducerPluginClass("TestEventProducerPluginClass");
assertNotEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventProducerPluginClass());
}
@Test
- public void testSetLabel() {
+ void testSetLabel() {
assertEquals(JMS_CARRIER_TECHNOLOGY_LABEL, jmsCarrierTechnologyParameters.getLabel());
jmsCarrierTechnologyParameters.setLabel("TestLable");
assertNotEquals(JMS_CARRIER_TECHNOLOGY_LABEL, jmsCarrierTechnologyParameters.getLabel());
@@ -182,14 +181,14 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetObjectMessageSending() {
+ void testSetObjectMessageSending() {
assertTrue(jmsCarrierTechnologyParameters.isObjectMessageSending());
jmsCarrierTechnologyParameters.setObjectMessageSending(!DEFAULT_TO_OBJECT_MSG_SENDING);
assertFalse(jmsCarrierTechnologyParameters.isObjectMessageSending());
}
@Test
- public void testSetProducerTopic() {
+ void testSetProducerTopic() {
assertEquals(DEFAULT_PRODUCER_TOPIC, jmsCarrierTechnologyParameters.getProducerTopic());
jmsCarrierTechnologyParameters.setProducerTopic("");
result = jmsCarrierTechnologyParameters.validate();
@@ -197,7 +196,7 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetProviderUrl() {
+ void testSetProviderUrl() {
assertNull(jmsCarrierTechnologyParameters.getProviderUrl());
jmsCarrierTechnologyParameters.setProviderUrl(null);
result = jmsCarrierTechnologyParameters.validate();
@@ -205,7 +204,7 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetSecurityCredentials() {
+ void testSetSecurityCredentials() {
assertNull(jmsCarrierTechnologyParameters.getSecurityCredentials());
jmsCarrierTechnologyParameters.setSecurityCredentials("");
result = jmsCarrierTechnologyParameters.validate();
@@ -213,7 +212,7 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetSecurityPrincipal() {
+ void testSetSecurityPrincipal() {
assertNull(jmsCarrierTechnologyParameters.getSecurityPrincipal());
jmsCarrierTechnologyParameters.setSecurityPrincipal(null);
result = jmsCarrierTechnologyParameters.validate();
@@ -221,7 +220,7 @@ public class JmsCarrierTechnologyParametersTest {
}
@Test
- public void testSetInitialContextFactory() {
+ void testSetInitialContextFactory() {
assertEquals(DEFAULT_INITIAL_CTXT_FACTORY, jmsCarrierTechnologyParameters.getInitialContextFactory());
@@ -233,8 +232,8 @@ public class JmsCarrierTechnologyParametersTest {
assertNotEquals(DEFAULT_INITIAL_CTXT_FACTORY, jmsCarrierTechnologyParameters.getInitialContextFactory());
}
- @Test(expected = ParameterRuntimeException.class)
- public void testSetName() {
- jmsCarrierTechnologyParameters.setName("TestName");
+ @Test
+ void testSetName() {
+ assertThrows(ParameterRuntimeException.class, () -> jmsCarrierTechnologyParameters.setName("TestName"));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
index 1ef3550e4..f1e420bf0 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,12 +23,13 @@
package org.onap.policy.apex.plugins.event.carrier.kafka;
import static org.assertj.core.api.Assertions.assertThatCode;
-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 static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventProducer;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
@@ -37,7 +38,7 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-public class ApexKafkaConsumerTest {
+class ApexKafkaConsumerTest {
ApexKafkaConsumer apexKafkaConsumer = null;
ApexKafkaConsumer apexKafkaConsumer2 = null;
EventHandlerParameters consumerParameters = null;
@@ -51,13 +52,14 @@ public class ApexKafkaConsumerTest {
*
* @throws ApexEventException on test set up errors.
*/
- @Before
- public void setUp() throws ApexEventException {
+ @BeforeEach
+ void setUp() throws ApexEventException {
apexKafkaConsumer = new ApexKafkaConsumer();
consumerParameters = new EventHandlerParameters();
apexKafkaProducer = new ApexKafkaProducer();
consumerParameters
- .setCarrierTechnologyParameters(new KafkaCarrierTechnologyParameters() {});
+ .setCarrierTechnologyParameters(new KafkaCarrierTechnologyParameters() {
+ });
apexKafkaConsumer.init("TestApexKafkaConsumer", consumerParameters, incomingEventReceiver);
apexKafkaConsumer2 = new ApexKafkaConsumer();
@@ -65,63 +67,66 @@ public class ApexKafkaConsumerTest {
kafkaParameters = new KafkaCarrierTechnologyParameters();
String[][] kafkaProperties = {
{"value.deserializer", "io.confluent.kafka.serializers.KafkaAvroDeserializer"},
- {"schema.registry.url", "[http://test-registory:8080]"}
+ {"schema.registry.url", "[https://test-registory:8080]"}
};
kafkaParameters.setKafkaProperties(kafkaProperties);
consumerParameters2
- .setCarrierTechnologyParameters(kafkaParameters);
+ .setCarrierTechnologyParameters(kafkaParameters);
apexKafkaConsumer2.init("TestApexKafkaConsumer2", consumerParameters2, incomingEventReceiver);
}
@Test
- public void testStart() {
+ void testStart() {
assertThatCode(apexKafkaConsumer::start).doesNotThrowAnyException();
assertThatCode(apexKafkaConsumer2::start).doesNotThrowAnyException();
}
@Test
- public void testGetName() {
+ void testGetName() {
assertEquals("TestApexKafkaConsumer", apexKafkaConsumer.getName());
assertEquals("TestApexKafkaConsumer2", apexKafkaConsumer2.getName());
}
@Test
- public void testGetPeeredReference() {
+ void testGetPeeredReference() {
assertNull(apexKafkaConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
assertNull(apexKafkaConsumer2.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testSetPeeredReference() {
+ void testSetPeeredReference() {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
- apexKafkaConsumer, apexKafkaProducer);
+ apexKafkaConsumer, apexKafkaProducer);
apexKafkaConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference);
assertNotNull(apexKafkaConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
PeeredReference peeredReference2 = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
- apexKafkaConsumer2, apexKafkaProducer);
+ apexKafkaConsumer2, apexKafkaProducer);
apexKafkaConsumer2.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference2);
assertNotNull(apexKafkaConsumer2.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
- @Test(expected = java.lang.NullPointerException.class)
- public void testRun() {
- apexKafkaConsumer.run();
- apexKafkaConsumer2.run();
+ @Test
+ void testRun() {
+ assertThrows(NullPointerException.class, () -> apexKafkaConsumer.run());
+ assertThrows(NullPointerException.class, () -> apexKafkaConsumer2.run());
}
- @Test(expected = java.lang.NullPointerException.class)
- public void testStop() {
- apexKafkaConsumer.stop();
- apexKafkaConsumer2.stop();
+ @Test
+ void testStop() {
+ assertThrows(NullPointerException.class, () -> apexKafkaConsumer.stop());
+ assertThrows(NullPointerException.class, () -> apexKafkaConsumer2.stop());
}
- @Test(expected = ApexEventException.class)
- public void testInitWithNonKafkaCarrierTechnologyParameters() throws ApexEventException {
- consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {});
- apexKafkaConsumer.init("TestApexKafkaConsumer", consumerParameters, incomingEventReceiver);
- apexKafkaConsumer2.init("TestApexKafkaConsumer2", consumerParameters, incomingEventReceiver);
+ @Test
+ void testInitWithNonKafkaCarrierTechnologyParameters() {
+ consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {
+ });
+ assertThrows(ApexEventException.class, () ->
+ apexKafkaConsumer.init("TestApexKafkaConsumer", consumerParameters, incomingEventReceiver));
+ assertThrows(ApexEventException.class, () ->
+ apexKafkaConsumer2.init("TestApexKafkaConsumer2", consumerParameters, incomingEventReceiver));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducerTest.java
index 7300474c7..f5606eb57 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -20,19 +21,20 @@
package org.onap.policy.apex.plugins.event.carrier.kafka;
-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 static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.PeeredReference;
import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-public class ApexKafkaProducerTest {
+class ApexKafkaProducerTest {
ApexKafkaProducer apexKafkaProducer = null;
ApexKafkaConsumer apexKafkaConsumer = null;
EventHandlerParameters producerParameters = null;
@@ -43,37 +45,38 @@ public class ApexKafkaProducerTest {
/**
* Set up testing.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
apexKafkaProducer = new ApexKafkaProducer();
apexKafkaConsumer = new ApexKafkaConsumer();
producerParameters = new EventHandlerParameters();
}
- @Test(expected = ApexEventException.class)
- public void testInit() throws ApexEventException {
- apexKafkaProducer.init("TestApexKafkaProducer", producerParameters);
+ @Test
+ void testInit() {
+ assertThrows(ApexEventException.class,
+ () -> apexKafkaProducer.init("TestApexKafkaProducer", producerParameters));
}
@Test
- public void testGetName() {
+ void testGetName() {
assertNull(apexKafkaProducer.getName());
}
@Test
- public void testGetPeeredReference() {
+ void testGetPeeredReference() {
assertNull(apexKafkaProducer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
}
@Test
- public void testWithProperValues() throws ApexEventException {
+ void testWithProperValues() throws ApexEventException {
producerParameters
- .setCarrierTechnologyParameters(new KafkaCarrierTechnologyParameters() {});
+ .setCarrierTechnologyParameters(new KafkaCarrierTechnologyParameters() { });
synchronousEventCache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS,
- apexKafkaConsumer, apexKafkaProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
+ apexKafkaConsumer, apexKafkaProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
apexKafkaProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS,
- synchronousEventCache);
+ synchronousEventCache);
apexKafkaProducer.init("TestApexKafkaProducer", producerParameters);
assertEquals("TestApexKafkaProducer", apexKafkaProducer.getName());
assertNotNull(apexKafkaProducer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParametersTest.java
index 6b0f7d920..11bafc9b1 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/test/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParametersTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,17 +22,18 @@
package org.onap.policy.apex.plugins.event.carrier.kafka;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class KafkaCarrierTechnologyParametersTest {
+class KafkaCarrierTechnologyParametersTest {
@Test
- public void testKafkaCarrierTechnologyParameters() {
+ void testKafkaCarrierTechnologyParameters() {
KafkaCarrierTechnologyParameters kafkaCarrierTechnologyParameters = new KafkaCarrierTechnologyParameters();
assertNotNull(kafkaCarrierTechnologyParameters);
@@ -40,17 +41,17 @@ public class KafkaCarrierTechnologyParametersTest {
}
@Test
- public void testGetKafkaProducerProperties() {
+ void testGetKafkaProducerProperties() {
KafkaCarrierTechnologyParameters kafkaCarrierTechnologyParameters = new KafkaCarrierTechnologyParameters();
Properties kafkaProducerProperties = kafkaCarrierTechnologyParameters.getKafkaProducerProperties();
assertNotNull(kafkaProducerProperties);
assertEquals("localhost:9092", kafkaProducerProperties.get("bootstrap.servers"));
assertEquals("1", kafkaProducerProperties.get("linger.ms"));
- assertEquals(null, kafkaProducerProperties.get("group.id"));
- assertEquals(null, kafkaProducerProperties.get("Property0"));
- assertEquals(null, kafkaProducerProperties.get("Property1"));
- assertEquals(null, kafkaProducerProperties.get("Property2"));
+ assertNull(kafkaProducerProperties.get("group.id"));
+ assertNull(kafkaProducerProperties.get("Property0"));
+ assertNull(kafkaProducerProperties.get("Property1"));
+ assertNull(kafkaProducerProperties.get("Property2"));
// @formatter:off
String[][] kafkaProperties = {
@@ -68,24 +69,24 @@ public class KafkaCarrierTechnologyParametersTest {
assertNotNull(kafkaProducerProperties);
assertEquals("localhost:9092", kafkaProducerProperties.get("bootstrap.servers"));
assertEquals("1", kafkaProducerProperties.get("linger.ms"));
- assertEquals(null, kafkaProducerProperties.get("group.id"));
+ assertNull(kafkaProducerProperties.get("group.id"));
assertEquals("Value0", kafkaProducerProperties.get("Property0"));
assertEquals("Value1", kafkaProducerProperties.get("Property1"));
- assertEquals(null, kafkaProducerProperties.get("Property2"));
+ assertNull(kafkaProducerProperties.get("Property2"));
}
@Test
- public void testGetKafkaConsumerProperties() {
+ void testGetKafkaConsumerProperties() {
KafkaCarrierTechnologyParameters kafkaCarrierTechnologyParameters = new KafkaCarrierTechnologyParameters();
Properties kafkaConsumerProperties = kafkaCarrierTechnologyParameters.getKafkaConsumerProperties();
assertNotNull(kafkaConsumerProperties);
assertEquals("localhost:9092", kafkaConsumerProperties.get("bootstrap.servers"));
assertEquals("default-group-id", kafkaConsumerProperties.get("group.id"));
- assertEquals(null, kafkaConsumerProperties.get("linger.ms"));
- assertEquals(null, kafkaConsumerProperties.get("Property0"));
- assertEquals(null, kafkaConsumerProperties.get("Property1"));
- assertEquals(null, kafkaConsumerProperties.get("Property2"));
+ assertNull(kafkaConsumerProperties.get("linger.ms"));
+ assertNull(kafkaConsumerProperties.get("Property0"));
+ assertNull(kafkaConsumerProperties.get("Property1"));
+ assertNull(kafkaConsumerProperties.get("Property2"));
// @formatter:off
String[][] kafkaProperties = {
@@ -103,204 +104,30 @@ public class KafkaCarrierTechnologyParametersTest {
assertNotNull(kafkaConsumerProperties);
assertEquals("localhost:9092", kafkaConsumerProperties.get("bootstrap.servers"));
assertEquals("default-group-id", kafkaConsumerProperties.get("group.id"));
- assertEquals(null, kafkaConsumerProperties.get("linger.ms"));
+ assertNull(kafkaConsumerProperties.get("linger.ms"));
assertEquals("Value0", kafkaConsumerProperties.get("Property0"));
assertEquals("Value1", kafkaConsumerProperties.get("Property1"));
- assertEquals(null, kafkaConsumerProperties.get("Property2"));
+ assertNull(kafkaConsumerProperties.get("Property2"));
}
@Test
- public void testValidate() {
+ void testValidate() {
KafkaCarrierTechnologyParameters kafkaCarrierTechnologyParameters = new KafkaCarrierTechnologyParameters();
assertNotNull(kafkaCarrierTechnologyParameters);
assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
- String origStringValue = kafkaCarrierTechnologyParameters.getBootstrapServers();
- kafkaCarrierTechnologyParameters.setBootstrapServers(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setBootstrapServers(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getAcks();
- kafkaCarrierTechnologyParameters.setAcks(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setAcks(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getGroupId();
- kafkaCarrierTechnologyParameters.setGroupId(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setGroupId(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getProducerTopic();
- kafkaCarrierTechnologyParameters.setProducerTopic(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setProducerTopic(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- int origIntValue = kafkaCarrierTechnologyParameters.getRetries();
- kafkaCarrierTechnologyParameters.setRetries(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setRetries(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origIntValue = kafkaCarrierTechnologyParameters.getBatchSize();
- kafkaCarrierTechnologyParameters.setBatchSize(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setBatchSize(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origIntValue = kafkaCarrierTechnologyParameters.getLingerTime();
- kafkaCarrierTechnologyParameters.setLingerTime(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setLingerTime(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- long origLongValue = kafkaCarrierTechnologyParameters.getBufferMemory();
- kafkaCarrierTechnologyParameters.setBufferMemory(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setBufferMemory(origLongValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origIntValue = kafkaCarrierTechnologyParameters.getAutoCommitTime();
- kafkaCarrierTechnologyParameters.setAutoCommitTime(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setAutoCommitTime(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origIntValue = kafkaCarrierTechnologyParameters.getSessionTimeout();
- kafkaCarrierTechnologyParameters.setSessionTimeout(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setSessionTimeout(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origIntValue = kafkaCarrierTechnologyParameters.getConsumerPollTime();
- kafkaCarrierTechnologyParameters.setConsumerPollTime(-1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setConsumerPollTime(origIntValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getKeySerializer();
- kafkaCarrierTechnologyParameters.setKeySerializer(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKeySerializer(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getValueSerializer();
- kafkaCarrierTechnologyParameters.setValueSerializer(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setValueSerializer(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getKeyDeserializer();
- kafkaCarrierTechnologyParameters.setKeyDeserializer(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKeyDeserializer(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- origStringValue = kafkaCarrierTechnologyParameters.getValueDeserializer();
- kafkaCarrierTechnologyParameters.setValueDeserializer(" ");
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setValueDeserializer(origStringValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- String[] origConsumerTopcList = kafkaCarrierTechnologyParameters.getConsumerTopicList();
- kafkaCarrierTechnologyParameters.setConsumerTopicList(null);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setConsumerTopicList(origConsumerTopcList);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- kafkaCarrierTechnologyParameters.setConsumerTopicList(new String[0]);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setConsumerTopicList(origConsumerTopcList);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- String[] blankStringList = { null, "" };
- kafkaCarrierTechnologyParameters.setConsumerTopicList(blankStringList);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setConsumerTopicList(origConsumerTopcList);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- String[][] origKafkaProperties = kafkaCarrierTechnologyParameters.getKafkaProperties();
- kafkaCarrierTechnologyParameters.setKafkaProperties(null);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
+ assertValidateStringProperties(kafkaCarrierTechnologyParameters);
- kafkaCarrierTechnologyParameters.setKafkaProperties(new String[0][0]);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
+ assertValidateNumberProperties(kafkaCarrierTechnologyParameters);
- // @formatter:offkafkaCarrierTechnologyParameters
- String[][] kafkaProperties0 = {
- {
- null, "Value0"
- }
- };
- // @formatter:on
+ assertValidateTopicList(kafkaCarrierTechnologyParameters);
- kafkaCarrierTechnologyParameters.setKafkaProperties(kafkaProperties0);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- // @formatter:off
- String[][] kafkaProperties1 = {
- {
- "Property1", null
- }
- };
- // @formatter:on
-
- kafkaCarrierTechnologyParameters.setKafkaProperties(kafkaProperties1);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- // @formatter:off
- String[][] kafkaProperties2 = {
- {
- "Property1", null
- }
- };
- // @formatter:on
-
- kafkaCarrierTechnologyParameters.setKafkaProperties(kafkaProperties2);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
-
- // @formatter:off
- String[][] kafkaPropertiesWithEmptyValue = {
- {
- "Property1", ""
- }
- };
- // @formatter:on
-
- kafkaCarrierTechnologyParameters.setKafkaProperties(kafkaPropertiesWithEmptyValue);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
-
- // @formatter:off
- String[][] kafkaProperties3 = {
- {
- "Property1", "Value0", "Value1"
- }
- };
- // @formatter:on
-
- kafkaCarrierTechnologyParameters.setKafkaProperties(kafkaProperties3);
- assertFalse(kafkaCarrierTechnologyParameters.validate().isValid());
- kafkaCarrierTechnologyParameters.setKafkaProperties(origKafkaProperties);
- assertTrue(kafkaCarrierTechnologyParameters.validate().isValid());
+ assertValidateKafkaProperties(kafkaCarrierTechnologyParameters);
}
@Test
- public void testExplicitImplicit() {
+ void testExplicitImplicit() {
KafkaCarrierTechnologyParameters kafkaCtp = new KafkaCarrierTechnologyParameters();
assertNotNull(kafkaCtp);
@@ -378,4 +205,194 @@ public class KafkaCarrierTechnologyParametersTest {
kafkaCtp.setKafkaProperties(kafkaProperties3);
assertEquals("localhost:7777", kafkaCtp.getKafkaConsumerProperties().get("bootstrap.servers"));
}
+
+ private static void assertValidateStringProperties(KafkaCarrierTechnologyParameters kafkaParameters) {
+ String origStringValue = kafkaParameters.getBootstrapServers();
+ kafkaParameters.setBootstrapServers(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setBootstrapServers(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getAcks();
+ kafkaParameters.setAcks(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setAcks(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getGroupId();
+ kafkaParameters.setGroupId(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setGroupId(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getProducerTopic();
+ kafkaParameters.setProducerTopic(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setProducerTopic(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getKeySerializer();
+ kafkaParameters.setKeySerializer(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setKeySerializer(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getValueSerializer();
+ kafkaParameters.setValueSerializer(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setValueSerializer(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getKeyDeserializer();
+ kafkaParameters.setKeyDeserializer(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setKeyDeserializer(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origStringValue = kafkaParameters.getValueDeserializer();
+ kafkaParameters.setValueDeserializer(" ");
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setValueDeserializer(origStringValue);
+ assertTrue(kafkaParameters.validate().isValid());
+ }
+
+ private static void assertValidateTopicList(KafkaCarrierTechnologyParameters kafkaParameters) {
+ String[] origConsumerTopicList = kafkaParameters.getConsumerTopicList();
+ kafkaParameters.setConsumerTopicList(null);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setConsumerTopicList(origConsumerTopicList);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ kafkaParameters.setConsumerTopicList(new String[0]);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setConsumerTopicList(origConsumerTopicList);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ String[] blankStringList = { null, "" };
+ kafkaParameters.setConsumerTopicList(blankStringList);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setConsumerTopicList(origConsumerTopicList);
+ assertTrue(kafkaParameters.validate().isValid());
+ }
+
+ private static void assertValidateNumberProperties(KafkaCarrierTechnologyParameters kafkaParameters) {
+ int origIntValue = kafkaParameters.getRetries();
+ kafkaParameters.setRetries(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setRetries(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origIntValue = kafkaParameters.getBatchSize();
+ kafkaParameters.setBatchSize(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setBatchSize(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origIntValue = kafkaParameters.getLingerTime();
+ kafkaParameters.setLingerTime(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setLingerTime(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ long origLongValue = kafkaParameters.getBufferMemory();
+ kafkaParameters.setBufferMemory(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setBufferMemory(origLongValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origIntValue = kafkaParameters.getAutoCommitTime();
+ kafkaParameters.setAutoCommitTime(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setAutoCommitTime(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origIntValue = kafkaParameters.getSessionTimeout();
+ kafkaParameters.setSessionTimeout(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setSessionTimeout(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ origIntValue = kafkaParameters.getConsumerPollTime();
+ kafkaParameters.setConsumerPollTime(-1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setConsumerPollTime(origIntValue);
+ assertTrue(kafkaParameters.validate().isValid());
+ }
+
+ private static void assertValidateKafkaProperties(KafkaCarrierTechnologyParameters kafkaParameters) {
+ String[][] origKafkaProperties = kafkaParameters.getKafkaProperties();
+ kafkaParameters.setKafkaProperties(null);
+ assertTrue(kafkaParameters.validate().isValid());
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ kafkaParameters.setKafkaProperties(new String[0][0]);
+ assertTrue(kafkaParameters.validate().isValid());
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ // @formatter:off
+ String[][] kafkaProperties0 = {
+ {
+ null, "Value0"
+ }
+ };
+ // @formatter:on
+
+ kafkaParameters.setKafkaProperties(kafkaProperties0);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ // @formatter:off
+ String[][] kafkaProperties1 = {
+ {
+ "Property1", null
+ }
+ };
+ // @formatter:on
+
+ kafkaParameters.setKafkaProperties(kafkaProperties1);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ // @formatter:off
+ String[][] kafkaProperties2 = {
+ {
+ "Property1", null
+ }
+ };
+ // @formatter:on
+
+ kafkaParameters.setKafkaProperties(kafkaProperties2);
+ assertFalse(kafkaParameters.validate().isValid());
+
+ // @formatter:off
+ String[][] kafkaPropertiesWithEmptyValue = {
+ {
+ "Property1", ""
+ }
+ };
+ // @formatter:on
+
+ kafkaParameters.setKafkaProperties(kafkaPropertiesWithEmptyValue);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+
+ // @formatter:off
+ String[][] kafkaProperties3 = {
+ {
+ "Property1", "Value0", "Value1"
+ }
+ };
+ // @formatter:on
+
+ kafkaParameters.setKafkaProperties(kafkaProperties3);
+ assertFalse(kafkaParameters.validate().isValid());
+ kafkaParameters.setKafkaProperties(origKafkaProperties);
+ assertTrue(kafkaParameters.validate().isValid());
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java
index 61155c8cf..b3a6bca06 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,9 +24,10 @@ package org.onap.policy.apex.plugins.event.carrier.restclient;
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.assertTrue;
+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.assertTrue;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.Invocation.Builder;
@@ -35,22 +36,23 @@ import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
/**
- * This class tests the ApexRestClientConusmer class.
- *
+ * This class tests the ApexRestClientConsumer class.
*/
-@RunWith(MockitoJUnitRunner.class)
-public class ApexRestClientConusmerTest {
+@ExtendWith(MockitoExtension.class)
+class ApexRestClientConsumerTest {
private final PrintStream stdout = System.out;
@Mock
@@ -65,13 +67,13 @@ public class ApexRestClientConusmerTest {
@Mock
private Response responseMock;
- @After
- public void after() {
+ @AfterEach
+ void after() {
System.setOut(stdout);
}
@Test
- public void testApexRestClientConsumerErrors() throws ApexEventException {
+ void testApexRestClientConsumerErrors() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -99,7 +101,7 @@ public class ApexRestClientConusmerTest {
assertEquals("RestClientConsumer", arcc.getName());
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
@@ -120,7 +122,7 @@ public class ApexRestClientConusmerTest {
}
@Test
- public void testApexRestClientConsumerHttpError() throws ApexEventException {
+ void testApexRestClientConsumerHttpError() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -139,7 +141,7 @@ public class ApexRestClientConusmerTest {
assertEquals("RestClientConsumer", arcc.getName());
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
Mockito.doReturn(responseMock).when(builderMock).get();
@@ -159,7 +161,7 @@ public class ApexRestClientConusmerTest {
}
@Test
- public void testApexRestClientConsumerJsonError() throws ApexEventException {
+ void testApexRestClientConsumerJsonError() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -175,7 +177,7 @@ public class ApexRestClientConusmerTest {
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
@@ -197,7 +199,7 @@ public class ApexRestClientConusmerTest {
}
@Test
- public void testApexRestClientConsumerJsonEmpty() throws ApexEventException {
+ void testApexRestClientConsumerJsonEmpty() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -214,7 +216,7 @@ public class ApexRestClientConusmerTest {
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
@@ -242,7 +244,7 @@ public class ApexRestClientConusmerTest {
}
@Test
- public void testApexRestClientConsumerJsonOk() throws ApexEventException {
+ void testApexRestClientConsumerJsonOk() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -259,7 +261,7 @@ public class ApexRestClientConusmerTest {
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
@@ -278,7 +280,7 @@ public class ApexRestClientConusmerTest {
}
@Test
- public void testApexRestClientConsumerInvalidStatusCode() throws ApexEventException {
+ void testApexRestClientConsumerInvalidStatusCode() throws ApexEventException {
ApexRestClientConsumer arcc = new ApexRestClientConsumer();
assertNotNull(arcc);
@@ -295,7 +297,7 @@ public class ApexRestClientConusmerTest {
arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
index cc5ebbb9f..ec454af00 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,19 +23,23 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+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 jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.Invocation.Builder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Response;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
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.SynchronousEventCache;
@@ -47,8 +51,8 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
* Test the ApexRestClientProducer class.
*
*/
-@RunWith(MockitoJUnitRunner.class)
-public class ApexRestClientProducerTest {
+@ExtendWith(MockitoExtension.class)
+class ApexRestClientProducerTest {
@Mock
private Client httpClientMock;
@@ -61,8 +65,10 @@ public class ApexRestClientProducerTest {
@Mock
private Response responseMock;
+ AutoCloseable closeable;
+
@Test
- public void testApexRestClientProducerErrors() throws ApexEventException {
+ void testApexRestClientProducerErrors() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -84,7 +90,7 @@ public class ApexRestClientProducerTest {
assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
assertEquals("RestClientConsumer", arcp.getName());
arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
arcp.stop();
rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
@@ -92,7 +98,7 @@ public class ApexRestClientProducerTest {
assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
assertEquals("RestClientConsumer", arcp.getName());
arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
arcp.stop();
rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT);
@@ -100,12 +106,12 @@ public class ApexRestClientProducerTest {
assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod());
assertEquals("RestClientConsumer", arcp.getName());
arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
- assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
arcp.stop();
}
@Test
- public void testApexRestClientProducerPutEvent() throws ApexEventException {
+ void testApexRestClientProducerPutEvent() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -120,7 +126,7 @@ public class ApexRestClientProducerTest {
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
+ closeable = Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
@@ -131,7 +137,7 @@ public class ApexRestClientProducerTest {
}
@Test
- public void testApexRestClientProducerPostEventFail() throws ApexEventException {
+ void testApexRestClientProducerPostEventFail() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -160,7 +166,7 @@ public class ApexRestClientProducerTest {
}
@Test
- public void testApexRestClientProducerPostEventOK() throws ApexEventException {
+ void testApexRestClientProducerPostEventOK() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -179,7 +185,7 @@ public class ApexRestClientProducerTest {
properties.put("tag", "exist");
properties.put("key", "that");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
+ closeable = Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target("http://some.place.that.does.not/exist");
@@ -190,7 +196,7 @@ public class ApexRestClientProducerTest {
}
@Test
- public void testApexRestClientProducerPostEventAccepted() throws ApexEventException {
+ void testApexRestClientProducerPostEventAccepted() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -219,7 +225,7 @@ public class ApexRestClientProducerTest {
}
@Test
- public void testApexRestClientProducerPostEventCache() throws ApexEventException {
+ void testApexRestClientProducerPostEventCache() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -251,39 +257,7 @@ public class ApexRestClientProducerTest {
}
@Test
- public void testApexRestClientProducerPostEventCacheTrace() throws ApexEventException {
- ApexRestClientProducer arcp = new ApexRestClientProducer();
- assertNotNull(arcp);
-
- EventHandlerParameters producerParameters = new EventHandlerParameters();
- RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
- producerParameters.setCarrierTechnologyParameters(rcctp);
-
- rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
-
- ApexEventConsumer consumer = new ApexFileEventConsumer();
- SynchronousEventCache cache =
- new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, 1000);
- arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache);
- assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
- arcp.init("RestClientConsumer", producerParameters);
- assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
- assertEquals("RestClientConsumer", arcp.getName());
-
- rcctp.setUrl("http://some.place.that.does.not/exist");
- Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
- Mockito.doReturn(builderMock).when(targetMock).request("application/json");
- Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
- Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
- arcp.setClient(httpClientMock);
-
- arcp.sendEvent(123, null, "EventName", "This is an Event");
- arcp.stop();
- }
-
- @Test
- public void testApexRestClientProducerHttpError() throws ApexEventException {
+ void testApexRestClientProducerHttpError() throws ApexEventException {
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
@@ -298,7 +272,7 @@ public class ApexRestClientProducerTest {
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ closeable = Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
@@ -308,4 +282,11 @@ public class ApexRestClientProducerTest {
.hasMessageContaining("send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" "
+ "failed with status code 400");
}
+
+ @AfterEach
+ void after() throws Exception {
+ if (closeable != null) {
+ closeable.close();
+ }
+ }
}
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 58d265a97..4539c5181 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
@@ -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.
* ================================================================================
@@ -25,12 +25,13 @@ package org.onap.policy.apex.plugins.event.carrier.restclient;
import static org.assertj.core.api.Assertions.assertThatCode;
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;
@@ -39,10 +40,10 @@ import org.onap.policy.common.parameters.ParameterException;
/**
* Test REST client carrier technology parameters.
*/
-public class RestClientCarrierTechnologyParametersTest {
+class RestClientCarrierTechnologyParametersTest {
@Test
- public void testRestClientCarrierTechnologyParametersBadList() {
+ void testRestClientCarrierTechnologyParametersBadList() {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json");
arguments.setRelativeFileRoot(".");
@@ -55,7 +56,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testRestClientCarrierTechnologyParametersNotKvPairs() {
+ void testRestClientCarrierTechnologyParametersNotKvPairs() {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json");
arguments.setRelativeFileRoot(".");
@@ -67,7 +68,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testRestClientCarrierTechnologyParametersNulls() {
+ void testRestClientCarrierTechnologyParametersNulls() {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json");
arguments.setRelativeFileRoot(".");
@@ -79,7 +80,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testRestClientCarrierTechnologyParameterFilterInvalid() {
+ void testRestClientCarrierTechnologyParameterFilterInvalid() {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPFilterInvalid.json");
arguments.setRelativeFileRoot(".");
@@ -92,7 +93,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testRestClientCarrierTechnologyParametersOk() throws ParameterException {
+ void testRestClientCarrierTechnologyParametersOk() throws ParameterException {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json");
arguments.setRelativeFileRoot(".");
@@ -111,11 +112,11 @@ public class RestClientCarrierTechnologyParametersTest {
assertEquals("fff", rrctp1.getHttpHeadersAsMultivaluedMap().get("eee").get(0));
rrctp1.setHttpHeaders(null);
- assertEquals(null, rrctp1.getHttpHeadersAsMultivaluedMap());
+ assertNull(rrctp1.getHttpHeadersAsMultivaluedMap());
}
@Test
- public void testRestClientCarrierTechnologyHttpCodeFilterOk() throws ParameterException {
+ void testRestClientCarrierTechnologyHttpCodeFilterOk() throws ParameterException {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json");
arguments.setRelativeFileRoot(".");
@@ -128,7 +129,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testGettersAndSetters() {
+ void testGettersAndSetters() {
RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters();
rrctp.setUrl("http://some.where");
@@ -168,7 +169,7 @@ public class RestClientCarrierTechnologyParametersTest {
}
@Test
- public void testUrlValidation() {
+ void testUrlValidation() {
RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters();
rrctp.setUrl("http://some.where.no.tag.in.url");
@@ -186,29 +187,27 @@ public class RestClientCarrierTechnologyParametersTest {
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/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"));
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
index 1ec0d52bb..b2e158f1a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/AccessControlFilterTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021, 2023 Nordix Foundation.
+ * Copyright (C) 2021, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerResponseContext;
@@ -29,16 +29,16 @@ import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import java.io.IOException;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class AccessControlFilterTest {
+@ExtendWith(MockitoExtension.class)
+class AccessControlFilterTest {
private AccessControlFilter acf;
@@ -47,13 +47,13 @@ public class AccessControlFilterTest {
@Mock
private ContainerResponseContext responseContext;
- @Before
+ @BeforeEach
public void beforeEach() {
acf = new AccessControlFilter();
}
@Test
- public void filterAddToExisting() throws IOException {
+ void filterAddToExisting() throws IOException {
// prepare mocks
final String origin = RandomStringUtils.randomAlphanumeric(14, 16);
final MultivaluedHashMap<String, Object> map = new MultivaluedHashMap<>();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
index 5f7cb257b..291a97c70 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023-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.
@@ -21,84 +21,84 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.lang.reflect.Field;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer;
import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.utils.network.NetworkUtil;
-public class ApexRestServerConsumerTest {
+class ApexRestServerConsumerTest {
ApexRestServerConsumer apexRestServerConsumer = null;
EventHandlerParameters consumerParameters = null;
ApexEventReceiver incomingEventReceiver = null;
ApexRestServerProducer apexRestServerProducer = null;
RestServerCarrierTechnologyParameters restServerCarrierTechnologyParameters = null;
- SynchronousEventCache synchronousEventCache = null;
+
+ AutoCloseable closeable;
/**
* Set up testing.
- *
- * @throws Exception on test set up errors.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
apexRestServerConsumer = new ApexRestServerConsumer();
consumerParameters = new EventHandlerParameters();
apexRestServerProducer = new ApexRestServerProducer();
apexRestServerConsumer.start();
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
apexRestServerConsumer.stop();
}
- @Test(expected = ApexEventException.class)
- public void testInitWithNonWebSocketCarrierTechnologyParameters() throws ApexEventException {
- consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {});
- apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters,
- incomingEventReceiver);
+ @Test
+ void testInitWithNonWebSocketCarrierTechnologyParameters() {
+ consumerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {
+ });
+ assertThrows(ApexEventException.class, () ->
+ apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters, incomingEventReceiver));
}
- @Test(expected = ApexEventException.class)
- public void testInitWithWebSocketCarrierTechnologyParameters() throws ApexEventException {
+ @Test
+ void testInitWithWebSocketCarrierTechnologyParameters() {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
consumerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
- apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters,
- incomingEventReceiver);
+ assertThrows(ApexEventException.class, () ->
+ apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters, incomingEventReceiver));
}
- @Test(expected = ApexEventException.class)
- public void testInitWithSynchronousMode() throws ApexEventException, SecurityException, IllegalArgumentException {
+ @Test
+ void testInitWithSynchronousMode() throws SecurityException, IllegalArgumentException {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
restServerCarrierTechnologyParameters.setStandalone(true);
consumerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
consumerParameters.setPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS, true);
- apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters,
- incomingEventReceiver);
+
+ assertThrows(ApexEventException.class, () -> apexRestServerConsumer.init("TestApexRestServerConsumer",
+ consumerParameters, incomingEventReceiver));
}
- @Test(expected = IllegalArgumentException.class)
- public void testInitWithSynchronousModeAndProperValues()
- throws ApexEventException, SecurityException, IllegalArgumentException {
+ @Test
+ void testInitWithSynchronousModeAndProperValues() throws SecurityException, IllegalArgumentException {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
@@ -109,12 +109,14 @@ public class ApexRestServerConsumerTest {
consumerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
consumerParameters.setPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS, true);
- apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters,
- incomingEventReceiver);
+
+ assertThrows(IllegalArgumentException.class,
+ () -> apexRestServerConsumer.init("TestApexRestServerConsumer", consumerParameters,
+ incomingEventReceiver));
}
@Test
- public void testInitAndStop() throws ApexEventException, IOException {
+ void testInitAndStop() throws ApexEventException, IOException {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
restServerCarrierTechnologyParameters.setStandalone(true);
@@ -138,39 +140,39 @@ public class ApexRestServerConsumerTest {
}
@Test
- public void testGetName() {
+ void testGetName() {
assertNull(apexRestServerConsumer.getName());
}
@Test
- public void testGetPeeredReference() {
+ void testGetPeeredReference() {
assertNull(apexRestServerConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testSetPeeredReference() {
+ void testSetPeeredReference() {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
- apexRestServerConsumer, apexRestServerProducer);
+ apexRestServerConsumer, apexRestServerProducer);
apexRestServerConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR,
- peeredReference);
+ peeredReference);
assertNotNull(apexRestServerConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testReceiveEvent() throws ApexEventException {
+ void testReceiveEvent() {
Response response = apexRestServerConsumer.receiveEvent("");
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ response.close();
}
- @Test(expected = NullPointerException.class)
- public void testReceiveEventWithNonDefaultValues()
- throws ApexEventException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException {
+ @Test
+ void testReceiveEventWithNonDefaultValues() throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
- apexRestServerConsumer, apexRestServerProducer);
+ apexRestServerConsumer, apexRestServerProducer);
apexRestServerConsumer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR,
- peeredReference);
+ peeredReference);
ApexEventReceiver apexEventReceiver = new SupportApexEventReceiver();
@@ -178,8 +180,14 @@ public class ApexRestServerConsumerTest {
Field field = ApexPluginsEventConsumer.class.getDeclaredField("name");
field.setAccessible(true);
field.set(apexRestServerConsumer, "TestApexRestServerConsumer");
+ assertThrows(NullPointerException.class, () ->
+ closeable = apexRestServerConsumer.receiveEvent("TestApexRestServerConsumer"));
+ }
- apexRestServerConsumer.receiveEvent("TestApexRestServerConsumer");
-
+ @AfterEach
+ void after() throws Exception {
+ if (closeable != null) {
+ closeable.close();
+ }
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducerTest.java
index 34992ff1d..435af0996 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 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.
@@ -21,34 +21,32 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.Field;
import java.util.Random;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEventException;
-import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
import org.onap.policy.apex.service.engine.event.PeeredReference;
import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-public class ApexRestServerProducerTest {
+class ApexRestServerProducerTest {
ApexRestServerProducer apexRestServerProducer = null;
EventHandlerParameters producerParameters = null;
- ApexEventReceiver incomingEventReceiver = null;
ApexRestServerConsumer apexRestServerConsumer = null;
RestServerCarrierTechnologyParameters restServerCarrierTechnologyParameters = null;
- SynchronousEventCache synchronousEventCache = null;
Random random = new Random();
/**
@@ -56,35 +54,38 @@ public class ApexRestServerProducerTest {
*
* @throws Exception on test set up errors.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
apexRestServerConsumer = new ApexRestServerConsumer();
producerParameters = new EventHandlerParameters();
apexRestServerProducer = new ApexRestServerProducer();
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
apexRestServerProducer.stop();
}
- @Test(expected = ApexEventException.class)
- public void testInitWithNonWebSocketCarrierTechnologyParameters() throws ApexEventException {
- producerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {});
- apexRestServerProducer.init("TestApexRestServerProducer", producerParameters);
+ @Test
+ void testInitWithNonWebSocketCarrierTechnologyParameters() {
+ producerParameters.setCarrierTechnologyParameters(new CarrierTechnologyParameters() {
+ });
+ assertThrows(ApexEventException.class, () ->
+ apexRestServerProducer.init("TestApexRestServerProducer", producerParameters));
}
- @Test(expected = ApexEventException.class)
- public void testInitWithWebSocketCarrierTechnologyParameters() throws ApexEventException {
+ @Test
+ void testInitWithWebSocketCarrierTechnologyParameters() {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
producerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
- apexRestServerProducer.init("TestApexRestServerProducer", producerParameters);
+ assertThrows(ApexEventException.class, () ->
+ apexRestServerProducer.init("TestApexRestServerProducer", producerParameters));
}
- @Test(expected = ApexEventException.class)
- public void testInitWithNonDefaultValue() throws ApexEventException, NoSuchFieldException,
- SecurityException, IllegalArgumentException, IllegalAccessException {
+ @Test
+ void testInitWithNonDefaultValue() throws NoSuchFieldException,
+ SecurityException, IllegalArgumentException, IllegalAccessException {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host");
field.setAccessible(true);
@@ -93,11 +94,12 @@ public class ApexRestServerProducerTest {
field.setAccessible(true);
field.set(restServerCarrierTechnologyParameters, 65535);
producerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
- apexRestServerProducer.init("TestApexRestServerProducer", producerParameters);
+ assertThrows(ApexEventException.class, () ->
+ apexRestServerProducer.init("TestApexRestServerProducer", producerParameters));
}
@Test
- public void testInitWithSynchronousMode() throws ApexEventException {
+ void testInitWithSynchronousMode() throws ApexEventException {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
producerParameters.setCarrierTechnologyParameters(restServerCarrierTechnologyParameters);
producerParameters.setPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS, true);
@@ -106,26 +108,26 @@ public class ApexRestServerProducerTest {
}
@Test
- public void testGetName() {
+ void testGetName() {
assertNull(apexRestServerProducer.getName());
}
@Test
- public void testGetPeeredReference() {
+ void testGetPeeredReference() {
assertNull(apexRestServerProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testSetPeeredReference() {
+ void testSetPeeredReference() {
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR,
- apexRestServerConsumer, apexRestServerProducer);
+ apexRestServerConsumer, apexRestServerProducer);
apexRestServerProducer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR,
- peeredReference);
+ peeredReference);
assertNotNull(apexRestServerProducer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR));
}
@Test
- public void testSendEventNotExistingEventToApex() {
+ void testSendEventNotExistingEventToApex() {
final long executionId = random.nextLong();
final String eventName = RandomStringUtils.randomAlphabetic(7);
final Object event = new Object();
@@ -143,7 +145,7 @@ public class ApexRestServerProducerTest {
}
@Test
- public void testSendEvent() {
+ void testSendEvent() {
final long executionId = random.nextLong();
final String eventName = RandomStringUtils.randomAlphabetic(7);
final Object expected = new Object();
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
index ef78d3211..ab7a54cdd 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. 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");
@@ -23,16 +23,16 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
-public class RestServerCarrierTechnologyParametersTest {
+class RestServerCarrierTechnologyParametersTest {
RestServerCarrierTechnologyParameters restServerCarrierTechnologyParameters = null;
ValidationResult result = null;
@@ -40,28 +40,27 @@ public class RestServerCarrierTechnologyParametersTest {
/**
* Set up testing.
*
- * @throws Exception on test set up errors.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
}
@Test
- public void testRestServerCarrierTechnologyParameters() {
+ void testRestServerCarrierTechnologyParameters() {
assertNotNull(restServerCarrierTechnologyParameters);
assertFalse(restServerCarrierTechnologyParameters.isStandalone());
}
@Test
- public void testValidate() {
+ void testValidate() {
result = restServerCarrierTechnologyParameters.validate();
assertNotNull(result);
assertTrue(result.isValid());
}
@Test
- public void testValidateWithNonDefaultValues() throws NoSuchFieldException, SecurityException,
+ void testValidateWithNonDefaultValues() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
@@ -89,7 +88,7 @@ public class RestServerCarrierTechnologyParametersTest {
}
@Test
- public void testValidateWithValidValues() throws NoSuchFieldException, SecurityException,
+ void testValidateWithValidValues() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
@@ -119,7 +118,7 @@ public class RestServerCarrierTechnologyParametersTest {
}
@Test
- public void testValidateWithInvalidValues() throws NoSuchFieldException, SecurityException,
+ void testValidateWithInvalidValues() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/SupportApexEventReceiver.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/SupportApexEventReceiver.java
index 773ecafb2..b10eecf21 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/SupportApexEventReceiver.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/SupportApexEventReceiver.java
@@ -27,7 +27,7 @@ import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
/**
- * Support Apex event reveiver for unit test.
+ * Support Apex event receiver for unit test.
*
*/
@Getter
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
index 5f643c04a..2ca3cf24d 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
@@ -21,6 +21,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
+ <artifactId>plugins-event-protocol</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
<artifactId>plugins-event-protocol-jms</artifactId>
<name>${project.artifactId}</name>
<description>[${project.parent.artifactId}] Plugins for handling events that are being transported as JMS messages
@@ -33,10 +39,10 @@
<version>${version.activemq}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>jakarta.jms</groupId>
+ <artifactId>jakarta.jms-api</artifactId>
+ <version>${version.jms}</version>
+ </dependency>
</dependencies>
- <parent>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
- <artifactId>plugins-event-protocol</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
</project> \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java
index 701326f71..c828f789a 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021, 2023 Nordix Foundation.
+ * Copyright (C) 2021, 2023-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,9 +22,9 @@ package org.onap.policy.apex.plugins.event.protocol.jms;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import jakarta.jms.JMSException;
import jakarta.jms.ObjectMessage;
@@ -33,39 +33,39 @@ import java.io.PrintStream;
import java.util.List;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
import org.onap.policy.apex.service.engine.event.impl.apexprotocolplugin.ApexEventProtocolParameters;
-public class Apex2JmsObjectEventConverterTest {
+class Apex2JmsObjectEventConverterTest {
private Apex2JmsObjectEventConverter converter;
private final PrintStream orgOutBuffer = System.out;
private ByteArrayOutputStream testOutStream;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
converter = new Apex2JmsObjectEventConverter();
testOutStream = new ByteArrayOutputStream();
System.setOut(new PrintStream(testOutStream));
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
System.setOut(orgOutBuffer);
}
@Test
- public void initNull() {
+ void initNull() {
assertThatThrownBy(() -> converter.init(null))
.isInstanceOf(NullPointerException.class);
}
@Test
- public void initWrongClass() {
+ void initWrongClass() {
converter.init(new ApexEventProtocolParameters());
final String actual = testOutStream.toString();
assertThat(actual).contains("specified Event Protocol Parameters properties of typ");
@@ -73,7 +73,7 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void init() {
+ void init() {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final JmsObjectEventProtocolParameters actual = converter.getEventProtocolParameters();
@@ -81,7 +81,7 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void toApexEventNull() {
+ void toApexEventNull() {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final String eventName = RandomStringUtils.randomAlphabetic(4);
@@ -90,7 +90,7 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void toApexEventObject() {
+ void toApexEventObject() {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final String eventName = RandomStringUtils.randomAlphabetic(4);
@@ -99,31 +99,31 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void toApexEventNoParams() {
+ void toApexEventNoParams() {
final String eventName = RandomStringUtils.randomAlphabetic(4);
- ObjectMessage object = new ActiveMQObjectMessage();
+ ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
assertThatThrownBy(() -> converter.toApexEvent(eventName, object))
.isInstanceOf(ApexEventRuntimeException.class);
}
@Test
- public void toApexEventIncomingObjectIsNull() {
+ void toApexEventIncomingObjectIsNull() {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final String eventName = RandomStringUtils.randomAlphabetic(4);
- ObjectMessage object = new ActiveMQObjectMessage();
+ ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
assertThatThrownBy(() -> converter.toApexEvent(eventName, object))
.isInstanceOf(NullPointerException.class);
}
@Test
- public void toApexEvent() throws ApexEventException, JMSException {
+ void toApexEvent() throws ApexEventException, JMSException {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final String eventName = RandomStringUtils.randomAlphabetic(4);
- final ObjectMessage object = new ActiveMQObjectMessage();
+ final ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
final String value = RandomStringUtils.randomAlphabetic(3);
object.setObject(value);
@@ -145,13 +145,12 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void fromApexEventNull() {
- assertThatThrownBy(() -> converter.fromApexEvent(null))
- .isInstanceOf(ApexEventException.class);
+ void fromApexEventNull() {
+ assertThatThrownBy(() -> converter.fromApexEvent(null)).isInstanceOf(ApexEventException.class);
}
@Test
- public void fromApexEventEmptyEvent() throws ApexEventException {
+ void fromApexEventEmptyEvent() throws ApexEventException {
final ApexEvent apexEvent = new ApexEvent(
"a" + RandomStringUtils.randomAlphabetic(3),
"a" + RandomStringUtils.randomAlphabetic(3),
@@ -163,7 +162,7 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void fromApexEventMultipleEvents() throws ApexEventException {
+ void fromApexEventMultipleEvents() throws ApexEventException {
final ApexEvent apexEvent = new ApexEvent(
"a" + RandomStringUtils.randomAlphabetic(3),
"a" + RandomStringUtils.randomAlphabetic(4),
@@ -176,7 +175,7 @@ public class Apex2JmsObjectEventConverterTest {
}
@Test
- public void fromApexEventSingleEvent() throws ApexEventException {
+ void fromApexEventSingleEvent() throws ApexEventException {
final ApexEvent apexEvent = new ApexEvent(
"a" + RandomStringUtils.randomAlphabetic(3),
"a" + RandomStringUtils.randomAlphabetic(3),
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java
index 9f68b49df..a2ff9d02f 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 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.
@@ -21,15 +21,14 @@
package org.onap.policy.apex.plugins.event.protocol.jms;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -45,40 +44,41 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters;
import org.onap.policy.common.parameters.ParameterService;
-public class Apex2JmsTextEventConverterTest {
+class Apex2JmsTextEventConverterTest {
private Apex2JmsTextEventConverter converter;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
converter = new Apex2JmsTextEventConverter();
ModelService.registerModel(AxContextSchemas.class, new AxContextSchemas());
ModelService.registerModel(AxEvents.class, new AxEvents());
ParameterService.register(new SchemaParameters());
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
ModelService.deregisterModel(AxContextSchema.class);
ModelService.deregisterModel(AxEvents.class);
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
- public void toApexEventNull() {
+ void toApexEventNull() {
final String eventName = RandomStringUtils.randomAlphabetic(4);
assertThatThrownBy(() -> converter.toApexEvent(eventName, null))
.isInstanceOf(ApexEventRuntimeException.class);
}
@Test
- public void toApexEventObject() {
+ void toApexEventObject() {
final String eventName = RandomStringUtils.randomAlphabetic(4);
- assertThatThrownBy(() -> converter.toApexEvent(eventName, new Object()))
- .isInstanceOf(ApexEventRuntimeException.class);
+ var object = new Object();
+ assertThatThrownBy(() -> converter.toApexEvent(eventName, object)).isInstanceOf(
+ ApexEventRuntimeException.class);
}
@Test
- public void toApexEventJsonString() throws ApexEventException {
+ void toApexEventJsonString() throws ApexEventException {
final String eventName = RandomStringUtils.randomAlphabetic(4);
final String eventVersion = "0.0.1";
final String source = RandomStringUtils.randomAlphabetic(5);
@@ -113,12 +113,12 @@ public class Apex2JmsTextEventConverterTest {
}
@Test
- public void fromApexNull() {
+ void fromApexNull() {
assertThatThrownBy(() -> converter.fromApexEvent(null)).isInstanceOf(ApexEventException.class);
}
@Test
- public void fromApex() throws ApexEventException {
+ void fromApex() throws ApexEventException {
final String name = RandomStringUtils.randomAlphabetic(4);
final String version = "0.2.3";
final String nameSpace = "a.name.space";
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java
index 8baa9d5b1..1f480a654 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 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.
@@ -20,15 +20,15 @@
package org.onap.policy.apex.plugins.event.protocol.jms;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-public class JmsObjectEventProtocolParametersTest {
+class JmsObjectEventProtocolParametersTest {
@Test
- public void getIncomingEventVersion() {
+ void getIncomingEventVersion() {
final JmsObjectEventProtocolParameters jmsObjectEventProtocolParameters =
new JmsObjectEventProtocolParameters();
final String actual = jmsObjectEventProtocolParameters.getIncomingEventVersion();
@@ -36,7 +36,7 @@ public class JmsObjectEventProtocolParametersTest {
}
@Test
- public void getIncomingEventSource() {
+ void getIncomingEventSource() {
final JmsObjectEventProtocolParameters jmsObjectEventProtocolParameters =
new JmsObjectEventProtocolParameters();
final String actual = jmsObjectEventProtocolParameters.getIncomingEventSource();
@@ -44,7 +44,7 @@ public class JmsObjectEventProtocolParametersTest {
}
@Test
- public void getIncomingEventTarget() {
+ void getIncomingEventTarget() {
final JmsObjectEventProtocolParameters jmsObjectEventProtocolParameters =
new JmsObjectEventProtocolParameters();
final String actual = jmsObjectEventProtocolParameters.getIncomingEventTarget();
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolTest.java
index 2fbae65e4..b0da163f8 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolTest.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,16 +22,15 @@
package org.onap.policy.apex.plugins.event.protocol.yaml;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -52,15 +51,14 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* The Class TestYamlEventProtocol.
*/
-public class YamlEventProtocolTest {
+class YamlEventProtocolTest {
/**
* Register test events and schemas.
*
- * @throws IOException Signals that an I/O exception has occurred.
*/
- @BeforeClass
- public static void registerTestEventsAndSchemas() throws IOException {
+ @BeforeAll
+ static void registerTestEventsAndSchemas() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters, true);
@@ -201,8 +199,8 @@ public class YamlEventProtocolTest {
/**
* Unregister test events and schemas.
*/
- @AfterClass
- public static void unregisterTestEventsAndSchemas() {
+ @AfterAll
+ static void unregisterTestEventsAndSchemas() {
ModelService.clear();
ParameterService.clear();
}
@@ -214,7 +212,7 @@ public class YamlEventProtocolTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testYamlProcessing() throws ApexEventException, IOException {
+ void testYamlProcessing() throws ApexEventException, IOException {
assertThatThrownBy(() -> testYamlDecodeEncode("TestEvent0", 1, 0, "Empty0"))
.hasMessage("event processing failed, event is null");
testYamlDecodeEncode("TestEvent0", 1, 0, "Empty1");
@@ -252,7 +250,7 @@ public class YamlEventProtocolTest {
converter.init(parameters);
String filePath = "src/test/resources/yaml_in/" + fileName + ".yaml";
- FileInputStream fileInputStream = new FileInputStream(new File(filePath));
+ FileInputStream fileInputStream = new FileInputStream(filePath);
HeaderDelimitedTextBlockReader reader = new HeaderDelimitedTextBlockReader(parameters);
reader.init(fileInputStream);
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
index fdab1d8c1..7332f341e 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2023 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -24,14 +24,15 @@
package org.onap.policy.apex.plugins.event.protocol.yaml;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+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.assertTrue;
-import java.io.IOException;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -50,16 +51,14 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestYamlPluginStability.
*/
-public class YamlPluginStabilityTest {
+class YamlPluginStabilityTest {
static AxEvent testEvent;
/**
* Register test events and schemas.
- *
- * @throws IOException Signals that an I/O exception has occurred.
*/
- @BeforeClass
- public static void registerTestEventsAndSchemas() throws IOException {
+ @BeforeAll
+ static void registerTestEventsAndSchemas() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters);
@@ -67,15 +66,15 @@ public class YamlPluginStabilityTest {
AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema simpleIntSchema = new AxContextSchema(new AxArtifactKey("SimpleIntSchema", "0.0.1"), "JAVA",
- "java.lang.Integer");
+ "java.lang.Integer");
schemas.getSchemasMap().put(simpleIntSchema.getKey(), simpleIntSchema);
AxContextSchema simpleDoubleSchema = new AxContextSchema(new AxArtifactKey("SimpleDoubleSchema", "0.0.1"),
- "JAVA", "java.lang.Double");
+ "JAVA", "java.lang.Double");
schemas.getSchemasMap().put(simpleDoubleSchema.getKey(), simpleDoubleSchema);
AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"),
- "JAVA", "java.lang.String");
+ "JAVA", "java.lang.String");
schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema);
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -86,10 +85,10 @@ public class YamlPluginStabilityTest {
AxField teField0 = new AxField(new AxReferenceKey(testEvent.getKey(), "intValue"), simpleIntSchema.getKey());
testEvent.getParameterMap().put("intValue", teField0);
AxField teField1 = new AxField(new AxReferenceKey(testEvent.getKey(), "doubleValue"),
- simpleDoubleSchema.getKey());
+ simpleDoubleSchema.getKey());
testEvent.getParameterMap().put("doubleValue", teField1);
AxField teField2 = new AxField(new AxReferenceKey(testEvent.getKey(), "stringValue"),
- simpleStringSchema.getKey(), true);
+ simpleStringSchema.getKey(), true);
testEvent.getParameterMap().put("stringValue", teField2);
AxEvents events = new AxEvents();
@@ -101,8 +100,8 @@ public class YamlPluginStabilityTest {
/**
* Unregister test events and schemas.
*/
- @AfterClass
- public static void unregisterTestEventsAndSchemas() {
+ @AfterAll
+ static void unregisterTestEventsAndSchemas() {
ModelService.clear();
ParameterService.clear();
}
@@ -112,9 +111,8 @@ public class YamlPluginStabilityTest {
*
* @throws ApexEventException the apex event exception
*/
- @SuppressWarnings("deprecation")
@Test
- public void testStability() throws ApexEventException {
+ void testStability() throws ApexEventException {
Apex2YamlEventConverter converter = new Apex2YamlEventConverter();
assertThatThrownBy(() -> converter.init(null))
@@ -122,20 +120,20 @@ public class YamlPluginStabilityTest {
YamlEventProtocolParameters pars = new YamlEventProtocolParameters();
converter.init(pars);
- assertThatThrownBy(() -> converter.toApexEvent("NonExistantEvent", ""))
+ assertThatThrownBy(() -> converter.toApexEvent("NonExistentEvent", ""))
.hasMessageContaining("Failed to unmarshal YAML event")
- .getCause().hasMessageStartingWith("an event definition for an event named \"NonExistantEvent\"");
+ .cause().hasMessageStartingWith("an event definition for an event named \"NonExistentEvent\"");
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", null))
.hasMessage("event processing failed, event is null");
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", 1))
.hasMessage("error converting event \"1\" to a string");
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", ""))
- .getCause().hasMessageContaining("Field \"doubleValue\" is missing");
+ .cause().hasMessageContaining("Field \"doubleValue\" is missing");
assertThatThrownBy(() -> converter.fromApexEvent(null))
.hasMessage("event processing failed, Apex event is null");
ApexEvent apexEvent = new ApexEvent(testEvent.getKey().getName(), testEvent.getKey().getVersion(),
- testEvent.getNameSpace(), testEvent.getSource(), testEvent.getTarget(),
- testEvent.getToscaPolicyState());
+ testEvent.getNameSpace(), testEvent.getSource(), testEvent.getTarget(),
+ testEvent.getToscaPolicyState());
apexEvent.put("doubleValue", 123.45);
apexEvent.put("intValue", 123);
apexEvent.put("stringValue", "123.45");
@@ -149,15 +147,15 @@ public class YamlPluginStabilityTest {
.hasMessageContaining("error parsing TestEvent:0.0.1 event to Json. Field \"intValue\" is missing");
assertThatThrownBy(() -> converter.toApexEvent(null, ""))
.hasMessageStartingWith("Failed to unmarshal YAML event")
- .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
+ .cause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
pars.setNameAlias("TheNameField");
assertThatThrownBy(() -> converter.toApexEvent(null, ""))
.hasMessageStartingWith("Failed to unmarshal YAML event")
- .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
+ .cause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
apexEvent.put("intValue", 123);
apexEvent.remove("stringValue");
- yamlString = (String) converter.fromApexEvent(apexEvent);
+ assertNotNull(converter.fromApexEvent(apexEvent));
apexEvent.put("stringValue", "123.45");
String yamlInputString = "doubleValue: 123.45\n" + "intValue: 123";
@@ -165,60 +163,71 @@ public class YamlPluginStabilityTest {
List<ApexEvent> eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals(123.45, eventList.get(0).get("doubleValue"));
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: null";
+ yamlInputString = "doubleValue: 123.45\nintValue: 123\nstringValue: null";
eventList = converter.toApexEvent("TestEvent", yamlInputString);
- assertEquals(null, eventList.get(0).get("stringValue"));
+ assertNull(eventList.get(0).get("stringValue"));
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: TestEvent";
+ yamlInputString = "doubleValue: 123.45\nintValue: 123\nstringValue: TestEvent";
pars.setNameAlias("stringValue");
eventList = converter.toApexEvent(null, yamlInputString);
assertEquals("TestEvent", eventList.get(0).get("stringValue"));
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: SomeOtherEvent";
+ yamlInputString = "doubleValue: 123.45\nintValue: 123\nstringValue: SomeOtherEvent";
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("SomeOtherEvent", eventList.get(0).get("stringValue"));
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: 0.0.1";
+ yamlInputString = "doubleValue: 123.45\nintValue: 123\nstringValue: 0.0.1";
pars.setNameAlias(null);
pars.setVersionAlias("stringValue");
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("0.0.1", eventList.get(0).get("stringValue"));
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: org.some.other.namespace";
+ yamlInputString = "doubleValue: 123.45\nintValue: 123\nstringValue: org.some.other.namespace";
pars.setVersionAlias(null);
pars.setNameSpaceAlias("stringValue");
final String yamlInputStringCopy = yamlInputString;
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", yamlInputStringCopy))
.hasMessageStartingWith("Failed to unmarshal YAML event")
- .getCause().hasMessageStartingWith("namespace \"org.some.other.namespace\" on event");
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n"
- + "stringValue: org.onap.policy.apex.plugins.event.protocol.yaml";
+ .cause().hasMessageStartingWith("namespace \"org.some.other.namespace\" on event");
+
+ yamlInputString = """
+ doubleValue: 123.45
+ intValue: 123
+ stringValue: \
+ org.onap.policy.apex.plugins.event.protocol.yaml""";
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("org.onap.policy.apex.plugins.event.protocol.yaml", eventList.get(0).getNameSpace());
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: MySource";
+ yamlInputString = """
+ doubleValue: 123.45
+ intValue: 123
+ stringValue: MySource""";
pars.setNameSpaceAlias(null);
pars.setSourceAlias("stringValue");
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("MySource", eventList.get(0).getSource());
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: MyTarget";
+ yamlInputString = """
+ doubleValue: 123.45
+ intValue: 123
+ stringValue: MyTarget""";
pars.setSourceAlias(null);
pars.setTargetAlias("stringValue");
eventList = converter.toApexEvent("TestEvent", yamlInputString);
assertEquals("MyTarget", eventList.get(0).getTarget());
pars.setTargetAlias(null);
- yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: MyString";
pars.setSourceAlias(null);
pars.setTargetAlias("intValue");
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", yamlInputStringCopy))
.hasMessageStartingWith("Failed to unmarshal YAML event")
- .getCause().hasMessageStartingWith("field \"target\" with type \"java.lang.Integer\"");
+ .cause().hasMessageStartingWith("field \"target\" with type \"java.lang.Integer\"");
pars.setTargetAlias(null);
- assertThatThrownBy(() -> converter.toApexEvent("TestEvent", "doubleValue: 123.45\n" + "intValue: ~\n"
- + "stringValue: MyString")).getCause().hasMessageStartingWith("mandatory field \"intValue\" is missing");
+ assertThatThrownBy(() -> converter.toApexEvent("TestEvent", """
+ doubleValue: 123.45
+ intValue: ~
+ stringValue: MyString""")).cause().hasMessageStartingWith("mandatory field \"intValue\" is missing");
}
}
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
index 1e1dbf7ed..f9c56ab82 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
@@ -1,36 +1,41 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
* 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=========================================================
*/
package org.onap.policy.apex.plugins.executor.java;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JavaExecutorParameters class.
*/
-public class JavaExecutorParametersTest {
+class JavaExecutorParametersTest {
@Test
- public void testJavaExecutorParameters() {
- assertNotNull(new JavaExecutorParameters());
+ void testJavaExecutorParameters() {
+ var executorType = "Java";
+ var javaExecutor = new JavaExecutorParameters();
+ assertTrue(javaExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(javaExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
+ assertTrue(javaExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
index a1c296436..884530436 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.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,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -50,14 +50,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaStateFinalizerExecutor class.
- *
*/
-public class JavaStateFinalizerExecutorTest {
+class JavaStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -67,8 +66,8 @@ public class JavaStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -76,7 +75,7 @@ public class JavaStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
+ void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
JavaStateFinalizerExecutor jsfe = new JavaStateFinalizerExecutor();
assertNotNull(jsfe);
@@ -111,7 +110,7 @@ public class JavaStateFinalizerExecutorTest {
assertThatThrownBy(() -> {
jsfe.execute(-1, new Properties(), event);
}).hasMessage("execute-post: state finalizer logic execution failure on state "
- + "\"NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
+ + "\"NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
state.getStateOutputs().put("SelectedOutputIsMe", null);
jsfe.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
index 96bc6bb3d..3fbaf8b16 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.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.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,16 +23,16 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,14 +47,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaTaskExecutor class.
- *
*/
-public class JavaTaskExecutorTest {
+class JavaTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +62,15 @@ public class JavaTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskExecutor() throws ContextException, StateMachineException {
+ void testJavaTaskExecutor() throws ContextException, StateMachineException {
JavaTaskExecutor jte = new JavaTaskExecutor();
assertNotNull(jte);
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
index 61acecd9b..feb4cc6fd 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.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,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,12 +47,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JavaTaskSelectExecutor class.
*
*/
-public class JavaTaskSelectExecutorTest {
+class JavaTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -61,22 +61,22 @@ public class JavaTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
+ void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
JavaTaskSelectExecutor jtse = new JavaTaskSelectExecutor();
assertNotNull(jtse);
assertThatThrownBy(jtse::prepare)
.isInstanceOf(java.lang.NullPointerException.class);
AxState state = new AxState();
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
jtse.setContext(null, state, internalContext);
@@ -96,9 +96,8 @@ public class JavaTaskSelectExecutorTest {
.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskSelectionLogic");
jtse.prepare();
- assertThatThrownBy(() -> {
- jtse.execute(-1, new Properties(), event);
- }).hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
+ assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event))
+ .hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
jtse.prepare();
AxArtifactKey taskKey = jtse.execute(0, new Properties(), event);
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
index 394126bc4..61422d1d5 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorFullApexTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * 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.
@@ -21,21 +21,21 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class JavascriptExecutorFullApexTest {
+class JavascriptExecutorFullApexTest {
@Test
- public void testFullApexPolicy() throws ApexException {
+ void testFullApexPolicy() throws ApexException {
final String[] args = {"src/test/resources/prodcons/File2File.json"};
final File outFile0 = new File("src/test/resources/events/EventsOut0.json");
@@ -46,19 +46,17 @@ public class JavascriptExecutorFullApexTest {
final ApexMain apexMain = new ApexMain(args);
assertNotNull(apexMain);
- await().atMost(10, TimeUnit.SECONDS).until(() -> outFile0.exists());
- await().atMost(10, TimeUnit.SECONDS).until(() -> outFile1.exists());
+ await().atMost(10, TimeUnit.SECONDS).until(outFile0::exists);
+ await().atMost(10, TimeUnit.SECONDS).until(outFile1::exists);
- await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile0, "BasicEventOut0", 50));
- await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurencesOf(outFile1, "BasicEventOut1", 50));
+ await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurrencesOf(outFile0, "BasicEventOut0"));
+ await().atMost(10, TimeUnit.SECONDS).until(() -> fileHasOccurrencesOf(outFile1, "BasicEventOut1"));
apexMain.shutdown();
}
- private boolean fileHasOccurencesOf(final File file, final String token, final int occurenceCount)
- throws IOException {
-
- return occurenceCount == StringUtils.countMatches(TextFileUtils.getTextFileAsString(file.getAbsolutePath()),
- token);
+ private boolean fileHasOccurrencesOf(final File file, final String token)
+ throws IOException {
+ return 50 == StringUtils.countMatches(TextFileUtils.getTextFileAsString(file.getAbsolutePath()), token);
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
index 5b23584d0..adc7dbb00 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 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.
@@ -20,17 +20,21 @@
package org.onap.policy.apex.plugins.executor.javascript;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JavaExecutorParameters class.
*/
-public class JavascriptExecutorParametersTest {
+class JavascriptExecutorParametersTest {
@Test
- public void testJavascriptExecutorParameters() {
- assertNotNull(new JavascriptExecutorParameters());
+ void testJavascriptExecutorParameters() {
+ var executorType = "Javascript";
+ var javascriptExecutor = new JavascriptExecutorParameters();
+ assertTrue(javascriptExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
+ assertTrue(javascriptExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(javascriptExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
index 20ba1291f..083ec521a 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020, 2024 Nordix Foundation. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,21 +23,21 @@ package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-public class JavascriptExecutorTest {
+class JavascriptExecutorTest {
@Test
- public void testReturnOK() throws StateMachineException {
+ void testReturnOK() throws StateMachineException {
JavascriptExecutor executor = new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "true;");
assertThatCode(() -> executor.execute(new Object())).doesNotThrowAnyException();
}
@Test
- public void testReturnNonBoolean() throws StateMachineException {
+ void testReturnNonBoolean() throws StateMachineException {
JavascriptExecutor executor = new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "var a = 1; a;");
assertThatThrownBy(() -> executor.execute(new Object()))
@@ -45,14 +45,14 @@ public class JavascriptExecutorTest {
}
@Test
- public void testBlankLogic() {
+ void testBlankLogic() {
assertThatThrownBy(() -> new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), " "))
.hasMessageContaining("no logic specified for TestTask:0.0.1");
}
@Test
- public void testCompileFailed() {
+ void testCompileFailed() {
assertThatThrownBy(() -> new JavascriptExecutor(
new AxArtifactKey("TestTask:0.0.1"), "return boolean;"))
.hasMessageContaining("logic failed to compile for TestTask:0.0.1");
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
index 2a10e70ca..ff7301541 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-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.
@@ -21,12 +21,12 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -46,14 +46,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavascriptStateFinalizerExecutor class.
- *
*/
-public class JavascriptStateFinalizerExecutorTest {
+class JavascriptStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,8 +62,8 @@ public class JavascriptStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -72,12 +71,10 @@ public class JavascriptStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws Exception {
+ void testJavaStateFinalizerExecutor() throws Exception {
JavascriptStateFinalizerExecutor jsfe = new JavascriptStateFinalizerExecutor();
- assertThatThrownBy(() -> {
- jsfe.prepare();
- }).isInstanceOf(java.lang.NullPointerException.class);
+ assertThatThrownBy(jsfe::prepare).isInstanceOf(java.lang.NullPointerException.class);
ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
StateExecutor parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
@@ -88,9 +85,7 @@ public class JavascriptStateFinalizerExecutorTest {
jsfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
stateFinalizerLogic.setLogic("return false");
- assertThatThrownBy(() -> {
- jsfe.prepare();
- }).hasMessage("logic failed to compile for NULL:0.0.0:NULL:NULL "
+ assertThatThrownBy(jsfe::prepare).hasMessage("logic failed to compile for NULL:0.0.0:NULL:NULL "
+ "with message: invalid return (NULL:0.0.0:NULL:NULL#1)");
stateFinalizerLogic.setLogic("java.lang.String");
@@ -98,11 +93,19 @@ public class JavascriptStateFinalizerExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
- stateFinalizerLogic.setLogic("if(executor.executionId==-1)" + "{\r\n"
- + "var returnValueType = java.lang.Boolean;" + "var returnValue = new returnValueType(false); }\n"
- + "else{\n" + "executor.setSelectedStateOutputName(\"SelectedOutputIsMe\");\n"
- + "var returnValueType = java.lang.Boolean;\n" + "\n"
- + "var returnValue = new returnValueType(true);} true;");
+ var logic = """
+ if(executor.executionId==-1)
+ {
+ var returnValueType = java.lang.Boolean;
+ var returnValue = new returnValueType(false);
+ }
+ else
+ {
+ executor.setSelectedStateOutputName("SelectedOutputIsMe");
+ var returnValueType = java.lang.Boolean;
+ var returnValue = new returnValueType(true);
+ } true;""";
+ stateFinalizerLogic.setLogic(logic);
assertThatThrownBy(() -> {
jsfe.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
index 215491d4e..0dd630a2c 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -23,17 +23,17 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
@@ -58,17 +58,16 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* Test the JavaTaskExecutor class.
- *
*/
-public class JavascriptTaskExecutorTest {
+class JavascriptTaskExecutorTest {
/**
- * Set ups everything for the test.
+ * Set-ups everything for the test.
*/
- @BeforeClass
- public static void prepareForTest() {
+ @BeforeAll
+ static void prepareForTest() {
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager");
+ .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager");
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
@@ -90,8 +89,8 @@ public class JavascriptTaskExecutorTest {
/**
* Clear down the test data.
*/
- @AfterClass
- public static void cleanUpAfterTest() {
+ @AfterAll
+ static void cleanUpAfterTest() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -101,12 +100,10 @@ public class JavascriptTaskExecutorTest {
}
@Test
- public void testJavascriptTaskExecutor() throws Exception {
+ void testJavascriptTaskExecutor() throws Exception {
JavascriptTaskExecutor jte = new JavascriptTaskExecutor();
- assertThatThrownBy(() -> {
- jte.prepare();
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(jte::prepare).isInstanceOf(NullPointerException.class);
AxTask task = new AxTask(new AxArtifactKey("TestTask:0.0.1"));
final ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
@@ -115,17 +112,14 @@ public class JavascriptTaskExecutorTest {
task.getTaskLogic().setLogic("return boolean;");
- assertThatThrownBy(() -> {
- jte.prepare();
- }).hasMessage("logic failed to compile for TestTask:0.0.1 with message: invalid return (TestTask:0.0.1#1)");
+ assertThatThrownBy(jte::prepare)
+ .hasMessage("logic failed to compile for TestTask:0.0.1 with message: invalid return (TestTask:0.0.1#1)");
task.getTaskLogic().setLogic("var x = 5;");
jte.prepare();
Properties props = new Properties();
- assertThatThrownBy(() -> {
- jte.execute(-1, props, null);
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> jte.execute(-1, props, null)).isInstanceOf(NullPointerException.class);
jte.cleanUp();
task.setInputEvent(new AxEvent());
task.setOutputEvents(new TreeMap<>());
@@ -149,14 +143,12 @@ public class JavascriptTaskExecutorTest {
}
@Test
- public void testJavascriptTaskExecutorLogic() throws Exception {
+ void testJavascriptTaskExecutorLogic() throws Exception {
JavascriptTaskExecutor jte = new JavascriptTaskExecutor();
assertNotNull(jte);
- assertThatThrownBy(() -> {
- jte.prepare();
- }).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(jte::prepare).isInstanceOf(NullPointerException.class);
AxTask task = new AxTask(new AxArtifactKey("TestTask:0.0.1"));
@@ -199,16 +191,16 @@ public class JavascriptTaskExecutorTest {
private ContextAlbum createTestContextAlbum() throws ContextException {
AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema simpleStringSchema =
- new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", "java.lang.String");
+ new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", "java.lang.String");
schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema);
ModelService.registerModel(AxContextSchemas.class, schemas);
AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
- true, AxArtifactKey.getNullKey());
+ true, AxArtifactKey.getNullKey());
axContextAlbum.setItemSchema(simpleStringSchema.getKey());
Distributor distributor = new JvmLocalDistributor();
distributor.init(axContextAlbum.getKey());
- return new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
+ return new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
}
}
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
index d2bb852b6..7e7f61622 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
@@ -22,13 +22,13 @@
package org.onap.policy.apex.plugins.executor.javascript;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -43,14 +43,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JavaTaskSelectExecutor class.
- *
*/
-public class JavascriptTaskSelectExecutorTest {
+class JavascriptTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -59,15 +58,15 @@ public class JavascriptTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavascriptTaskSelectExecutor() throws Exception {
+ void testJavascriptTaskSelectExecutor() throws Exception {
JavascriptTaskSelectExecutor jtse = new JavascriptTaskSelectExecutor();
assertThatThrownBy(() -> {
@@ -79,9 +78,7 @@ public class JavascriptTaskSelectExecutorTest {
ApexInternalContext internalContext = new ApexInternalContext(new AxPolicyModel());
jtse.setContext(null, state, internalContext);
- assertThatThrownBy(() -> {
- jtse.prepare();
- }).hasMessage("no logic specified for NULL:0.0.0:NULL:NULL");
+ assertThatThrownBy(jtse::prepare).hasMessage("no logic specified for NULL:0.0.0:NULL:NULL");
state.getTaskSelectionLogic().setLogic("java.lang.String");
jtse.prepare();
@@ -92,9 +89,7 @@ public class JavascriptTaskSelectExecutorTest {
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
- assertThatThrownBy(() -> {
- jtse.execute(-1, new Properties(), event);
- }).hasMessage(
+ assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event)).hasMessage(
"execute: logic for NULL:0.0.0:NULL:NULL returned a non-boolean value [JavaClass java.lang.String]");
state.getTaskSelectionLogic().setLogic("var x=1;\n" + "false; ");
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
index 4cfd7a19c..c6e0b3a67 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 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.
@@ -20,16 +20,20 @@
package org.onap.policy.apex.plugins.executor.jruby;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the JrubyExecutorParameters class.
*/
-public class JrubyExecutorParametersTest {
+class JrubyExecutorParametersTest {
@Test
- public void testJrubyExecutorParameters() {
- assertNotNull(new JrubyExecutorParameters());
+ void testJrubyExecutorParameters() {
+ var executorType = "Jruby";
+ var jrubyExecutor = new JrubyExecutorParameters();
+ assertTrue(jrubyExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(jrubyExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
+ assertTrue(jrubyExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
index eca9a45cd..a750a0bfe 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-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,14 +21,14 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -53,12 +52,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JrubyStateFinalizerExecutor class.
*
*/
-public class JrubyStateFinalizerExecutorTest {
+class JrubyStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -68,8 +67,8 @@ public class JrubyStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -77,7 +76,7 @@ public class JrubyStateFinalizerExecutorTest {
}
@Test
- public void testJrubyStateFinalizerExecutor() throws StateMachineException, ContextException,
+ void testJrubyStateFinalizerExecutor() throws StateMachineException, ContextException,
NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
JrubyStateFinalizerExecutor jsfe = new JrubyStateFinalizerExecutor();
assertNotNull(jsfe);
@@ -105,8 +104,13 @@ public class JrubyStateFinalizerExecutorTest {
+ "NULL:0.0.0:NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL");
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
- final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else "
- + "\n executor.setSelectedStateOutputName(\"SelectedOutputIsMe\")" + "\n return true" + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ executor.setSelectedStateOutputName("SelectedOutputIsMe")
+ return true
+ end""";
stateFinalizerLogic.setLogic(jrubyLogic);
EnEvent event = new EnEvent(axEvent);
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
index 0cc476425..2092c8fb2 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,17 +22,17 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -49,12 +49,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the JrubyTaskExecutor class.
*
*/
-public class JrubyTaskExecutorTest {
+class JrubyTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +63,15 @@ public class JrubyTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJrubyTaskExecutor() throws StateMachineException, ContextException,
+ void testJrubyTaskExecutor() throws StateMachineException, ContextException,
IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
// Run test twice to check for incorrect shutdown activity
jrubyExecutorTest();
@@ -91,7 +91,7 @@ public class JrubyTaskExecutorTest {
fieldContainer.set(jte, null);
assertThatThrownBy(jte::prepare).isInstanceOf(java.lang.NullPointerException.class);
AxTask task = new AxTask();
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
task.setInputEvent(new AxEvent());
task.setOutputEvents(new TreeMap<>());
@@ -102,8 +102,12 @@ public class JrubyTaskExecutorTest {
Map<String, Object> incomingParameters = new HashMap<>();
assertThatThrownBy(() -> jte.execute(-1, new Properties(), incomingParameters))
.hasMessage("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0");
- final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true"
- + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ return true
+ end""";
task.getTaskLogic().setLogic(jrubyLogic);
jte.prepare();
Map<String, Map<String, Object>> returnMap = jte.execute(0, new Properties(), incomingParameters);
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
index 59d1be4b4..c7b96fde1 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-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,14 +21,14 @@
package org.onap.policy.apex.plugins.executor.jruby;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -46,14 +45,13 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the JrubyTaskSelectExecutor class.
- *
*/
-public class JrubyTaskSelectExecutorTest {
+class JrubyTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -62,15 +60,15 @@ public class JrubyTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJrubyTaskSelectExecutor() throws StateMachineException, ContextException,
+ void testJrubyTaskSelectExecutor() throws StateMachineException, ContextException,
NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
JrubyTaskSelectExecutor jtse = new JrubyTaskSelectExecutor();
assertNotNull(jtse);
@@ -93,8 +91,12 @@ public class JrubyTaskSelectExecutorTest {
EnEvent event = new EnEvent(axEvent);
assertThatThrownBy(() -> jtse.execute(-1, new Properties(), event))
.hasMessage("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"");
- final String jrubyLogic =
- "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true" + "\n end";
+ final String jrubyLogic = """
+ if executor.executionId == -1
+ return false
+ else
+ return true
+ end""";
state.getTaskSelectionLogic().setLogic(jrubyLogic);
jtse.prepare();
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
index 81dc037ae..2d3f51fb1 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 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.
@@ -20,17 +20,21 @@
package org.onap.policy.apex.plugins.executor.mvel;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the MvelExecutorParameters class.
*/
-public class MvelExecutorParametersTest {
+class MvelExecutorParametersTest {
@Test
- public void testJavaExecutorParameters() {
- assertNotNull(new MvelExecutorParameters());
+ void testMvelExecutorParameters() {
+ var executorType = "Mvel";
+ var mvelExecutor = new MvelExecutorParameters();
+ assertTrue(mvelExecutor.getStateFinalizerExecutorPluginClass().contains(executorType));
+ assertTrue(mvelExecutor.getTaskExecutorPluginClass().contains(executorType));
+ assertTrue(mvelExecutor.getTaskSelectionExecutorPluginClass().contains(executorType));
}
}
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
index 4dd400bbc..fbd789d96 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-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,13 +21,13 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -52,12 +51,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelStateFinalizerExecutor class.
*
*/
-public class MvelStateFinalizerExecutorTest {
+class MvelStateFinalizerExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -67,8 +66,8 @@ public class MvelStateFinalizerExecutorTest {
/**
* Clear down Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -76,22 +75,22 @@ public class MvelStateFinalizerExecutorTest {
}
@Test
- public void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
+ void testJavaStateFinalizerExecutor() throws StateMachineException, ContextException {
MvelStateFinalizerExecutor msfe = new MvelStateFinalizerExecutor();
assertNotNull(msfe);
assertThatThrownBy(msfe::prepare).isInstanceOf(java.lang.NullPointerException.class);
- ApexInternalContext internalContext = null;
+ ApexInternalContext internalContext;
internalContext = new ApexInternalContext(new AxPolicyModel());
- StateExecutor parentStateExcutor = null;
+ StateExecutor parentStateExecutor;
- parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
+ parentStateExecutor = new StateExecutor(new ExecutorFactoryImpl());
AxState state = new AxState();
- parentStateExcutor.setContext(null, state, internalContext);
+ parentStateExecutor.setContext(null, state, internalContext);
AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic();
- msfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
+ msfe.setContext(parentStateExecutor, stateFinalizerLogic, internalContext);
stateFinalizerLogic.setLogic("x > 1 2 ()");
assertThatThrownBy(msfe::prepare).hasMessage("failed to compile MVEL code for state NULL:0.0.0:NULL:NULL");
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
index 3d59c4b21..f6dd7d824 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,16 +22,16 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -49,12 +48,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelTaskExecutor class.
*
*/
-public class MvelTaskExecutorTest {
+class MvelTaskExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -63,15 +62,15 @@ public class MvelTaskExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testMvelTaskExecutor() throws StateMachineException, ContextException {
+ void testMvelTaskExecutor() throws StateMachineException, ContextException {
MvelTaskExecutor mte = new MvelTaskExecutor();
assertNotNull(mte);
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
index d81c3d13b..4a25730cc 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutorTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Copyright (C) 2019-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,13 +21,13 @@
package org.onap.policy.apex.plugins.executor.mvel;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -47,12 +46,12 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the MvelTaskSelectExecutor class.
*
*/
-public class MvelTaskSelectExecutorTest {
+class MvelTaskSelectExecutorTest {
/**
* Initiate Parameters.
*/
- @Before
- public void initiateParameters() {
+ @BeforeEach
+ void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new LockManagerParameters());
ParameterService.register(new PersistorParameters());
@@ -61,15 +60,15 @@ public class MvelTaskSelectExecutorTest {
/**
* Clear Parameters.
*/
- @After
- public void clearParameters() {
+ @AfterEach
+ void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
}
@Test
- public void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
+ void testJavaTaskSelectExecutor() throws StateMachineException, ContextException {
MvelTaskSelectExecutor mtse = new MvelTaskSelectExecutor();
assertNotNull(mtse);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
index a8f13bbf6..ee814e245 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
@@ -1,8 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -23,6 +24,7 @@
package org.onap.policy.apex.service.engine.event;
import com.google.common.base.Strings;
+import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
@@ -50,6 +52,8 @@ import org.slf4j.LoggerFactory;
@ToString
@EqualsAndHashCode(callSuper = false)
public class ApexEvent extends HashMap<String, Object> implements Serializable {
+
+ @Serial
private static final long serialVersionUID = -4451918242101961685L;
// Get a reference to the logger
@@ -59,7 +63,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
private static final String EVENT_PREAMBLE = "event \"";
// Holds the next identifier for event execution.
- private static AtomicLong nextExecutionID = new AtomicLong(0L);
+ private static final AtomicLong nextExecutionID = new AtomicLong(0L);
/**
* The name of the Apex event, a mandatory field. All Apex events must have a name so that the
@@ -131,7 +135,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
private final String nameSpace;
private final String source;
private final String target;
- private final String toscaPolicyState;
+ private String toscaPolicyState;
// An identifier for the current event execution. The default value here will always be unique
// in a single JVM
@@ -154,6 +158,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
* @param nameSpace the name space (java package) of the event
* @param source the source of the event
* @param target the target of the event
+ * @param toscaPolicyState Policy state
* @throws ApexEventException thrown on validation errors on event names and versions
*/
public ApexEvent(final String name, final String version, final String nameSpace, final String source,
@@ -167,10 +172,29 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
}
/**
+ * Instantiates a new apex event.
+ *
+ * @param name the name of the event
+ * @param version the version of the event
+ * @param nameSpace the name space (java package) of the event
+ * @param source the source of the event
+ * @param target the target of the event
+ * @throws ApexEventException thrown on validation errors on event names and versions
+ */
+ public ApexEvent(final String name, final String version, final String nameSpace, final String source,
+ final String target) throws ApexEventException {
+ this.name = validateField(NAME_HEADER_FIELD, name, NAME_REGEXP);
+ this.version = validateField(VERSION_HEADER_FIELD, version, VERSION_REGEXP);
+ this.nameSpace = validateField(NAMESPACE_HEADER_FIELD, nameSpace, NAMESPACE_REGEXP);
+ this.source = validateField(SOURCE_HEADER_FIELD, source, SOURCE_REGEXP);
+ this.target = validateField(TARGET_HEADER_FIELD, target, TARGET_REGEXP);
+ }
+
+ /**
* Private utility to get the next candidate value for a Execution ID. This value will always be
* unique in a single JVM
*
- * @return the next candidate value for a Execution ID
+ * @return the next candidate value for an Execution ID
*/
private static synchronized long getNextExecutionId() {
return nextExecutionID.getAndIncrement();
@@ -249,7 +273,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
* {@inheritDoc}.
*/
@Override
- public void putAll(final Map<? extends String, ? extends Object> incomingMap) {
+ public void putAll(final Map<? extends String, ?> incomingMap) {
// Check the keys are valid
try {
for (final String key : incomingMap.keySet()) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
index fe59486f3..194e13bfe 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
@@ -66,9 +66,9 @@ public abstract class EventProtocolParameters extends ParameterGroupImpl {
}
/**
- * Sets the event event protocol plugin class.
+ * Sets the event protocol plugin class.
*
- * @param eventProtocolPluginClass the event event protocol plugin class
+ * @param eventProtocolPluginClass the event protocol plugin class
*/
public void setEventProtocolPluginClass(final String eventProtocolPluginClass) {
this.eventProtocolPluginClass = eventProtocolPluginClass.replaceAll("\\s+", "");