|
| 1 | +package com.backbase.dbs.payment.batch.rule.validation; |
| 2 | + |
| 3 | +import static com.backbase.dbs.payment.batch.rule.BatchFacts.FACT_BATCH_PAYMENT; |
| 4 | + |
| 5 | +import com.backbase.dbs.payment.batch.config.BatchRuleInformation; |
| 6 | +import com.backbase.dbs.payment.batch.model.BatchPayment; |
| 7 | +import com.backbase.dbs.payment.batch.rule.AbstractBatchValidationRule; |
| 8 | +import com.backbase.dbs.payment.batch.service.RtnBlocklistValidator; |
| 9 | +import java.util.ArrayList; |
| 10 | +import java.util.Map; |
| 11 | +import org.jeasy.rules.api.Facts; |
| 12 | +import org.springframework.expression.EvaluationContext; |
| 13 | +import org.springframework.expression.Expression; |
| 14 | + |
| 15 | +public class RtnBlocklistBatchValidationRule extends AbstractBatchValidationRule { |
| 16 | + |
| 17 | + private final RtnBlocklistValidator rtnBlocklistValidator; |
| 18 | + |
| 19 | + public static class RtnBlocklist extends ArrayList<String> { |
| 20 | + |
| 21 | + } |
| 22 | + |
| 23 | + public RtnBlocklistBatchValidationRule( |
| 24 | + BatchRuleInformation batchRuleInformation, |
| 25 | + Map<String, Expression> errorContextExpressions, |
| 26 | + EvaluationContext evaluationContext, |
| 27 | + Expression conditionExpression, RtnBlocklistValidator rtnBlocklistValidator) { |
| 28 | + super(batchRuleInformation, errorContextExpressions, evaluationContext, conditionExpression); |
| 29 | + this.rtnBlocklistValidator = rtnBlocklistValidator; |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + public boolean isValid(Facts facts) { |
| 34 | + BatchPayment batchPayment = facts.get(FACT_BATCH_PAYMENT); |
| 35 | + |
| 36 | + Map<String, String> ruleConfiguration = getBatchRuleInformation().getConfiguration(); |
| 37 | + |
| 38 | + String rtnBlocklistUrl = ruleConfiguration.get("rtn-blocklist-url"); |
| 39 | + |
| 40 | + return rtnBlocklistValidator.isValid(rtnBlocklistUrl, batchPayment.getCounterpartyBankBranchCode()); |
| 41 | + } |
| 42 | + |
| 43 | +} |
0 commit comments