44package com .microsoft .applicationinsights .smoketest ;
55
66import static com .microsoft .applicationinsights .smoketest .EnvironmentValue .TOMCAT_8_JAVA_8 ;
7- import static org .assertj .core .api .Assertions .assertThat ;
87
9- import com .microsoft .applicationinsights .smoketest .schemav2 .Data ;
10- import com .microsoft .applicationinsights .smoketest .schemav2 .Envelope ;
11- import com .microsoft .applicationinsights .smoketest .schemav2 .ExceptionData ;
12- import com .microsoft .applicationinsights .smoketest .schemav2 .RequestData ;
13- import java .util .List ;
8+ import com .microsoft .applicationinsights .smoketest .schemav2 .SeverityLevel ;
149import org .junit .jupiter .api .Test ;
1510import org .junit .jupiter .api .extension .RegisterExtension ;
1611
@@ -23,39 +18,41 @@ class LogbackLevelOffTest {
2318 @ Test
2419 @ TargetUri ("/test" )
2520 void testDisabled () throws Exception {
26- List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
27-
28- Envelope rdEnvelope = rdList .get (0 );
29- RequestData rd = (RequestData ) ((Data <?>) rdEnvelope .getData ()).getBaseData ();
30- assertThat (rd .getName ()).isEqualTo ("GET /Logback/test" );
31-
32- assertThat (testing .mockedIngestion .getCountForType ("MessageData" )).isZero ();
21+ testing .waitAndAssertTrace (
22+ trace ->
23+ trace
24+ .hasRequestSatisying (
25+ request ->
26+ request
27+ .hasName ("GET /Logback/test" )
28+ .hasSuccess (true )
29+ .hasNoParent ()
30+ .hasTag ("ai.operation.name" , "GET /Logback/test" ))
31+ .hasMessageCount (0 ));
3332 }
3433
3534 @ Test
3635 @ TargetUri ("/testWithSpanException" )
3736 void testWithSpanException () throws Exception {
38- List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
39-
40- Envelope rdEnvelope = rdList .get (0 );
41- RequestData rd = (RequestData ) ((Data <?>) rdEnvelope .getData ()).getBaseData ();
42- assertThat (rd .getName ()).isEqualTo ("GET /Logback/testWithSpanException" );
43-
44- assertThat (testing .mockedIngestion .getCountForType ("MessageData" )).isZero ();
45-
46- // check that span exception is still captured
47- String operationId = rdEnvelope .getTags ().get ("ai.operation.id" );
48- List <Envelope > edList =
49- testing .mockedIngestion .waitForItemsInOperation ("ExceptionData" , 1 , operationId );
50-
51- Envelope edEnvelope = edList .get (0 );
52- ExceptionData ed = (ExceptionData ) ((Data <?>) edEnvelope .getData ()).getBaseData ();
53-
54- assertThat (ed .getExceptions ().get (0 ).getTypeName ()).isEqualTo ("java.lang.RuntimeException" );
55- assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("Test Exception" );
56- assertThat (ed .getProperties ()).isEmpty (); // this is not a logger-based exception
57-
58- SmokeTestExtension .assertParentChild (
59- rd , rdEnvelope , edEnvelope , "GET /Logback/testWithSpanException" );
37+ testing .waitAndAssertTrace (
38+ trace ->
39+ trace
40+ .hasRequestSatisying (
41+ request ->
42+ request
43+ .hasName ("GET /Logback/testWithSpanException" )
44+ .hasSuccess (true )
45+ .hasNoParent ()
46+ .hasTag ("ai.operation.name" , "GET /Logback/testWithSpanException" ))
47+ .hasMessageCount (0 )
48+ .hasExceptionCount (1 )
49+ .hasExceptionSatisying (
50+ exception ->
51+ exception
52+ .hasExceptionTypeName ("java.lang.RuntimeException" )
53+ .hasExceptionMessage ("Test Exception" )
54+ .hasPropertyCount (0 ) // this is not a logger-based exception
55+ .hasParent (trace .getRequestId (0 ))
56+ .hasTag ("ai.operation.name" , "GET /Logback/testWithSpanException" )));
6057 }
6158}
0 commit comments