11package  com .javaquery .util ;
22
33import  com .javaquery .util .logging .Action ;
4+ import  com .javaquery .util .logging .ActivityStatus ;
45import  org .junit .jupiter .api .Assertions ;
56import  org .junit .jupiter .api .Test ;
67
@@ -16,19 +17,63 @@ public enum ExecutionContextAction implements Action{
1617        ONE 
1718    }
1819
20+     public  class  UserContext {
21+ 
22+         private  Long  userId ;
23+ 
24+         private  Long  tenantId ;
25+ 
26+         public  UserContext (Long  userId , Long  tenantId ) {
27+             this .userId  = userId ;
28+             this .tenantId  = tenantId ;
29+         }
30+ 
31+         public  Long  getUserId () {
32+             return  userId ;
33+         }
34+ 
35+         public  Long  getTenantId () {
36+             return  tenantId ;
37+         }
38+     }
39+ 
40+     @ Test 
41+     public  void  defaultConstructor (){
42+         ExecutionContext <Object , Object > executionContext  = new  ExecutionContext <>();
43+         executionContext .setUserContext (new  UserContext (50L , 20L ));
44+         executionContext .setRequestId (UniqueIdGenerator .generate ());
45+ 
46+         UserContext  userContext  = (UserContext ) executionContext .getUserContext ();
47+         Assertions .assertEquals (50L , userContext .getUserId ());
48+         Assertions .assertNotNull (executionContext .getCreatedAt ());
49+         Assertions .assertNotNull (executionContext .getRequestId ());
50+     }
51+ 
52+     @ Test 
53+     public  void  constructorWithRequestId (){
54+         ExecutionContext <Long , Long > executionContext  = new  ExecutionContext <>(UniqueIdGenerator .generate ());
55+         Assertions .assertNotNull (executionContext .getRequestId ());
56+     }
57+ 
1958    @ Test 
2059    public  void  constructorWithRequestIdReferenceIdAction (){
21-         ExecutionContext <Long > executionContext  = new  ExecutionContext <>(UniqueIdGenerator .generate (), 1L , ExecutionContextAction .ONE );
60+         ExecutionContext <Long , Long > executionContext  = new  ExecutionContext <>(UniqueIdGenerator .generate (), 1L , ExecutionContextAction .ONE );
61+         executionContext .setUserContext (50L );
62+         executionContext .setActivityStatus (ActivityStatus .STARTED );
2263        Assertions .assertNotNull (executionContext .getRequestId ());
2364        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
2465        Assertions .assertEquals (1L , executionContext .getReferenceId ());
2566        Assertions .assertNotNull (executionContext .getMeta ());
2667        Assertions .assertNotNull (executionContext .getCreatedAt ());
68+ 
69+         Assertions .assertEquals (50L , executionContext .getUserContext ());
70+         Assertions .assertEquals (ActivityStatus .STARTED , executionContext .getActivityStatus ());
71+         Assertions .assertNotNull (executionContext .getCreatedAt ());
2772    }
2873
2974    @ Test 
3075    public  void  constructorWithReferenceIdAction (){
31-         ExecutionContext <String > executionContext  = new  ExecutionContext <>("test" , ExecutionContextAction .ONE );
76+         ExecutionContext <String ,  Void > executionContext  = new  ExecutionContext <>("test" , ExecutionContextAction .ONE );
3277        Assertions .assertNotNull (executionContext .getRequestId ());
3378        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
3479        Assertions .assertEquals ("test" , executionContext .getReferenceId ());
@@ -38,7 +83,7 @@ public void constructorWithReferenceIdAction(){
3883
3984    @ Test 
4085    public  void  constructorWithAction (){
41-         ExecutionContext <String > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
86+         ExecutionContext <String ,  Void > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
4287        Assertions .assertNotNull (executionContext .getRequestId ());
4388        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
4489        Assertions .assertNull (executionContext .getReferenceId ());
@@ -48,7 +93,7 @@ public void constructorWithAction(){
4893
4994    @ Test 
5095    public  void  constructorWithActionAndMeta (){
51-         ExecutionContext <String > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
96+         ExecutionContext <String ,  Void > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
5297        executionContext .addMeta ("key" , "value" );
5398        Assertions .assertNotNull (executionContext .getRequestId ());
5499        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
@@ -63,7 +108,7 @@ public void constructorWithActionAndMeta(){
63108
64109    @ Test 
65110    public  void  constructorWithActionAndRetriesAttempted (){
66-         ExecutionContext <String > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
111+         ExecutionContext <String ,  Void > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE );
67112        executionContext .addRetriesAttempted (1 );
68113        Assertions .assertNotNull (executionContext .getRequestId ());
69114        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
@@ -75,7 +120,7 @@ public void constructorWithActionAndRetriesAttempted(){
75120
76121    @ Test 
77122    public  void  constructorWithReferenceIdActionMaxRetries (){
78-         ExecutionContext <Long > executionContext  = new  ExecutionContext <>(1L , ExecutionContextAction .ONE , 3 );
123+         ExecutionContext <Long ,  Void > executionContext  = new  ExecutionContext <>(1L , ExecutionContextAction .ONE , 3 );
79124        Assertions .assertNotNull (executionContext .getRequestId ());
80125        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
81126        Assertions .assertEquals (1L , executionContext .getReferenceId ());
@@ -86,7 +131,7 @@ public void constructorWithReferenceIdActionMaxRetries(){
86131
87132    @ Test 
88133    public  void  constructorWithActionMaxRetries (){
89-         ExecutionContext <Long > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE , 3 );
134+         ExecutionContext <Long ,  Void > executionContext  = new  ExecutionContext <>(ExecutionContextAction .ONE , 3 );
90135        Assertions .assertNotNull (executionContext .getRequestId ());
91136        Assertions .assertEquals (ExecutionContextAction .ONE , executionContext .getAction ());
92137        Assertions .assertNull (executionContext .getReferenceId ());
0 commit comments