Update published event to include header and body
[aai/gizmo.git] / src / test / java / org / onap / crud / event / response / GraphEventResponseHandlerTest.java
1 package org.onap.crud.event.response;
2
3 import static org.hamcrest.Matchers.is;
4 import static org.junit.Assert.assertThat;
5 import org.junit.Test;
6 import org.onap.crud.event.envelope.GraphEventEnvelope;
7 import org.onap.crud.test.util.TestUtil;
8 import com.google.gson.Gson;
9
10 public class GraphEventResponseHandlerTest {
11
12     @Test
13     public void testPolicyViolationsNotDetected() throws Exception {
14         String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel-no-violations.json");
15         Gson gson = new Gson();
16         GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
17
18         GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
19         assertThat(graphEventResponseHandler.hasPolicyViolations(envelope), is(false));
20     }
21
22     @Test
23     public void testPolicyViolationsDetected() throws Exception {
24         String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel.json");
25         Gson gson = new Gson();
26         GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
27
28         GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
29         assertThat(graphEventResponseHandler.hasPolicyViolations(envelope), is(true));
30     }
31 }