Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ org.apache.fineract.common.validation.time.DurationMax.message=must be shorter t
org.apache.fineract.common.validation.time.DurationMin.message=must be longer than${inclusive == true ? ' or equal to' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'}
# dummy
org.apache.fineract.dummy.request.content.not-empty=Dummy request content must have a value

# Interest Rate Chart validation messages
validation.msg.savings.interestRateChart.slabs.overlap=There is an overlap between slabs {0} and {1}.
validation.msg.savings.interestRateChart.slabs.gap=There is a gap between slabs {0} and {1}.
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ org.apache.fineract.common.validation.time.DurationMax.message=muss k\u00fcrzer
org.apache.fineract.common.validation.time.DurationMin.message=muss gr\u00f6\u00dfer sein als${inclusive == true ? ' oder gleich' : ''}${days == 0 ? '' : days == 1 ? ' 1 Tag' : ' ' += days += ' Tage'}${hours == 0 ? '' : hours == 1 ? ' 1 Stunde' : ' ' += hours += ' Stunden'}${minutes == 0 ? '' : minutes == 1 ? ' 1 Minute' : ' ' += minutes += ' Minuten'}${seconds == 0 ? '' : seconds == 1 ? ' 1 Sekunde' : ' ' += seconds += ' Sekunden'}${millis == 0 ? '' : millis == 1 ? ' 1 Millisekunde' : ' ' += millis += ' Millisekunden'}${nanos == 0 ? '' : nanos == 1 ? ' 1 Nanosekunde' : ' ' += nanos += ' Nanosekunden'}
# dummy
org.apache.fineract.dummy.request.content.not-empty=Dummy Request Attribut muss einen Wert enthalten

# Interest Rate Chart validation messages
validation.msg.savings.interestRateChart.slabs.overlap=Es gibt eine Überlappung zwischen Segmenten {0} und {1}.
validation.msg.savings.interestRateChart.slabs.gap=Es gibt eine Lücke zwischen Segmenten {0} und {1}.
22 changes: 22 additions & 0 deletions fineract-provider/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Interest Rate Chart validation messages
validation.msg.savings.interestRateChart.slabs.overlap=There is an overlap between slabs {0} and {1}.
validation.msg.savings.interestRateChart.slabs.gap=There is a gap between slabs {0} and {1}.
22 changes: 22 additions & 0 deletions fineract-provider/src/main/resources/messages_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Interest Rate Chart validation messages
validation.msg.savings.interestRateChart.slabs.overlap=Es gibt eine Überlappung zwischen Segmenten {0} und {1}.
validation.msg.savings.interestRateChart.slabs.gap=Es gibt eine Lücke zwischen Segmenten {0} und {1}.
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,21 @@ public void validateChartSlabs(DataValidatorBuilder baseDataValidator) {
if (iSlabs.slabFields().isValidChart(isPrimaryGroupingByAmount)
&& nextSlabs.slabFields().isValidChart(isPrimaryGroupingByAmount)) {
if (iSlabs.slabFields().isRateChartOverlapping(nextSlabs.slabFields(), isPrimaryGroupingByAmount)) {
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("chart.slabs.range.overlapping",
iSlabs.slabFields().fromPeriod(), iSlabs.slabFields().toPeriod(), nextSlabs.slabFields().fromPeriod(),
nextSlabs.slabFields().toPeriod(), iSlabs.slabFields().getAmountRangeFrom(),
iSlabs.slabFields().getAmountRangeTo(), nextSlabs.slabFields().getAmountRangeFrom(),
nextSlabs.slabFields().getAmountRangeTo());
// Use DataValidatorBuilder with resource/parameter context for clean error codes
DataValidatorBuilder v = new DataValidatorBuilder(baseDataValidator.getDataValidationErrors())
.resource("savings.interestRateChart").parameter("slabs");
v.failWithCode("overlap", iSlabs.slabFields().fromPeriod(), iSlabs.slabFields().toPeriod(),
nextSlabs.slabFields().fromPeriod(), nextSlabs.slabFields().toPeriod(),
iSlabs.slabFields().getAmountRangeFrom(), iSlabs.slabFields().getAmountRangeTo(),
nextSlabs.slabFields().getAmountRangeFrom(), nextSlabs.slabFields().getAmountRangeTo());
} else if (iSlabs.slabFields().isRateChartHasGap(nextSlabs.slabFields(), isPrimaryGroupingByAmount)) {
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("chart.slabs.range.has.gap",
iSlabs.slabFields().fromPeriod(), iSlabs.slabFields().toPeriod(), nextSlabs.slabFields().fromPeriod(),
nextSlabs.slabFields().toPeriod(), iSlabs.slabFields().getAmountRangeFrom(),
iSlabs.slabFields().getAmountRangeTo(), nextSlabs.slabFields().getAmountRangeFrom(),
nextSlabs.slabFields().getAmountRangeTo());
// Use DataValidatorBuilder with resource/parameter context for clean error codes
DataValidatorBuilder v = new DataValidatorBuilder(baseDataValidator.getDataValidationErrors())
.resource("savings.interestRateChart").parameter("slabs");
v.failWithCode("gap", iSlabs.slabFields().fromPeriod(), iSlabs.slabFields().toPeriod(),
nextSlabs.slabFields().fromPeriod(), nextSlabs.slabFields().toPeriod(),
iSlabs.slabFields().getAmountRangeFrom(), iSlabs.slabFields().getAmountRangeTo(),
nextSlabs.slabFields().getAmountRangeFrom(), nextSlabs.slabFields().getAmountRangeTo());
}
if (isPrimaryGroupingByAmount) {
if (!iSlabs.slabFields().isAmountSame(nextSlabs.slabFields())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.interestratechart.domain;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.util.ArrayList;
import java.util.List;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Test class for InterestRateChart validation error codes and arguments
*/
public class InterestRateChartValidationTest {

private List<ApiParameterError> dataValidationErrors;

@BeforeEach
public void setUp() {
dataValidationErrors = new ArrayList<>();
}

@Test
public void testOverlappingRangesValidation() {
// Given - use DataValidatorBuilder with resource/parameter context
DataValidatorBuilder v = new DataValidatorBuilder(dataValidationErrors).resource("savings.interestRateChart").parameter("slabs");

// When - simulate overlapping ranges validation
v.failWithCode("overlap", 1, 12, 6, 18, 1000.0, 5000.0, 3000.0, 8000.0);

// Then
assertEquals(1, dataValidationErrors.size(), "Expected exactly one validation error");
ApiParameterError actualError = dataValidationErrors.get(0);
assertEquals("validation.msg.savings.interestRateChart.slabs.overlap", actualError.getUserMessageGlobalisationCode());
// Check that arguments are present
assertFalse(actualError.getArgs().isEmpty());
}

@Test
public void testGapBetweenRangesValidation() {
// Given - use DataValidatorBuilder with resource/parameter context
DataValidatorBuilder v = new DataValidatorBuilder(dataValidationErrors).resource("savings.interestRateChart").parameter("slabs");

// When - simulate gap between ranges validation
v.failWithCode("gap", 1, 12, 15, 24, 1000.0, 5000.0, 6000.0, 10000.0);

// Then
assertEquals(1, dataValidationErrors.size(), "Expected exactly one validation error");
ApiParameterError actualError = dataValidationErrors.get(0);
assertEquals("validation.msg.savings.interestRateChart.slabs.gap", actualError.getUserMessageGlobalisationCode());
// Check that arguments are present
assertFalse(actualError.getArgs().isEmpty());
}
}
Loading