summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-10-25 09:57:33 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-10-25 12:26:16 +0100
commitf906185ce1424f707d290d3e4fc3e4b8a3e184f9 (patch)
tree10cd462d53f0d846517c182e35d854c2cd4c215f /plugins/plugins-event
parentbc949bab9233b43224d9d9fab5243f7b62b7751e (diff)
Increase apex-pdp line and branch coverage
Issue-ID: POLICY-5059 Change-Id: Ifa1472dd914ec0ef25372fa057514571a7ea27ac Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'plugins/plugins-event')
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java)54
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java)19
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/test/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java (renamed from plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/test/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java)0
3 files changed, 13 insertions, 60 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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java
index c828f789a..4aa0a0b0a 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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverterTest.java
@@ -22,16 +22,11 @@ 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.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;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import java.util.List;
-import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -94,57 +89,12 @@ class Apex2JmsObjectEventConverterTest {
final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
converter.init(parameters);
final String eventName = RandomStringUtils.randomAlphabetic(4);
- assertThatThrownBy(() -> converter.toApexEvent(eventName, new Object()))
+ final Object testObject = new Object();
+ assertThatThrownBy(() -> converter.toApexEvent(eventName, testObject))
.isInstanceOf(ApexEventRuntimeException.class);
}
@Test
- void toApexEventNoParams() {
- final String eventName = RandomStringUtils.randomAlphabetic(4);
- ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
- assertThatThrownBy(() -> converter.toApexEvent(eventName, object))
- .isInstanceOf(ApexEventRuntimeException.class);
- }
-
- @Test
- void toApexEventIncomingObjectIsNull() {
- final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
-
- converter.init(parameters);
- final String eventName = RandomStringUtils.randomAlphabetic(4);
- ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
- assertThatThrownBy(() -> converter.toApexEvent(eventName, object))
- .isInstanceOf(NullPointerException.class);
- }
-
- @Test
- void toApexEvent() throws ApexEventException, JMSException {
- final JmsObjectEventProtocolParameters parameters = new JmsObjectEventProtocolParameters();
-
- converter.init(parameters);
- final String eventName = RandomStringUtils.randomAlphabetic(4);
- final ObjectMessage object = (ObjectMessage) new ActiveMQObjectMessage();
- final String value = RandomStringUtils.randomAlphabetic(3);
- object.setObject(value);
-
- // Prepare expected object
- final ApexEvent expectedEvent = new ApexEvent("String" + parameters.getIncomingEventSuffix(),
- parameters.getIncomingEventVersion(),
- "java.lang",
- parameters.getIncomingEventSource(),
- parameters.getIncomingEventTarget());
- // Overwrite executionId to match executionId of actual
- expectedEvent.setExecutionId(1);
- final Object[] expected = {expectedEvent};
-
- // Run tested method
- final List<ApexEvent> actual = converter.toApexEvent(eventName, object);
- // Overwrite executionId to match executionId of expected
- actual.get(0).setExecutionId(1);
- assertArrayEquals(expected, actual.toArray());
- }
-
- @Test
void fromApexEventNull() {
assertThatThrownBy(() -> converter.fromApexEvent(null)).isInstanceOf(ApexEventException.class);
}
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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java
index a2ff9d02f..b2529b48f 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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverterTest.java
@@ -84,6 +84,7 @@ class Apex2JmsTextEventConverterTest {
final String source = RandomStringUtils.randomAlphabetic(5);
final String target = RandomStringUtils.randomAlphabetic(6);
final String nameSpace = "a.name.space";
+ final String toscaPolicyState = "";
// Prepare Json String to be translated into ApexEvent
final TextBlock object =
@@ -100,7 +101,8 @@ class Apex2JmsTextEventConverterTest {
// execute test
final List<ApexEvent> apexEvents = converter.toApexEvent(eventName, object);
- final ApexEvent expectedEvent = new ApexEvent(eventName, eventVersion, nameSpace, source, target);
+ final ApexEvent expectedEvent =
+ new ApexEvent(eventName, eventVersion, nameSpace, source, target, toscaPolicyState);
// Reset executionId
expectedEvent.setExecutionId(0);
@@ -125,13 +127,14 @@ class Apex2JmsTextEventConverterTest {
final String source = RandomStringUtils.randomAlphabetic(6);
final String target = RandomStringUtils.randomAlphabetic(7);
- final String expected = "{\n" +
- " \"name\": \"" + name + "\",\n" +
- " \"version\": \"" + version + "\",\n" +
- " \"nameSpace\": \"" + nameSpace + "\",\n" +
- " \"source\": \"" + source + "\",\n" +
- " \"target\": \"" + target + "\"\n" +
- "}";
+ final String expected = "{\n"
+ + " \"name\": \"" + name + "\",\n"
+ + " \"version\": \"" + version + "\",\n"
+ + " \"nameSpace\": \"" + nameSpace + "\",\n"
+ + " \"source\": \"" + source + "\",\n"
+ + " \"target\": \"" + target + "\",\n"
+ + " \"toscaPolicyState\": null\n"
+ + "}";
// Prepare Model service
final AxArtifactKey eventKey = new AxArtifactKey(name + ":" + version);
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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java
index 1f480a654..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/test/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParametersTest.java