diff options
author | 2018-03-28 17:22:56 +0100 | |
---|---|---|
committer | 2018-03-29 18:38:17 +0100 | |
commit | 837cbcdc2562c0cd041ed558d05bb7dbba4be603 (patch) | |
tree | 370e72f52e0420e0fa633de73a6fd47d03d17422 /src/test/java/org/onap/crud/event/response | |
parent | 0c19b1386259b7144bc6c95954f965c469835522 (diff) |
Update published event to include header and body
Originally, the published event only contained the raw graph
request payload.
This has now been updated to include the following changes:
- encapsulate the graph request in a body property
- add new event header with details such as timestamp, request-id,
event-type
Issue-ID: AAI-954
Change-Id: I780b6f52a01aafdcd7d09156e9d3a99c25be90a3
Signed-off-by: Michael Arrastia <MArrasti@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap/crud/event/response')
-rw-r--r-- | src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java b/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java new file mode 100644 index 0000000..5c0da98 --- /dev/null +++ b/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java @@ -0,0 +1,31 @@ +package org.onap.crud.event.response; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import org.junit.Test; +import org.onap.crud.event.envelope.GraphEventEnvelope; +import org.onap.crud.test.util.TestUtil; +import com.google.gson.Gson; + +public class GraphEventResponseHandlerTest { + + @Test + public void testPolicyViolationsNotDetected() throws Exception { + String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel-no-violations.json"); + Gson gson = new Gson(); + GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class); + + GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler(); + assertThat(graphEventResponseHandler.hasPolicyViolations(envelope), is(false)); + } + + @Test + public void testPolicyViolationsDetected() throws Exception { + String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel.json"); + Gson gson = new Gson(); + GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class); + + GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler(); + assertThat(graphEventResponseHandler.hasPolicyViolations(envelope), is(true)); + } +} |