Skip to content

Commit

Permalink
Add sendEvent(EventBuilder) method which calls builder helpers before…
Browse files Browse the repository at this point in the history
… building and sending the Event. (#218)
  • Loading branch information
bretthoerner committed Jun 10, 2016
1 parent ab7edd2 commit deb7a83
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -2,6 +2,7 @@ Version 7.2.4
-------------

- Add (manual) support for breadcrumbs to event objects.
- Add ``sendEvent(EventBuilder)`` method which calls builder helpers before building and sending the ``Event``.

Version 7.2.3
-------------
Expand Down
10 changes: 10 additions & 0 deletions raven/src/main/java/com/getsentry/raven/Raven.java
Expand Up @@ -51,6 +51,16 @@ public void sendEvent(Event event) {
}
}

/**
* Builds and sends an {@link Event} to the Sentry server.
*
* @param eventBuilder {@link EventBuilder} to send to Sentry.
*/
public void sendEvent(EventBuilder eventBuilder) {
runBuilderHelpers(eventBuilder);
sendEvent(eventBuilder.build());
}

/**
* Sends a message to the Sentry server.
* <p>
Expand Down
18 changes: 18 additions & 0 deletions raven/src/test/java/com/getsentry/raven/RavenTest.java
Expand Up @@ -35,6 +35,24 @@ public void testSendEvent() throws Exception {
}};
}

@Test
public void testSendEventBuilder() throws Exception {
final String message = "e960981e-656d-4404-9b1d-43b483d3f32c";
raven.addBuilderHelper(mockEventBuilderHelper);

raven.sendEvent(new EventBuilder()
.withMessage(message)
.withLevel(Event.Level.INFO));

new Verifications() {{
Event event;
mockEventBuilderHelper.helpBuildingEvent((EventBuilder) any);
mockConnection.send(event = withCapture());
assertThat(event.getLevel(), equalTo(Event.Level.INFO));
assertThat(event.getMessage(), equalTo(message));
}};
}

@Test
public void testSendEventFailingIsCaught() throws Exception {
new NonStrictExpectations() {{
Expand Down

0 comments on commit deb7a83

Please sign in to comment.