@@ -86,7 +86,11 @@ void tearDown() {
86
86
@ Test
87
87
void shouldCaptureNonHandlerMethod () {
88
88
nonHandlerMethod .doSomething ();
89
- assertThat (AWSXRay .getTraceEntity ().getSubsegments ())
89
+
90
+ assertThat (AWSXRay .getTraceEntity ())
91
+ .isNotNull ();
92
+
93
+ assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
90
94
.hasSize (1 )
91
95
.anySatisfy (segment ->
92
96
assertThat (segment .getName ()).isEqualTo ("## doSomething" ));
@@ -95,7 +99,11 @@ void shouldCaptureNonHandlerMethod() {
95
99
@ Test
96
100
void shouldCaptureNonHandlerMethodWithCustomSegmentName () {
97
101
nonHandlerMethod .doSomethingCustomName ();
98
- assertThat (AWSXRay .getTraceEntity ().getSubsegments ())
102
+
103
+ assertThat (AWSXRay .getTraceEntity ())
104
+ .isNotNull ();
105
+
106
+ assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
99
107
.hasSize (1 )
100
108
.anySatisfy (segment ->
101
109
assertThat (segment .getName ()).isEqualTo ("custom" ));
@@ -105,6 +113,9 @@ void shouldCaptureNonHandlerMethodWithCustomSegmentName() {
105
113
void shouldCaptureTraces () {
106
114
requestHandler .handleRequest (new Object (), context );
107
115
116
+ assertThat (AWSXRay .getTraceEntity ())
117
+ .isNotNull ();
118
+
108
119
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
109
120
.hasSize (1 )
110
121
.allSatisfy (subsegment -> {
@@ -125,6 +136,9 @@ void shouldCaptureTracesWithExceptionMetaData() {
125
136
126
137
Throwable exception = catchThrowable (() -> requestHandler .handleRequest (new Object (), context ));
127
138
139
+ assertThat (AWSXRay .getTraceEntity ())
140
+ .isNotNull ();
141
+
128
142
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
129
143
.hasSize (1 )
130
144
.allSatisfy (subsegment -> {
@@ -147,6 +161,9 @@ void shouldCaptureTracesWithExceptionMetaData() {
147
161
void shouldCaptureTracesForStream () throws IOException {
148
162
streamHandler .handleRequest (new ByteArrayInputStream ("test" .getBytes ()), new ByteArrayOutputStream (), context );
149
163
164
+ assertThat (AWSXRay .getTraceEntity ())
165
+ .isNotNull ();
166
+
150
167
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
151
168
.hasSize (1 )
152
169
.allSatisfy (subsegment -> {
@@ -166,6 +183,9 @@ void shouldNotCaptureTracesNotEnabled() throws IOException {
166
183
requestHandler = new PowerToolDisabled ();
167
184
requestHandler .handleRequest (new Object (), context );
168
185
186
+ assertThat (AWSXRay .getTraceEntity ())
187
+ .isNotNull ();
188
+
169
189
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
170
190
.isEmpty ();
171
191
@@ -182,6 +202,9 @@ void shouldCaptureTracesWithNoMetadata() {
182
202
183
203
requestHandler .handleRequest (new Object (), context );
184
204
205
+ assertThat (AWSXRay .getTraceEntity ())
206
+ .isNotNull ();
207
+
185
208
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
186
209
.hasSize (1 )
187
210
.allSatisfy (subsegment -> {
@@ -201,6 +224,9 @@ void shouldCaptureTracesForStreamWithNoMetadata() throws IOException {
201
224
202
225
streamHandler .handleRequest (new ByteArrayInputStream ("test" .getBytes ()), new ByteArrayOutputStream (), context );
203
226
227
+ assertThat (AWSXRay .getTraceEntity ())
228
+ .isNotNull ();
229
+
204
230
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
205
231
.hasSize (1 )
206
232
.allSatisfy (subsegment -> {
@@ -220,6 +246,9 @@ void shouldCaptureTracesWithNoMetadataDeprecated() {
220
246
221
247
requestHandler .handleRequest (new Object (), context );
222
248
249
+ assertThat (AWSXRay .getTraceEntity ())
250
+ .isNotNull ();
251
+
223
252
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
224
253
.hasSize (1 )
225
254
.allSatisfy (subsegment -> {
@@ -241,6 +270,9 @@ void shouldNotCaptureTracesIfDisabledViaEnvironmentVariable() {
241
270
242
271
requestHandler .handleRequest (new Object (), context );
243
272
273
+ assertThat (AWSXRay .getTraceEntity ())
274
+ .isNotNull ();
275
+
244
276
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
245
277
.hasSize (1 )
246
278
.allSatisfy (subsegment -> {
@@ -263,6 +295,9 @@ void shouldCaptureTracesIfExplicitlyEnabledAndEnvironmentVariableIsDisabled() {
263
295
264
296
requestHandler .handleRequest (new Object (), context );
265
297
298
+ assertThat (AWSXRay .getTraceEntity ())
299
+ .isNotNull ();
300
+
266
301
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
267
302
.hasSize (1 )
268
303
.allSatisfy (subsegment -> {
@@ -284,6 +319,9 @@ void shouldCaptureTracesForSelfReferencingReturnTypesViaCustomMapper() {
284
319
285
320
requestHandler .handleRequest (new Object (), context );
286
321
322
+ assertThat (AWSXRay .getTraceEntity ())
323
+ .isNotNull ();
324
+
287
325
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
288
326
.hasSize (1 )
289
327
.allSatisfy (subsegment -> {
@@ -311,6 +349,9 @@ void shouldCaptureTracesIfExplicitlyEnabledBothAndEnvironmentVariableIsDisabled(
311
349
312
350
requestHandler .handleRequest (new Object (), context );
313
351
352
+ assertThat (AWSXRay .getTraceEntity ())
353
+ .isNotNull ();
354
+
314
355
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
315
356
.hasSize (1 )
316
357
.allSatisfy (subsegment -> {
@@ -333,7 +374,13 @@ void shouldNotCaptureTracesWithExceptionMetaDataIfDisabledViaEnvironmentVariable
333
374
mocked .when (() -> SystemWrapper .getenv ("POWERTOOLS_TRACER_CAPTURE_ERROR" )).thenReturn ("false" );
334
375
requestHandler = new PowerTracerToolEnabledWithException ();
335
376
336
- catchThrowable (() -> requestHandler .handleRequest (new Object (), context ));
377
+ Throwable throwable = catchThrowable (() -> requestHandler .handleRequest (new Object (), context ));
378
+
379
+ assertThat (throwable )
380
+ .isInstanceOf (RuntimeException .class );
381
+
382
+ assertThat (AWSXRay .getTraceEntity ())
383
+ .isNotNull ();
337
384
338
385
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
339
386
.hasSize (1 )
@@ -358,6 +405,9 @@ void shouldCaptureTracesWithExceptionMetaDataEnabledExplicitlyAndEnvironmentVari
358
405
359
406
Throwable exception = catchThrowable (() -> requestHandler .handleRequest (new Object (), context ));
360
407
408
+ assertThat (AWSXRay .getTraceEntity ())
409
+ .isNotNull ();
410
+
361
411
assertThat (AWSXRay .getTraceEntity ().getSubsegmentsCopy ())
362
412
.hasSize (1 )
363
413
.allSatisfy (subsegment -> {
0 commit comments