Skip to content

Commit fe7c478

Browse files
committed
add test for multiple errors in a session
1 parent ebec0cb commit fe7c478

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

bugsnag/src/test/java/com/bugsnag/BugsnagTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,29 @@ public void close() {
510510
assertTrue(bugsnag.notify(new Throwable()));
511511
}
512512

513+
@Test
514+
public void testMultipleHandledIncrementWithSession() {
515+
bugsnag.startSession();
516+
StubNotificationDelivery testDelivery = new StubNotificationDelivery();
517+
bugsnag.setDelivery(testDelivery);
518+
519+
assertTrue(bugsnag.notify(new Throwable()));
520+
assertTrue(bugsnag.notify(new Throwable()));
521+
assertTrue(bugsnag.notify(new Throwable()));
522+
523+
for (int i = 0 ; i < testDelivery.getNotifications().size(); i++) {
524+
Report report = testDelivery.getNotifications().get(i).getEvents().get(0);
525+
526+
Map<String, Object> session = report.getSession();
527+
assertNotNull(session);
528+
529+
@SuppressWarnings("unchecked")
530+
Map<String, Object> handledCounts = (Map<String, Object>) session.get("events");
531+
assertEquals(i + 1, handledCounts.get("handled"));
532+
assertEquals(0, handledCounts.get("unhandled"));
533+
}
534+
}
535+
513536
@Test
514537
public void testSerialization() {
515538
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();

0 commit comments

Comments
 (0)