@@ -106,7 +106,7 @@ public class Span2JsonCodecTest {
106
106
.isEqualTo (worstSpanInTheWorld );
107
107
}
108
108
109
- @ Test public void niceErrorOnUppercaseTraceId () {
109
+ @ Test public void niceErrorOnUppercase_traceId () {
110
110
thrown .expect (IllegalArgumentException .class );
111
111
thrown .expectMessage (
112
112
"48485A3953BB6124 should be a 1 to 32 character lower-hex string with no prefix" );
@@ -120,21 +120,21 @@ public class Span2JsonCodecTest {
120
120
codec .readSpan (json .getBytes (UTF_8 ));
121
121
}
122
122
123
- @ Test public void decentErrorMessageOnEmptyInput_span () throws IOException {
123
+ @ Test public void niceErrorOnEmpty_inputSpan () throws IOException {
124
124
thrown .expect (IllegalArgumentException .class );
125
125
thrown .expectMessage ("Empty input reading Span2" );
126
126
127
127
codec .readSpan (new byte [0 ]);
128
128
}
129
129
130
- @ Test public void decentErrorMessageOnEmptyInput_spans () throws IOException {
130
+ @ Test public void niceErrorOnEmpty_inputSpans () throws IOException {
131
131
thrown .expect (IllegalArgumentException .class );
132
132
thrown .expectMessage ("Empty input reading List<Span2>" );
133
133
134
134
codec .readSpans (new byte [0 ]);
135
135
}
136
136
137
- @ Test public void decentErrorMessageOnMalformedInput_span () throws IOException {
137
+ @ Test public void niceErrorOnMalformed_inputSpan () throws IOException {
138
138
thrown .expect (IllegalArgumentException .class );
139
139
thrown .expectMessage ("Malformed reading Span2 from " );
140
140
@@ -144,7 +144,7 @@ public class Span2JsonCodecTest {
144
144
/**
145
145
* Particulary, thrift can mistake malformed content as a huge list. Let's not blow up.
146
146
*/
147
- @ Test public void decentErrorMessageOnMalformedInput_spans () throws IOException {
147
+ @ Test public void niceErrorOnMalformed_inputSpans () throws IOException {
148
148
thrown .expect (IllegalArgumentException .class );
149
149
thrown .expectMessage ("Malformed reading List<Span2> from " );
150
150
@@ -187,78 +187,71 @@ public class Span2JsonCodecTest {
187
187
.traceIdHigh (Util .lowerHexToUnsignedLong ("48485a3953bb6124" )).build ());
188
188
}
189
189
190
- @ Test public void ignoreNull_parentId () {
190
+ @ Test public void ignoresNull_topLevelFields () {
191
191
String json = "{\n "
192
192
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
193
- + " \" name \" : \" get-traces \" ,\n "
193
+ + " \" parentId \" : null ,\n "
194
194
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
195
- + " \" parentId\" : null\n "
196
- + "}" ;
197
-
198
- codec .readSpan (json .getBytes (UTF_8 ));
199
- }
200
-
201
- @ Test public void ignoreNull_timestamp () {
202
- String json = "{\n "
203
- + " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
204
- + " \" name\" : \" get-traces\" ,\n "
205
- + " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
206
- + " \" timestamp\" : null\n "
195
+ + " \" name\" : null,\n "
196
+ + " \" timestamp\" : null,\n "
197
+ + " \" duration\" : null,\n "
198
+ + " \" localEndpoint\" : null,\n "
199
+ + " \" remoteEndpoint\" : null,\n "
200
+ + " \" annotations\" : null,\n "
201
+ + " \" tags\" : null,\n "
202
+ + " \" debug\" : null,\n "
203
+ + " \" shared\" : null\n "
207
204
+ "}" ;
208
205
209
206
codec .readSpan (json .getBytes (UTF_8 ));
210
207
}
211
208
212
- @ Test public void ignoreNull_duration () {
209
+ @ Test public void ignoresNull_endpoint_topLevelFields () {
213
210
String json = "{\n "
214
211
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
215
212
+ " \" name\" : \" get-traces\" ,\n "
216
213
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
217
- + " \" duration\" : null\n "
214
+ + " \" localEndpoint\" : {\n "
215
+ + " \" serviceName\" : null,\n "
216
+ + " \" ipv4\" : \" 127.0.0.1\" ,\n "
217
+ + " \" ipv6\" : null,\n "
218
+ + " \" port\" : null\n "
219
+ + " }\n "
218
220
+ "}" ;
219
221
220
- codec .readSpan (json .getBytes (UTF_8 ));
222
+ assertThat (codec .readSpan (json .getBytes (UTF_8 )).localEndpoint ())
223
+ .isEqualTo (Endpoint .create ("" , 127 << 24 | 1 ));
221
224
}
222
225
223
- @ Test public void ignoreNull_debug () {
224
- String json = "{\n "
225
- + " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
226
- + " \" name\" : \" get-traces\" ,\n "
227
- + " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
228
- + " \" debug\" : null\n "
229
- + "}" ;
230
-
231
- codec .readSpan (json .getBytes (UTF_8 ));
232
- }
226
+ @ Test public void niceErrorOnIncomplete_endpoint () {
227
+ thrown .expect (IllegalArgumentException .class );
228
+ thrown .expectMessage ("Empty endpoint at $.localEndpoint reading Span2 from json" );
233
229
234
- @ Test public void ignoreNull_shared () {
235
230
String json = "{\n "
236
231
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
237
232
+ " \" name\" : \" get-traces\" ,\n "
238
233
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
239
- + " \" shared\" : null\n "
234
+ + " \" localEndpoint\" : {\n "
235
+ + " \" serviceName\" : null,\n "
236
+ + " \" ipv4\" : null,\n "
237
+ + " \" ipv6\" : null,\n "
238
+ + " \" port\" : null\n "
239
+ + " }\n "
240
240
+ "}" ;
241
-
242
241
codec .readSpan (json .getBytes (UTF_8 ));
243
242
}
244
243
245
- @ Test public void ignoreNull_localEndpoint () {
246
- String json = "{\n "
247
- + " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
248
- + " \" name\" : \" get-traces\" ,\n "
249
- + " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
250
- + " \" localEndpoint\" : null\n "
251
- + "}" ;
252
-
253
- codec .readSpan (json .getBytes (UTF_8 ));
254
- }
244
+ @ Test public void niceErrorOnIncomplete_annotation () {
245
+ thrown .expect (IllegalArgumentException .class );
246
+ thrown .expectMessage ("Incomplete annotation at $.annotations[0]" );
255
247
256
- @ Test public void ignoreNull_remoteEndpoint () {
257
248
String json = "{\n "
258
249
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
259
250
+ " \" name\" : \" get-traces\" ,\n "
260
251
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
261
- + " \" remoteEndpoint\" : null\n "
252
+ + " \" annotations\" : [\n "
253
+ + " { \" timestamp\" : 1472470996199000}\n "
254
+ + " ]\n "
262
255
+ "}" ;
263
256
264
257
codec .readSpan (json .getBytes (UTF_8 ));
@@ -290,7 +283,7 @@ public class Span2JsonCodecTest {
290
283
codec .readSpan (json .getBytes (UTF_8 ));
291
284
}
292
285
293
- @ Test public void missingValue () {
286
+ @ Test public void niceErrorOnNull_tagValue () {
294
287
thrown .expect (IllegalArgumentException .class );
295
288
thrown .expectMessage ("No value at $.tags.foo" );
296
289
@@ -306,56 +299,58 @@ public class Span2JsonCodecTest {
306
299
codec .readSpan (json .getBytes (UTF_8 ));
307
300
}
308
301
309
- @ Test public void readSpan_localEndpoint_noServiceName () {
302
+ @ Test public void niceErrorOnNull_annotationValue () {
303
+ thrown .expect (IllegalArgumentException .class );
304
+ thrown .expectMessage ("$.annotations[0].value" );
305
+
310
306
String json = "{\n "
311
307
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
312
308
+ " \" name\" : \" get-traces\" ,\n "
313
309
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
314
- + " \" localEndpoint \" : { \n "
315
- + " \" ipv4 \" : \" 127.0.0.1 \" \n "
316
- + " } \n "
310
+ + " \" annotations \" : [ \n "
311
+ + " { \" timestamp \" : 1472470996199000, \" value \" : NULL} \n "
312
+ + " ] \n "
317
313
+ "}" ;
318
314
319
- assertThat (codec .readSpan (json .getBytes (UTF_8 )).localEndpoint ())
320
- .isEqualTo (Endpoint .create ("" , 127 << 24 | 1 ));
315
+ codec .readSpan (json .getBytes (UTF_8 ));
321
316
}
322
317
323
- @ Test public void readSpan_localEndpoint_nullServiceName () {
318
+ @ Test public void niceErrorOnNull_annotationTimestamp () {
319
+ thrown .expect (IllegalArgumentException .class );
320
+ thrown .expectMessage ("$.annotations[0].timestamp" );
321
+
324
322
String json = "{\n "
325
323
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
326
324
+ " \" name\" : \" get-traces\" ,\n "
327
325
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
328
- + " \" localEndpoint\" : {\n "
329
- + " \" serviceName\" : null,\n "
330
- + " \" ipv4\" : \" 127.0.0.1\" \n "
331
- + " }\n "
326
+ + " \" annotations\" : [\n "
327
+ + " { \" timestamp\" : NULL, \" value\" : \" foo\" }\n "
328
+ + " ]\n "
332
329
+ "}" ;
333
330
334
- assertThat (codec .readSpan (json .getBytes (UTF_8 )).localEndpoint ())
335
- .isEqualTo (Endpoint .create ("" , 127 << 24 | 1 ));
331
+ codec .readSpan (json .getBytes (UTF_8 ));
336
332
}
337
333
338
- @ Test public void readSpan_remoteEndpoint_noServiceName () {
334
+ @ Test public void readSpan_localEndpoint_noServiceName () {
339
335
String json = "{\n "
340
336
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
341
337
+ " \" name\" : \" get-traces\" ,\n "
342
338
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
343
- + " \" remoteEndpoint \" : {\n "
339
+ + " \" localEndpoint \" : {\n "
344
340
+ " \" ipv4\" : \" 127.0.0.1\" \n "
345
341
+ " }\n "
346
342
+ "}" ;
347
343
348
- assertThat (codec .readSpan (json .getBytes (UTF_8 )).remoteEndpoint ())
344
+ assertThat (codec .readSpan (json .getBytes (UTF_8 )).localEndpoint ())
349
345
.isEqualTo (Endpoint .create ("" , 127 << 24 | 1 ));
350
346
}
351
347
352
- @ Test public void readSpan_remoteEndpoint_nullServiceName () {
348
+ @ Test public void readSpan_remoteEndpoint_noServiceName () {
353
349
String json = "{\n "
354
350
+ " \" traceId\" : \" 6b221d5bc9e6496c\" ,\n "
355
351
+ " \" name\" : \" get-traces\" ,\n "
356
352
+ " \" id\" : \" 6b221d5bc9e6496c\" ,\n "
357
353
+ " \" remoteEndpoint\" : {\n "
358
- + " \" serviceName\" : null,\n "
359
354
+ " \" ipv4\" : \" 127.0.0.1\" \n "
360
355
+ " }\n "
361
356
+ "}" ;
0 commit comments