aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgregory.hayes <gregory.hayes@est.tech>2020-12-09 20:42:33 +0000
committergregory.hayes <gregory.hayes@est.tech>2020-12-17 16:23:57 +0000
commita3979b8a14f6e67de406b29c3e0ad0c516c3bc54 (patch)
tree13f0b33e9d5ace049fa5b99b036aed7df557c712
parente267120c204303088f3c15e580a5e1a364e014f5 (diff)
Prune superfluous log and exception messages
Large volume exception messages should not be repeated in log messages or in rethrown exceptions. Jira-Link: https://jira.onap.org/browse/POLICY-2885 Issue-ID: POLICY-2885 Signed-off-by: gregory.hayes <gregory.hayes@est.tech> Change-Id: I345531d3a7640cc5ad9dbfc367052b9c8cc19387
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java1
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java4
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java1
-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
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java3
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java10
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java17
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java33
10 files changed, 58 insertions, 50 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
index 9fbc36116..88980762f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
@@ -179,7 +179,6 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
eventReceiver.receiveEvent(new Properties(), jmsMessage);
} catch (final Exception e) {
final String errorMessage = "failed to receive message from JMS";
- LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage, e);
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
index 39d0023d2..80ccda729 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
@@ -160,10 +160,10 @@ public class ApexRestServerConsumer extends ApexPluginsEventConsumer {
// Send the event into Apex
eventReceiver.receiveEvent(executionId, new Properties(), event);
} catch (final Exception e) {
- final String errorMessage = "error receiving events on event consumer " + name + ", " + e.getMessage();
+ final String errorMessage = "error receiving events on event consumer " + name;
LOGGER.warn(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
- .entity("{'errorMessage', '" + errorMessage + "'}").build();
+ .entity("{'errorMessage', '" + errorMessage + ", " + e.getMessage() + "'}").build();
}
final SynchronousEventCache synchronousEventCache =
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
index 44f010cd0..0f6735e0e 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
@@ -130,7 +130,6 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
final JAXBElement<XMLApexEvent> rootElement = unmarshaller.unmarshal(source, XMLApexEvent.class);
xmlApexEvent = rootElement.getValue();
} catch (final JAXBException e) {
- LOGGER.warn("Unable to unmarshal Apex XML event\n" + xmlEventString, e);
throw new ApexEventException("Unable to unmarshal Apex XML event\n" + xmlEventString, e);
}
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");
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
index 459a2c4bf..e8e592b09 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,10 +111,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
eventList.add(jsonStringApexEvent(eventName, jsonEventString));
}
} catch (final Exception e) {
- final String errorString = "Failed to unmarshal JSON event: " + e.getMessage() + ", event="
- + jsonEventString;
- LOGGER.warn(errorString, e);
- throw new ApexEventException(errorString, e);
+ throw new ApexEventException("Failed to unmarshal JSON event, event=" + jsonEventString, e);
}
// Return the list of events we have unmarshalled
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
index dc9854158..fd6ac4489 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
@@ -263,8 +263,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
break;
} catch (ApexException e) {
if (!iterator.hasNext()) {
- final String errorMessage = "Error while converting event into an ApexEvent for " + name + ": "
- + e.getMessage() + ", Event=" + event;
+ final String errorMessage = "Error while converting event into an ApexEvent for " + name;
throw new ApexEventException(errorMessage, e);
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
index ceadc4aae..a7d08bb55 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
@@ -49,11 +49,13 @@ public class JsonEventConverterTest {
assertThatThrownBy(() -> converter.toApexEvent(null, 1))
.hasMessage("error converting event \"1\" to a string");
assertThatThrownBy(() -> converter.toApexEvent(null, "[{\"aKey\": 1},{\"aKey\": 2}]"))
- .hasMessage("Failed to unmarshal JSON event: event received without mandatory parameter \"name\" "
- + "on configuration or on event, event=[{\"aKey\": 1},{\"aKey\": 2}]");
+ .hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\" "
+ + "on configuration or on event");
assertThatThrownBy(() -> converter.toApexEvent(null, "[1,2,3]"))
- .hasMessage("Failed to unmarshal JSON event: incoming event ([1,2,3]) is a JSON object array "
- + "containing an invalid object 1.0, event=[1,2,3]");
+ .hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("incoming event ([1,2,3]) is a JSON object array "
+ + "containing an invalid object 1.0");
assertThatThrownBy(() -> converter.fromApexEvent(null))
.hasMessage("event processing failed, Apex event is null");
assertThatThrownBy(() -> converter.fromApexEvent(new ApexEvent("Event", "0.0.1", "a.name.space",
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java
index de84acca1..c58cb085d 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java
@@ -217,15 +217,18 @@ public class JsonEventHandlerForPojoTest {
logger.debug("input event\n" + apexEventJsonStringIn);
assertThatThrownBy(() -> jsonEventConverter.toApexEvent("PojoEvent", apexEventJsonStringIn))
- .hasMessageContaining("Failed to unmarshal JSON event: error parsing PojoEvent:0.0.1 event from Json. "
- + "Field BAD_POJO_PAR not found on POJO event definition.");
+ .hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("error parsing PojoEvent:0.0.1 event from Json. "
+ + "Field BAD_POJO_PAR not found on POJO event definition.");
pars.setPojoField("POJO_PAR");
assertThatThrownBy(() -> jsonEventConverter.toApexEvent("PojoNoFieldEvent", apexEventJsonStringIn))
- .hasMessageContaining("Failed to unmarshal JSON event: error parsing PojoNoFieldEvent:0.0.1 "
- + "event from Json, Field POJO_PAR not found, no fields defined on event.");
+ .hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("error parsing PojoNoFieldEvent:0.0.1 "
+ + "event from Json, Field POJO_PAR not found, no fields defined on event.");
assertThatThrownBy(() -> jsonEventConverter.toApexEvent("PojoTooManyFieldsEvent", apexEventJsonStringIn))
- .hasMessageContaining("Failed to unmarshal JSON event: error parsing PojoTooManyFieldsEvent:0.0.1"
- + " event from Json, Field POJO_PAR, one and only one field may be defined on a "
- + "POJO event definition.");
+ .hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("error parsing PojoTooManyFieldsEvent:0.0.1"
+ + " event from Json, Field POJO_PAR, one and only one field may be defined on a "
+ + "POJO event definition.");
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
index 241c92978..fdb886e10 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
@@ -144,18 +144,20 @@ public class JsonEventHandlerTest {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventNoName();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: event received without "
- + "mandatory parameter \"name\" ");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("event received without mandatory parameter \"name\" ");
assertThatThrownBy(() -> {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventBadName();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: field \"name\" with value \"%%%%\" is invalid");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("field \"name\" with value \"%%%%\" is invalid");
assertThatThrownBy(() -> {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventNoExName();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: an event definition for an event named \"I_DONT_EXI");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("an event definition for an event named \"I_DONT_EXI");
String apexEventJsonStringIn1 = null;
apexEventJsonStringIn1 = SupportJsonEventGenerator.jsonEventNoVersion();
ApexEvent event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn1).get(0);
@@ -164,12 +166,14 @@ public class JsonEventHandlerTest {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventBadVersion();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: field \"version\" with value \"#####\" is invalid");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("field \"version\" with value \"#####\" is invalid");
assertThatThrownBy(() -> {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventNoExVersion();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: an event definition for an event named "
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("an event definition for an event named "
+ "\"BasicEvent\" with version \"1.2.3\" not found in Apex model");
apexEventJsonStringIn1 = SupportJsonEventGenerator.jsonEventNoNamespace();
event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn1).get(0);
@@ -179,13 +183,14 @@ public class JsonEventHandlerTest {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventBadNamespace();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: " + "field \"nameSpace\" with value \"hello.&&&&\" "
- + "is invalid");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("field \"nameSpace\" with value \"hello.&&&&\" is invalid");
assertThatThrownBy(() -> {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventNoExNamespace();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: namespace \"pie.in.the.sky\" "
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("namespace \"pie.in.the.sky\" "
+ "on event \"BasicEvent\" does not" + " match namespace \"org.onap.policy.apex.events\" "
+ "for that event in the Apex model");
apexEventJsonStringIn1 = SupportJsonEventGenerator.jsonEventNoSource();
@@ -196,7 +201,8 @@ public class JsonEventHandlerTest {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventBadSource();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: field \"source\" with value \"%!@**@!\" is invalid");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("field \"source\" with value \"%!@**@!\" is invalid");
apexEventJsonStringIn1 = SupportJsonEventGenerator.jsonEventNoTarget();
event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn1).get(0);
assertEquals("target", event.getTarget());
@@ -205,13 +211,14 @@ public class JsonEventHandlerTest {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventBadTarget();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: field \"target\" with value \"KNIO(*S)A(S)D\" "
- + "is invalid");
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("field \"target\" with value \"KNIO(*S)A(S)D\" is invalid");
assertThatThrownBy(() -> {
String apexEventJsonStringIn = null;
apexEventJsonStringIn = SupportJsonEventGenerator.jsonEventMissingFields();
jsonEventConverter.toApexEvent(null, apexEventJsonStringIn);
- }).hasMessageContaining("Failed to unmarshal JSON event: error parsing BasicEvent:0.0.1 "
+ }).hasMessageStartingWith("Failed to unmarshal JSON event")
+ .getCause().hasMessageStartingWith("error parsing BasicEvent:0.0.1 "
+ "event from Json. Field \"intPar\" is missing, but is mandatory.");
apexEventJsonStringIn1 = SupportJsonEventGenerator.jsonEventNullFields();
event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn1).get(0);