@@ -44,7 +44,6 @@ public class RollbarAppenderTest {
44
44
static {
45
45
MDC .put ("mdc_key_1" , "mdc_value_1" );
46
46
}
47
-
48
47
private static String NESTED_EXCEPTION_MESSAGE = "This is the nested exception message" ;
49
48
50
49
private static final Exception NESTED_EXCEPTION =
@@ -53,6 +52,7 @@ public class RollbarAppenderTest {
53
52
private static final Exception EXCEPTION =
54
53
new IllegalArgumentException (EXCEPTION_MESSAGE , NESTED_EXCEPTION );
55
54
55
+ private static final Object [] ARGUMENT_ARRAY = {"arg_1" , 17 };
56
56
@ Rule
57
57
public MockitoRule rule = MockitoJUnit .rule ();
58
58
@@ -104,11 +104,12 @@ public void shouldLogEventWithAllInformationFromThrowableProxyWithThrowable() {
104
104
when (event .getThrowableProxy ()).thenReturn (rootThrowableProxy );
105
105
when (event .getMDCPropertyMap ()).thenReturn (MDC );
106
106
when (event .getFormattedMessage ()).thenReturn (FORMATTED_MESSAGE );
107
+ when (event .getArgumentArray ()).thenReturn (ARGUMENT_ARRAY );
107
108
108
109
sut .append (event );
109
110
110
111
Map <String , Object > expectedCustom = buildExpectedCustom (LOGGER_NAME ,
111
- new HashMap <String , Object >(MDC ), MARKER_NAME , THREAD_NAME );
112
+ new HashMap <String , Object >(MDC ), MARKER_NAME , THREAD_NAME , ARGUMENT_ARRAY );
112
113
113
114
verify (rollbar ).log (rootThrowableWrapper , expectedCustom , FORMATTED_MESSAGE , Level .ERROR , false );
114
115
}
@@ -121,11 +122,12 @@ public void shouldLogEventWhenNoMarker() {
121
122
when (event .getThrowableProxy ()).thenReturn (rootThrowableProxy );
122
123
when (event .getMDCPropertyMap ()).thenReturn (MDC );
123
124
when (event .getFormattedMessage ()).thenReturn (FORMATTED_MESSAGE );
125
+ when (event .getArgumentArray ()).thenReturn (ARGUMENT_ARRAY );
124
126
125
127
sut .append (event );
126
128
127
129
Map <String , Object > expectedCustom = buildExpectedCustom (LOGGER_NAME ,
128
- new HashMap <String , Object >(MDC ), null , THREAD_NAME );
130
+ new HashMap <String , Object >(MDC ), null , THREAD_NAME , ARGUMENT_ARRAY );
129
131
130
132
verify (rollbar ).log (rootThrowableWrapper , expectedCustom , FORMATTED_MESSAGE , Level .ERROR , false );
131
133
}
@@ -138,24 +140,45 @@ public void shouldLogEventWhenNoMDC() {
138
140
when (event .getLevel ()).thenReturn (ch .qos .logback .classic .Level .ERROR );
139
141
when (event .getThrowableProxy ()).thenReturn (rootThrowableProxy );
140
142
when (event .getFormattedMessage ()).thenReturn (FORMATTED_MESSAGE );
143
+ when (event .getArgumentArray ()).thenReturn (ARGUMENT_ARRAY );
144
+
145
+ sut .append (event );
146
+
147
+ Map <String , Object > expectedCustom = buildExpectedCustom (LOGGER_NAME ,
148
+ null , MARKER_NAME , THREAD_NAME , ARGUMENT_ARRAY );
149
+
150
+ verify (rollbar ).log (rootThrowableWrapper , expectedCustom , FORMATTED_MESSAGE , Level .ERROR , false );
151
+ }
152
+
153
+ @ Test
154
+ public void shouldLogEventWhenNoArgumentArray () {
155
+ when (event .getLoggerName ()).thenReturn (LOGGER_NAME );
156
+ when (event .getMarker ()).thenReturn (marker );
157
+ when (event .getThreadName ()).thenReturn (THREAD_NAME );
158
+ when (event .getLevel ()).thenReturn (ch .qos .logback .classic .Level .ERROR );
159
+ when (event .getThrowableProxy ()).thenReturn (rootThrowableProxy );
160
+ when (event .getMDCPropertyMap ()).thenReturn (MDC );
161
+ when (event .getFormattedMessage ()).thenReturn (FORMATTED_MESSAGE );
162
+ when (event .getArgumentArray ()).thenReturn (null );
141
163
142
164
sut .append (event );
143
165
144
166
Map <String , Object > expectedCustom = buildExpectedCustom (LOGGER_NAME ,
145
- null , MARKER_NAME , THREAD_NAME );
167
+ new HashMap < String , Object >( MDC ), MARKER_NAME , THREAD_NAME , null );
146
168
147
169
verify (rollbar ).log (rootThrowableWrapper , expectedCustom , FORMATTED_MESSAGE , Level .ERROR , false );
148
170
}
149
171
150
172
private static Map <String , Object > buildExpectedCustom (String loggerName , Map <String , Object > mdc ,
151
- String markerName , String threadName ) {
173
+ String markerName , String threadName , Object [] argumentArray ) {
152
174
Map <String , Object > rootCustom = new HashMap <>();
153
175
Map <String , Object > custom = new HashMap <>();
154
176
155
177
custom .put ("loggerName" , loggerName );
156
178
custom .put ("threadName" , threadName );
157
179
custom .put ("marker" , markerName );
158
180
custom .put ("mdc" , mdc );
181
+ custom .put ("argumentArray" , argumentArray );
159
182
160
183
rootCustom .put ("rollbar-logback" , custom );
161
184
0 commit comments