|
@@ -51,13 +51,13 @@ import static org.mockito.Mockito.verify;
|
51
|
51
|
import static org.mockito.Mockito.when;
|
52
|
52
|
|
53
|
53
|
@RunWith(MockitoJUnitRunner.class)
|
54
|
|
-public class ErrorReporterTest {
|
|
54
|
+public class SentryErrorReporterTest {
|
55
|
55
|
|
56
|
56
|
private static RavenFactory ravenFactory;
|
57
|
57
|
@Mock private Raven raven;
|
58
|
58
|
@Mock private ClientInfo clientInfo;
|
59
|
59
|
@Captor private ArgumentCaptor<Event> eventCaptor;
|
60
|
|
- private ErrorReporter errorReporter;
|
|
60
|
+ private SentryErrorReporter sentryErrorReporter;
|
61
|
61
|
|
62
|
62
|
@BeforeClass
|
63
|
63
|
public static void setUpClass() {
|
|
@@ -69,12 +69,12 @@ public class ErrorReporterTest {
|
69
|
69
|
@Before
|
70
|
70
|
public void setUp() {
|
71
|
71
|
when(ravenFactory.createRavenInstance(Matchers.<Dsn>anyObject())).thenReturn(raven);
|
72
|
|
- errorReporter = new ErrorReporter(clientInfo);
|
|
72
|
+ sentryErrorReporter = new SentryErrorReporter(clientInfo);
|
73
|
73
|
}
|
74
|
74
|
|
75
|
75
|
@Test
|
76
|
76
|
public void testSendsMessage() {
|
77
|
|
- errorReporter.sendException("message 123", ErrorLevel.MEDIUM, new Date(), null, null);
|
|
77
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.MEDIUM, new Date(), null, null);
|
78
|
78
|
verify(raven).sendEvent(eventCaptor.capture());
|
79
|
79
|
assertEquals("message 123", eventCaptor.getValue().getMessage());
|
80
|
80
|
}
|
|
@@ -82,49 +82,49 @@ public class ErrorReporterTest {
|
82
|
82
|
@Test
|
83
|
83
|
public void testSendsTimestamp() {
|
84
|
84
|
final Date date = new Date(561859200000l);
|
85
|
|
- errorReporter.sendException("message 123", ErrorLevel.MEDIUM, date, null, null);
|
|
85
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.MEDIUM, date, null, null);
|
86
|
86
|
verify(raven).sendEvent(eventCaptor.capture());
|
87
|
87
|
assertEquals(date, eventCaptor.getValue().getTimestamp());
|
88
|
88
|
}
|
89
|
89
|
|
90
|
90
|
@Test
|
91
|
91
|
public void testSendsLowLevelAsInfo() {
|
92
|
|
- errorReporter.sendException("message 123", ErrorLevel.LOW, new Date(), null, null);
|
|
92
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.LOW, new Date(), null, null);
|
93
|
93
|
verify(raven).sendEvent(eventCaptor.capture());
|
94
|
94
|
assertEquals(Event.Level.INFO, eventCaptor.getValue().getLevel());
|
95
|
95
|
}
|
96
|
96
|
|
97
|
97
|
@Test
|
98
|
98
|
public void testSendsMediumLevelAsWarning() {
|
99
|
|
- errorReporter.sendException("message 123", ErrorLevel.MEDIUM, new Date(), null, null);
|
|
99
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.MEDIUM, new Date(), null, null);
|
100
|
100
|
verify(raven).sendEvent(eventCaptor.capture());
|
101
|
101
|
assertEquals(Event.Level.WARNING, eventCaptor.getValue().getLevel());
|
102
|
102
|
}
|
103
|
103
|
|
104
|
104
|
@Test
|
105
|
105
|
public void testSendsHighLevelAsError() {
|
106
|
|
- errorReporter.sendException("message 123", ErrorLevel.HIGH, new Date(), null, null);
|
|
106
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.HIGH, new Date(), null, null);
|
107
|
107
|
verify(raven).sendEvent(eventCaptor.capture());
|
108
|
108
|
assertEquals(Event.Level.ERROR, eventCaptor.getValue().getLevel());
|
109
|
109
|
}
|
110
|
110
|
|
111
|
111
|
@Test
|
112
|
112
|
public void testSendsFatalLevelAsFatal() {
|
113
|
|
- errorReporter.sendException("message 123", ErrorLevel.FATAL, new Date(), null, null);
|
|
113
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.FATAL, new Date(), null, null);
|
114
|
114
|
verify(raven).sendEvent(eventCaptor.capture());
|
115
|
115
|
assertEquals(Event.Level.FATAL, eventCaptor.getValue().getLevel());
|
116
|
116
|
}
|
117
|
117
|
|
118
|
118
|
@Test
|
119
|
119
|
public void testSendsUnknownLevelAsInfo() {
|
120
|
|
- errorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), null, null);
|
|
120
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), null, null);
|
121
|
121
|
verify(raven).sendEvent(eventCaptor.capture());
|
122
|
122
|
assertEquals(Event.Level.INFO, eventCaptor.getValue().getLevel());
|
123
|
123
|
}
|
124
|
124
|
|
125
|
125
|
@Test
|
126
|
126
|
public void testAddsDetailsAsExtra() {
|
127
|
|
- errorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), null,
|
|
127
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), null,
|
128
|
128
|
"details 456");
|
129
|
129
|
verify(raven).sendEvent(eventCaptor.capture());
|
130
|
130
|
assertEquals("details 456", eventCaptor.getValue().getExtra().get("details"));
|
|
@@ -133,7 +133,7 @@ public class ErrorReporterTest {
|
133
|
133
|
@Test
|
134
|
134
|
public void testAddsExceptionInterface() {
|
135
|
135
|
final Exception exception = new IndexOutOfBoundsException("Message blah");
|
136
|
|
- errorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), exception, null);
|
|
136
|
+ sentryErrorReporter.sendException("message 123", ErrorLevel.UNKNOWN, new Date(), exception, null);
|
137
|
137
|
verify(raven).sendEvent(eventCaptor.capture());
|
138
|
138
|
final SentryInterface iface = eventCaptor.getValue().getSentryInterfaces()
|
139
|
139
|
.get(ExceptionInterface.EXCEPTION_INTERFACE);
|