[FINERACT-1678] Introducing synchronous COB execution for loan account changing APIs
This commit is contained in:
committed by
Arnold Gálovics
parent
70a0a3e2e9
commit
3951e69ad7
+7
-1
@@ -30,6 +30,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import org.apache.fineract.cob.service.InlineLoanCOBExecutorServiceImpl;
|
||||
import org.apache.fineract.cob.service.LoanAccountLockService;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.GLIMAccountInfoRepository;
|
||||
@@ -59,6 +60,8 @@ class LoanCOBApiFilterTest {
|
||||
private GLIMAccountInfoRepository glimAccountInfoRepository;
|
||||
@Mock
|
||||
private PlatformSecurityContext context;
|
||||
@Mock
|
||||
private InlineLoanCOBExecutorServiceImpl inlineLoanCOBExecutorService;
|
||||
|
||||
@Test
|
||||
void shouldProceedWhenUrlDoesNotMatch() throws ServletException, IOException {
|
||||
@@ -99,6 +102,7 @@ class LoanCOBApiFilterTest {
|
||||
given(request.getPathInfo()).willReturn("/loans/2/charges");
|
||||
given(request.getMethod()).willReturn(HTTPMethods.POST.value());
|
||||
given(loanAccountLockService.isLoanHardLocked(2L)).willReturn(false);
|
||||
given(loanAccountLockService.isLoanSoftLocked(2L)).willReturn(false);
|
||||
given(context.getAuthenticatedUserIfPresent()).willReturn(appUser);
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
@@ -106,7 +110,7 @@ class LoanCOBApiFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldProceedWhenLoanIsSoftLocked() throws ServletException, IOException {
|
||||
void shouldRunInlineCOBAndProceedWhenLoanIsSoftLocked() throws ServletException, IOException {
|
||||
MockHttpServletRequest request = mock(MockHttpServletRequest.class);
|
||||
MockHttpServletResponse response = mock(MockHttpServletResponse.class);
|
||||
FilterChain filterChain = mock(FilterChain.class);
|
||||
@@ -115,9 +119,11 @@ class LoanCOBApiFilterTest {
|
||||
given(request.getPathInfo()).willReturn("/loans/2/charges");
|
||||
given(request.getMethod()).willReturn(HTTPMethods.POST.value());
|
||||
given(loanAccountLockService.isLoanHardLocked(2L)).willReturn(false);
|
||||
given(loanAccountLockService.isLoanSoftLocked(2L)).willReturn(true);
|
||||
given(context.getAuthenticatedUserIfPresent()).willReturn(appUser);
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
verify(inlineLoanCOBExecutorService, times(1)).execute(Collections.singletonList(2L), "INLINE_LOAN_COB");
|
||||
verify(filterChain, times(1)).doFilter(request, response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user