FINERACT-1971: Fixing Loan COB error on startup when Loan COB is disabled

This commit is contained in:
Peter Bagrij
2024-03-22 12:16:40 +01:00
committed by Adam Saghy
parent c34f2b4f59
commit c404f474e9
6 changed files with 16 additions and 40 deletions
@@ -21,12 +21,10 @@ package org.apache.fineract.cob.conditions;
import org.apache.fineract.infrastructure.core.condition.PropertiesCondition;
import org.apache.fineract.infrastructure.core.config.FineractProperties;
public class LoanCOBWorkerCondition extends PropertiesCondition {
public class BatchManagerCondition extends PropertiesCondition {
@Override
protected boolean matches(FineractProperties properties) {
boolean loanCobEnabled = properties.getJob().isLoanCobEnabled();
boolean batchWorkerEnabled = properties.getMode().isBatchWorkerEnabled();
return loanCobEnabled && batchWorkerEnabled;
return properties.getMode().isBatchManagerEnabled();
}
}
@@ -21,12 +21,10 @@ package org.apache.fineract.cob.conditions;
import org.apache.fineract.infrastructure.core.condition.PropertiesCondition;
import org.apache.fineract.infrastructure.core.config.FineractProperties;
public class LoanCOBManagerCondition extends PropertiesCondition {
public class BatchWorkerCondition extends PropertiesCondition {
@Override
protected boolean matches(FineractProperties properties) {
boolean loanCobEnabled = properties.getJob().isLoanCobEnabled();
boolean batchManagerEnabled = properties.getMode().isBatchManagerEnabled();
return loanCobEnabled && batchManagerEnabled;
return properties.getMode().isBatchWorkerEnabled();
}
}
@@ -20,7 +20,7 @@ package org.apache.fineract.cob.loan;
import org.apache.fineract.cob.COBBusinessStepService;
import org.apache.fineract.cob.common.CustomJobParameterResolver;
import org.apache.fineract.cob.conditions.LoanCOBManagerCondition;
import org.apache.fineract.cob.conditions.BatchManagerCondition;
import org.apache.fineract.cob.listener.COBExecutionListenerRunner;
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
import org.apache.fineract.infrastructure.jobs.service.JobName;
@@ -47,7 +47,7 @@ import org.springframework.transaction.PlatformTransactionManager;
@Configuration
@EnableBatchIntegration
@Conditional(LoanCOBManagerCondition.class)
@Conditional(BatchManagerCondition.class)
public class LoanCOBManagerConfiguration {
@Autowired
@@ -22,7 +22,7 @@ import org.apache.fineract.cob.COBBusinessStepService;
import org.apache.fineract.cob.common.CustomJobParameterResolver;
import org.apache.fineract.cob.common.InitialisationTasklet;
import org.apache.fineract.cob.common.ResetContextTasklet;
import org.apache.fineract.cob.conditions.LoanCOBWorkerCondition;
import org.apache.fineract.cob.conditions.BatchWorkerCondition;
import org.apache.fineract.cob.listener.ChunkProcessingLoanItemListener;
import org.apache.fineract.infrastructure.core.config.FineractProperties;
import org.apache.fineract.infrastructure.jobs.service.JobName;
@@ -51,7 +51,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
@Configuration
@Conditional(LoanCOBWorkerCondition.class)
@Conditional(BatchWorkerCondition.class)
public class LoanCOBWorkerConfiguration {
@Autowired
@@ -32,7 +32,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.mock.env.MockEnvironment;
@ExtendWith(MockitoExtension.class)
class LoanCOBManagerConditionTest {
class BatchManagerConditionTest {
@Mock
private ConditionContext conditionContext;
@@ -43,7 +43,7 @@ class LoanCOBManagerConditionTest {
private MockEnvironment environment;
@InjectMocks
private LoanCOBManagerCondition testObj = new LoanCOBManagerCondition();
private BatchManagerCondition testObj = new BatchManagerCondition();
@BeforeEach
public void setUp() {
@@ -52,24 +52,14 @@ class LoanCOBManagerConditionTest {
}
@Test
public void testMatchesShouldReturnFalseWhenLoanCobIsDisabledAndManager() {
environment.withProperty("fineract.job.loan-cob-enabled", "false");
environment.withProperty("fineract.mode.batch-manager-enabled", "true");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isFalse();
}
@Test
public void testMatchesShouldReturnFalseWhenLoanCobIsEnabledAndNotManager() {
environment.withProperty("fineract.job.loan-cob-enabled", "true");
public void testMatchesShouldReturnFalseWhenManagerDisabled() {
environment.withProperty("fineract.mode.batch-manager-enabled", "false");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isFalse();
}
@Test
public void testMatchesShouldReturnTrueWhenLoanCobIsEnabledAndManager() {
environment.withProperty("fineract.job.loan-cob-enabled", "true");
public void testMatchesShouldReturnTrueWhenManagerEnabled() {
environment.withProperty("fineract.mode.batch-manager-enabled", "true");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isTrue();
@@ -32,7 +32,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.mock.env.MockEnvironment;
@ExtendWith(MockitoExtension.class)
class LoanCOBWorkerConditionTest {
class BatchWorkerConditionTest {
@Mock
private ConditionContext conditionContext;
@@ -43,7 +43,7 @@ class LoanCOBWorkerConditionTest {
private MockEnvironment environment;
@InjectMocks
private LoanCOBWorkerCondition testObj = new LoanCOBWorkerCondition();
private BatchWorkerCondition testObj = new BatchWorkerCondition();
@BeforeEach
public void setUp() {
@@ -52,24 +52,14 @@ class LoanCOBWorkerConditionTest {
}
@Test
public void testMatchesShouldReturnFalseWhenLoanCobIsDisabledAndWorker() {
environment.withProperty("fineract.job.loan-cob-enabled", "false");
environment.withProperty("fineract.mode.batch-worker-enabled", "true");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isFalse();
}
@Test
public void testMatchesShouldReturnFalseWhenLoanCobIsEnabledAndNotWorker() {
environment.withProperty("fineract.job.loan-cob-enabled", "true");
public void testMatchesShouldReturnFalseWhenWorkerDisabled() {
environment.withProperty("fineract.mode.batch-worker-enabled", "false");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isFalse();
}
@Test
public void testMatchesShouldReturnTrueWhenLoanCobIsEnabledAndWorker() {
environment.withProperty("fineract.job.loan-cob-enabled", "true");
public void testMatchesShouldReturnTrueWhenWorkerEnabled() {
environment.withProperty("fineract.mode.batch-worker-enabled", "true");
boolean result = testObj.matches(conditionContext, metadata);
assertThat(result).isTrue();