aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-17 15:31:12 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-17 16:05:42 +0100
commitfe6bb57982677177f85daa5f893868556b18e63c (patch)
tree54a2f6f5a3e31469c4ea703a777399fb30fc9cfc /plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- plugins module Issue-ID: POLICY-5041 Change-Id: Iebff0a2e6898a5dfe9679662dd2be4c5067a4008 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main')
-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
3 files changed, 54 insertions, 55 deletions
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();