You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/11/29 15:29:26 UTC

[GitHub] [fineract] taskain7 opened a new pull request, #2778: [FINERACT-1678] Fix Inline COB execution

taskain7 opened a new pull request, #2778:
URL: https://github.com/apache/fineract/pull/2778

   ## Description
   
   Fixing the Inline Loan COB execution
   


-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2778: [FINERACT-1678] Fix Inline COB execution

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2778:
URL: https://github.com/apache/fineract/pull/2778#discussion_r1034975382


##########
fineract-provider/src/main/java/org/apache/fineract/cob/common/InitialisationTasklet.java:
##########
@@ -41,11 +47,18 @@ public class InitialisationTasklet implements Tasklet {
 
     @Override
     public RepeatStatus execute(@NotNull StepContribution contribution, @NotNull ChunkContext chunkContext) throws Exception {
+        HashMap<BusinessDateType, LocalDate> businessDates = ThreadLocalContextUtil.getBusinessDates();
         AppUser user = userRepository.fetchSystemUser();
         UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(user, user.getPassword(),
                 new NullAuthoritiesMapper().mapAuthorities(user.getAuthorities()));
         SecurityContextHolder.getContext().setAuthentication(auth);
         ThreadLocalContextUtil.setActionContext(ActionContext.COB);
+        String businessDateString = Objects.requireNonNull((String) chunkContext.getStepContext().getStepExecution().getJobExecution()
+                .getExecutionContext().get(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME));

Review Comment:
   I dont think the LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME got promoted. Would you please check it?



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2778: [FINERACT-1678] Fix Inline COB execution

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2778:
URL: https://github.com/apache/fineract/pull/2778#discussion_r1034968902


##########
fineract-provider/src/test/java/org/apache/fineract/cob/common/InitialisationTaskletStepDefinitions.java:
##########
@@ -48,11 +59,22 @@ 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);

Review Comment:
   I dont see any assertion whether the proper dates were provided and set into the ThreadLocalContextUtil...



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] galovics merged pull request #2778: [FINERACT-1678] Fix Inline COB execution

Posted by GitBox <gi...@apache.org>.
galovics merged PR #2778:
URL: https://github.com/apache/fineract/pull/2778


-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2778: [FINERACT-1678] Fix Inline COB execution

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2778: [FINERACT-1678] Fix Inline COB execution

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2778:
URL: https://github.com/apache/fineract/pull/2778#discussion_r1034968902


##########
fineract-provider/src/test/java/org/apache/fineract/cob/common/InitialisationTaskletStepDefinitions.java:
##########
@@ -48,11 +59,22 @@ 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);

Review Comment:
   Could you please enhanced this test to check whether the proper dates were provided and set?



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org