MIFOSX-1187 - added null checks before compare with min and max values

This commit is contained in:
Pramod Nuthakki
2014-05-15 22:21:04 +05:30
parent 0a3e039122
commit 99822a32e2
3 changed files with 9 additions and 9 deletions
@@ -377,7 +377,7 @@ public class DepositProductDataValidator {
}
final Integer minDepositTermType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(minDepositTermTypeIdParamName, element);
baseDataValidator.reset().parameter(minDepositTermTypeIdParamName).value(minDepositTermType)
baseDataValidator.reset().parameter(minDepositTermTypeIdParamName).value(minDepositTermType).ignoreIfNull()
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues());
if (fromApiJsonHelper.parameterExists(maxDepositTermTypeIdParamName, element)) {
@@ -417,25 +417,25 @@ public class DepositProductAssembler {
if (command.parameterExists(minDepositTermParamName)) {
minDepositTerm = command.integerValueOfParameterNamed(minDepositTermParamName);
} else {
} else if(prodDepositTermDetail != null){
minDepositTerm = prodDepositTermDetail.minDepositTerm();
}
if (command.parameterExists(maxDepositTermParamName)) {
maxDepositTerm = command.integerValueOfParameterNamed(maxDepositTermParamName);
} else {
} else if(prodDepositTermDetail != null){
maxDepositTerm = prodDepositTermDetail.maxDepositTerm();
}
if (command.parameterExists(minDepositTermTypeIdParamName)) {
minDepositTermTypeId = command.integerValueOfParameterNamed(minDepositTermTypeIdParamName);
} else {
} else if(prodDepositTermDetail != null){
minDepositTermTypeId = prodDepositTermDetail.minDepositTermType();
}
if (command.parameterExists(maxDepositTermTypeIdParamName)) {
maxDepositTermTypeId = command.integerValueOfParameterNamed(maxDepositTermTypeIdParamName);
} else {
} else if(prodDepositTermDetail != null){
maxDepositTermTypeId = prodDepositTermDetail.maxDepositTermType();
}
@@ -447,13 +447,13 @@ public class DepositProductAssembler {
if (command.parameterExists(inMultiplesOfDepositTermParamName)) {
inMultiplesOfDepositTerm = command.integerValueOfParameterNamed(inMultiplesOfDepositTermParamName);
} else {
} else if(prodDepositTermDetail != null){
inMultiplesOfDepositTerm = prodDepositTermDetail.inMultiplesOfDepositTerm();
}
if (command.parameterExists(preClosurePenalApplicableParamName)) {
inMultiplesOfDepositTermTypeId = command.integerValueOfParameterNamed(inMultiplesOfDepositTermTypeIdParamName);
} else {
} else if(prodDepositTermDetail != null){
inMultiplesOfDepositTermTypeId = prodDepositTermDetail.inMultiplesOfDepositTermType();
}
@@ -175,13 +175,13 @@ public class DepositTermDetail {
private boolean isEqualOrGreaterThanMin(LocalDate depositStartDate, LocalDate depositEndDate) {
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.minDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return depositPeriod.compareTo(minDepositTerm()) >= 0;
return minDepositTerm() == null || depositPeriod.compareTo(minDepositTerm()) >= 0;
}
private boolean isEqualOrLessThanMax(LocalDate depositStartDate, LocalDate depositEndDate) {
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.maxDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return depositPeriod.compareTo(maxDepositTerm()) <= 0;
return maxDepositTerm() == null || depositPeriod.compareTo(maxDepositTerm()) <= 0;
}
public Integer depositPeriod(final LocalDate periodStartDate, final LocalDate periodEndDate,