adamsaghy commented on code in PR #2778:
URL: https://github.com/apache/fineract/pull/2778#discussion_r1034978343


##########
fineract-provider/src/test/java/org/apache/fineract/cob/common/InitialisationTaskletStepDefinitions.java:
##########
@@ -48,23 +59,42 @@ public InitialisationTaskletStepDefinitions() {
             } else {
                 
lenient().when(this.userRepository.fetchSystemUser()).thenReturn(appUser);
             }
-
+            HashMap<BusinessDateType, LocalDate> businessDates = new 
HashMap<>();
+            LocalDate businessDate = LocalDate.now(ZoneId.systemDefault());
+            LocalDate cobBusinessDate = businessDate.minusDays(1);
+            businessDates.put(BusinessDateType.BUSINESS_DATE, businessDate);
+            businessDates.put(BusinessDateType.COB_DATE, cobBusinessDate);
+            ThreadLocalContextUtil.setBusinessDates(businessDates);
+            JobExecution jobExecution = new JobExecution(1L);
+            
jobExecution.getExecutionContext().put(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME,
+                    cobBusinessDate.format(DateTimeFormatter.ISO_DATE));
+            StepExecution stepExecution = new StepExecution("step", 
jobExecution);
+            StepContext stepContext = new StepContext(stepExecution);
+            chunkContext = new ChunkContext(stepContext);
         });
 
         When("InitialisationTasklet.execute method executed", () -> {
-            resultItem = this.initialisationTasklet.execute(null, null);
+            resultItem = this.initialisationTasklet.execute(null, 
chunkContext);
         });
 
         Then("InitialisationTasklet.execute result should match", () -> {
             assertEquals(RepeatStatus.FINISHED, resultItem);
             assertEquals(appUser, 
SecurityContextHolder.getContext().getAuthentication().getPrincipal());
+            assertEquals(LocalDate.now(ZoneId.systemDefault()),

Review Comment:
   Would you mind to please use a global variable for this? i know it is really 
edge case, but if this test got run at just before midnight, it might fail :D



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to