summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2020-12-21 10:05:51 +0000
committerGerrit Code Review <gerrit@onap.org>2020-12-21 10:05:51 +0000
commit8cbea70d818013eaec06d17b9620453168649ef2 (patch)
treeb0dbee142b7c26bc49b64c2ab2a9c546b837bd65 /plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src
parent395b49a08401890e7fa3af1fc869e4049a4bda36 (diff)
parenta3979b8a14f6e67de406b29c3e0ad0c516c3bc54 (diff)
Merge "Prune superfluous log and exception messages"
Diffstat (limited to 'plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src')
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java6
-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.java26
2 files changed, 17 insertions, 15 deletions
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
index e6ee090e4..59c9c21c1 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
@@ -112,10 +112,8 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
try {
eventList.add(yamlMap2ApexEvent(eventName, yamlMap));
} catch (final Exception e) {
- final String errorString = "Failed to unmarshal YAML event: " + e.getMessage() + ", event="
- + yamlEventString;
- LOGGER.warn(errorString, e);
- throw new ApexEventException(errorString, e);
+ throw new ApexEventException("Failed to unmarshal YAML event, event="
+ + yamlEventString, e);
}
// Return the list of events we have unmarshalled
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 398bddb16..0577be703 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
@@ -21,8 +21,11 @@
package org.onap.policy.apex.plugins.event.protocol.yaml;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -118,14 +121,14 @@ public class YamlPluginStabilityTest {
converter.init(pars);
assertThatThrownBy(() -> converter.toApexEvent("NonExistantEvent", ""))
- .hasMessageContaining("Failed to unmarshal YAML event: an event definition for an event named "
- + "\"NonExistantEvent\"");
+ .hasMessageContaining("Failed to unmarshal YAML event")
+ .getCause().hasMessageStartingWith("an event definition for an event named \"NonExistantEvent\"");
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", ""))
- .hasMessageContaining("Field \"doubleValue\" is missing");
+ .getCause().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(),
@@ -142,12 +145,12 @@ public class YamlPluginStabilityTest {
assertThatThrownBy(() -> converter.fromApexEvent(apexEvent))
.hasMessageContaining("error parsing TestEvent:0.0.1 event to Json. Field \"intValue\" is missing");
assertThatThrownBy(() -> converter.toApexEvent(null, ""))
- .hasMessageContaining("Failed to unmarshal YAML event: event received without mandatory parameter"
- + " \"name\"");
+ .hasMessageStartingWith("Failed to unmarshal YAML event")
+ .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
pars.setNameAlias("TheNameField");
assertThatThrownBy(() -> converter.toApexEvent(null, ""))
- .hasMessageContaining("Failed to unmarshal YAML event: event received without mandatory parameter"
- + " \"name\"");
+ .hasMessageStartingWith("Failed to unmarshal YAML event")
+ .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\"");
apexEvent.put("intValue", 123);
apexEvent.remove("stringValue");
@@ -184,7 +187,8 @@ public class YamlPluginStabilityTest {
pars.setNameSpaceAlias("stringValue");
final String yamlInputStringCopy = yamlInputString;
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", yamlInputStringCopy))
- .hasMessageContaining("Failed to unmarshal YAML event: namespace \"org.some.other.namespace\" on event");
+ .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";
eventList = converter.toApexEvent("TestEvent", yamlInputString);
@@ -207,11 +211,11 @@ public class YamlPluginStabilityTest {
pars.setSourceAlias(null);
pars.setTargetAlias("intValue");
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", yamlInputStringCopy))
- .hasMessageContaining("Failed to unmarshal YAML event: field \"target\" with type \"java.lang.Integer\"");
+ .hasMessageStartingWith("Failed to unmarshal YAML event")
+ .getCause().hasMessageStartingWith("field \"target\" with type \"java.lang.Integer\"");
pars.setTargetAlias(null);
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", "doubleValue: 123.45\n" + "intValue: ~\n"
- + "stringValue: MyString"))
- .hasMessageContaining("mandatory field \"intValue\" is missing");
+ + "stringValue: MyString")).getCause().hasMessageStartingWith("mandatory field \"intValue\" is missing");
}
}