FINERACT-1724: Sonar fixes
Fineract Docker build - MariaDB / build (push) Canceled after 0s
Fineract Docker build - PostgreSQL / build (push) Canceled after 0s
Fineract Kafka Smoke / build (push) Canceled after 0s
Fineract Documentation build / build (push) Canceled after 0s
Fineract Build & Test - MariaDB / build (push) Canceled after 0s
Fineract Build & Test - MySQL / build (push) Canceled after 0s
Fineract Build & Test - PostgreSQL / build (push) Canceled after 0s
Fineract ActiveMQ Smoke / build (push) Canceled after 0s

This commit is contained in:
abraham.menyhart
2023-08-10 12:56:45 +02:00
committed by Adam Saghy
parent 33c1aa7874
commit d6c10e8303
31 changed files with 113 additions and 276 deletions
@@ -17,7 +17,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.batch.repeat.RepeatStatus.FINISHED;
import com.acme.fineract.loan.job.AcmeNoopJobTasklet; import com.acme.fineract.loan.job.AcmeNoopJobTasklet;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@@ -47,7 +48,7 @@ public class AcmeNoopJobTaskletTest {
@Test @Test
public void testJobExecution() throws Exception { public void testJobExecution() throws Exception {
resultStatus = underTest.execute(stepContribution, chunkContext); resultStatus = underTest.execute(stepContribution, chunkContext);
assertEquals(resultStatus, RepeatStatus.FINISHED); assertEquals(FINISHED, resultStatus);
} }
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.client.util; package org.apache.fineract.client.util;
import java.io.IOException; import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Response; import retrofit2.Response;
@@ -27,6 +28,7 @@ import retrofit2.Response;
* *
* @author Michael Vorburger.ch * @author Michael Vorburger.ch
*/ */
@Slf4j
public class CallFailedRuntimeException extends RuntimeException { public class CallFailedRuntimeException extends RuntimeException {
private final Call<?> call; private final Call<?> call;
@@ -46,17 +48,17 @@ public class CallFailedRuntimeException extends RuntimeException {
private static String message(Call<?> call, Response<?> response) { private static String message(Call<?> call, Response<?> response) {
StringBuilder sb = new StringBuilder("HTTP failed: " + call.request() + "; " + response); StringBuilder sb = new StringBuilder("HTTP failed: " + call.request() + "; " + response);
if (response.message() != null && !response.message().isEmpty()) { if (null != response.message() && !response.message().isEmpty()) {
sb.append("; message: " + response.message()); sb.append("; message: ").append(response.message());
} }
String errorBody; String errorBody;
try { try {
errorBody = response.errorBody().string(); errorBody = response.errorBody() != null ? response.errorBody().string() : null;
if (errorBody != null) { if (errorBody != null) {
sb.append("; errorBody: " + errorBody); sb.append("; errorBody: ").append(errorBody);
} }
} catch (IOException e) { } catch (IOException e) {
// Ignore. log.error("Exception during creating the {} message:", CallFailedRuntimeException.class.getSimpleName(), e);
} }
return sb.toString(); return sb.toString();
} }
@@ -23,6 +23,7 @@ import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import io.gsonfire.GsonFireBuilder; import io.gsonfire.GsonFireBuilder;
import java.io.IOException; import java.io.IOException;
@@ -35,10 +36,12 @@ import java.time.LocalDate;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import org.apache.fineract.client.models.ExternalId; import org.apache.fineract.client.models.ExternalId;
import org.apache.fineract.client.util.adapter.ExternalIdAdapter; import org.apache.fineract.client.util.adapter.ExternalIdAdapter;
import org.jetbrains.annotations.NotNull;
import retrofit2.Converter; import retrofit2.Converter;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
@@ -212,25 +215,28 @@ public class JSON {
@Override @Override
public Date read(JsonReader in) throws IOException { public Date read(JsonReader in) throws IOException {
try { try {
switch (in.peek()) { if (Objects.requireNonNull(in.peek()) == JsonToken.NULL) {
case NULL: in.nextNull();
in.nextNull(); return null;
return null;
default:
String date = in.nextString();
try {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}
} }
String date = in.nextString();
return parseDate(date);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new JsonParseException(e); throw new JsonParseException(e);
} }
} }
@NotNull
private Date parseDate(String date) {
try {
if (null != dateFormat) {
return dateFormat.parse(date);
}
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}
}
} }
// The following is not from the generated JSON class, but from the original generated ApiClient. // The following is not from the generated JSON class, but from the original generated ApiClient.
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
public class FineractClientTechnicalTest { public class FineractClientTechnicalTest {
@Test @Test
@Disabled // TODO remove Ignore once https://issues.apache.org/jira/browse/FINERACT-1221 is fixed @Disabled("remove Ignore once https://issues.apache.org/jira/browse/FINERACT-1221 is fixed")
void testInvalidOperations() { void testInvalidOperations() {
FineractClient.Builder builder = FineractClient.builder().baseURL("http://test/").tenant("default").basicAuth("mifos", "password"); FineractClient.Builder builder = FineractClient.builder().baseURL("http://test/").tenant("default").basicAuth("mifos", "password");
builder.getRetrofitBuilder().validateEagerly(true); // see FINERACT-1221 builder.getRetrofitBuilder().validateEagerly(true); // see FINERACT-1221
@@ -20,11 +20,8 @@ package org.apache.fineract.infrastructure.core.api;
import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.MultivaluedMap;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper; import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
@@ -148,16 +145,4 @@ public final class ApiParameterHelper {
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) { public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
return queryParams.getFirst("genericResultSet") != null; return queryParams.getFirst("genericResultSet") != null;
} }
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
final Map<String, String> map = new HashMap<>(queryParameters.size());
for (final String parameterName : queryParameters.keySet()) {
final List<String> values = queryParameters.get(parameterName);
map.put(parameterName, values.get(0));
}
return map;
}
} }
@@ -61,6 +61,7 @@ public class FineractProperties {
private FineractTemplateProperties template; private FineractTemplateProperties template;
private FineractJpaProperties jpa; private FineractJpaProperties jpa;
private FineractDatabaseProperties database;
private FineractQueryProperties query; private FineractQueryProperties query;
private FineractApiProperties api; private FineractApiProperties api;
private FineractSecurityProperties security; private FineractSecurityProperties security;
@@ -398,6 +399,13 @@ public class FineractProperties {
private boolean statementLoggingEnabled; private boolean statementLoggingEnabled;
} }
@Getter
@Setter
public static class FineractDatabaseProperties {
private String defaultMasterPassword;
}
@Getter @Getter
@Setter @Setter
public static class FineractQueryProperties { public static class FineractQueryProperties {
@@ -18,8 +18,6 @@
*/ */
package org.apache.fineract.infrastructure.core.data; package org.apache.fineract.infrastructure.core.data;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -176,13 +174,10 @@ public class DataValidatorBuilder {
return this; return this;
} }
/*** FIXME: Vishwas, why does this method have a parameter? Seems wrong ***/ public DataValidatorBuilder trueOrFalseRequired(final Object trueOfFalseField) {
/*
* This method is not meant for validation, if you have mandatory boolean param and if it has invalid value or value if (trueOfFalseField != null && !trueOfFalseField.toString().equalsIgnoreCase("true")
* not passed then call this method, this method is always used with input as false && !trueOfFalseField.toString().equalsIgnoreCase("false")) {
*/
public DataValidatorBuilder trueOrFalseRequired1(final boolean trueOfFalseFieldProvided) {
if (!trueOfFalseFieldProvided && !this.ignoreNullValue) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".must.be.true.or.false"); .append(this.parameter).append(".must.be.true.or.false");
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter `").append(this.parameter) final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter `").append(this.parameter)
@@ -191,22 +186,6 @@ public class DataValidatorBuilder {
defaultEnglishMessage.toString(), this.parameter); defaultEnglishMessage.toString(), this.parameter);
this.dataValidationErrors.add(error); this.dataValidationErrors.add(error);
} }
return this;
}
public DataValidatorBuilder trueOrFalseRequired(final Object trueOfFalseField) {
if (trueOfFalseField != null) {
if (!trueOfFalseField.toString().equalsIgnoreCase("true") && !trueOfFalseField.toString().equalsIgnoreCase("false")) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".must.be.true.or.false");
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter `").append(this.parameter)
.append("` must be set as true or false.");
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
defaultEnglishMessage.toString(), this.parameter);
this.dataValidationErrors.add(error);
}
}
return this; return this;
} }
@@ -320,7 +299,7 @@ public class DataValidatorBuilder {
final List<Object> rawValuesList = Arrays.asList(values); final List<Object> rawValuesList = Arrays.asList(values);
if (this.value == null || !rawValuesList.contains(this.value)) { if (this.value == null || !rawValuesList.contains(this.value)) {
final List<String> valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); final List<String> valuesList = Arrays.stream(values).map(Object::toString).toList();
final String valuesListStr = String.join(", ", valuesList); final String valuesListStr = String.join(", ", valuesList);
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.not.one.of.expected.enumerations"); .append(this.parameter).append(".is.not.one.of.expected.enumerations");
@@ -349,7 +328,7 @@ public class DataValidatorBuilder {
final List<Object> rawValuesList = Arrays.asList(values); final List<Object> rawValuesList = Arrays.asList(values);
if (this.value == null || !rawValuesList.contains(this.value.toString().toLowerCase())) { if (this.value == null || !rawValuesList.contains(this.value.toString().toLowerCase())) {
final List<String> valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); final List<String> valuesList = Arrays.stream(values).map(Object::toString).toList();
final String valuesListStr = String.join(", ", valuesList); final String valuesListStr = String.join(", ", valuesList);
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.not.one.of.expected.enumerations"); .append(this.parameter).append(".is.not.one.of.expected.enumerations");
@@ -397,7 +376,7 @@ public class DataValidatorBuilder {
final List<Object> rawValuesList = Arrays.asList(values); final List<Object> rawValuesList = Arrays.asList(values);
if (rawValuesList.contains(this.value)) { if (rawValuesList.contains(this.value)) {
final List<String> valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); final List<String> valuesList = Arrays.stream(values).map(Object::toString).toList();
final String valuesListStr = String.join(", ", valuesList); final String valuesListStr = String.join(", ", valuesList);
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.one.of.unwanted.enumerations"); .append(this.parameter).append(".is.one.of.unwanted.enumerations");
@@ -879,17 +858,15 @@ public class DataValidatorBuilder {
} }
public DataValidatorBuilder compareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) { public DataValidatorBuilder compareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) {
if (min != null && max != null) { if (min != null && max != null && max.compareTo(min) < 0) {
if (max.compareTo(min) < 0) { final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".is.not.within.expected.range");
.append(this.parameter).append(".is.not.within.expected.range"); final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min) .append(" should less than max number ").append(max).append(".");
.append(" should less than max number ").append(max).append("."); final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), this.parameter, min, max);
defaultEnglishMessage.toString(), this.parameter, min, max); this.dataValidationErrors.add(error);
this.dataValidationErrors.add(error); return this;
return this;
}
} }
return this; return this;
} }
@@ -34,8 +34,6 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor {
public static final String DEFAULT_ENCRYPTION = "AES/CBC/PKCS5Padding"; public static final String DEFAULT_ENCRYPTION = "AES/CBC/PKCS5Padding";
public static final String DEFAULT_MASTER_PASSWORD = "fineract";
private final FineractProperties fineractProperties; private final FineractProperties fineractProperties;
@SuppressWarnings("checkstyle:regexpsinglelinejava") @SuppressWarnings("checkstyle:regexpsinglelinejava")
@@ -54,7 +52,8 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor {
@Override @Override
public String encrypt(String plainPassword) { public String encrypt(String plainPassword) {
String masterPassword = Optional.ofNullable(fineractProperties.getTenant()) String masterPassword = Optional.ofNullable(fineractProperties.getTenant())
.map(FineractProperties.FineractTenantProperties::getMasterPassword).orElse(DEFAULT_MASTER_PASSWORD); .map(FineractProperties.FineractTenantProperties::getMasterPassword)
.orElse(fineractProperties.getDatabase().getDefaultMasterPassword());
String encryption = Optional.ofNullable(fineractProperties.getTenant()) String encryption = Optional.ofNullable(fineractProperties.getTenant())
.map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION); .map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION);
return EncryptionUtil.encryptToBase64(encryption, masterPassword, plainPassword); return EncryptionUtil.encryptToBase64(encryption, masterPassword, plainPassword);
@@ -63,7 +62,8 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor {
@Override @Override
public String decrypt(String encryptedPassword) { public String decrypt(String encryptedPassword) {
String masterPassword = Optional.ofNullable(fineractProperties.getTenant()) String masterPassword = Optional.ofNullable(fineractProperties.getTenant())
.map(FineractProperties.FineractTenantProperties::getMasterPassword).orElse(DEFAULT_MASTER_PASSWORD); .map(FineractProperties.FineractTenantProperties::getMasterPassword)
.orElse(fineractProperties.getDatabase().getDefaultMasterPassword());
String encryption = Optional.ofNullable(fineractProperties.getTenant()) String encryption = Optional.ofNullable(fineractProperties.getTenant())
.map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION); .map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION);
return EncryptionUtil.decryptFromBase64(encryption, masterPassword, encryptedPassword); return EncryptionUtil.decryptFromBase64(encryption, masterPassword, encryptedPassword);
@@ -73,7 +73,7 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor {
String masterPassword = Optional.ofNullable(fineractProperties) // String masterPassword = Optional.ofNullable(fineractProperties) //
.map(FineractProperties::getTenant) // .map(FineractProperties::getTenant) //
.map(FineractProperties.FineractTenantProperties::getMasterPassword) // .map(FineractProperties.FineractTenantProperties::getMasterPassword) //
.orElse(DEFAULT_MASTER_PASSWORD); .orElse(fineractProperties.getDatabase().getDefaultMasterPassword());
return BCrypt.hashpw(masterPassword.getBytes(StandardCharsets.UTF_8), BCrypt.gensalt()); return BCrypt.hashpw(masterPassword.getBytes(StandardCharsets.UTF_8), BCrypt.gensalt());
} }
@@ -81,7 +81,7 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor {
String masterPassword = Optional.ofNullable(fineractProperties) // String masterPassword = Optional.ofNullable(fineractProperties) //
.map(FineractProperties::getTenant) // .map(FineractProperties::getTenant) //
.map(FineractProperties.FineractTenantProperties::getMasterPassword) // .map(FineractProperties.FineractTenantProperties::getMasterPassword) //
.orElse(DEFAULT_MASTER_PASSWORD); .orElse(fineractProperties.getDatabase().getDefaultMasterPassword());
return BCrypt.checkpw(masterPassword, hashed); return BCrypt.checkpw(masterPassword, hashed);
} }
} }
@@ -71,8 +71,7 @@ public final class WorkingDaysUtil {
adjustedDateDetailsDTO.setChangedScheduleDate(changedScheduleDate); adjustedDateDetailsDTO.setChangedScheduleDate(changedScheduleDate);
} }
public static RepaymentRescheduleType getRepaymentRescheduleType(final WorkingDays workingDays, final LocalDate date) { public static RepaymentRescheduleType getRepaymentRescheduleType(final WorkingDays workingDays) {
RepaymentRescheduleType rescheduleType = RepaymentRescheduleType.fromInt(workingDays.getRepaymentReschedulingType()); return RepaymentRescheduleType.fromInt(workingDays.getRepaymentReschedulingType());
return rescheduleType;
} }
} }
@@ -377,30 +377,16 @@ public final class CalendarData implements Serializable {
} }
public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) {
if (this.startDate != null && compareDate != null) { return this.startDate != null && compareDate != null
if (this.startDate.isBefore(compareDate) || this.startDate.equals(compareDate)) { && (this.startDate.isBefore(compareDate) || this.startDate.equals(compareDate));
return true;
}
}
return false;
} }
public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { public boolean isEndDateAfterOrEqual(final LocalDate compareDate) {
if (this.endDate != null && compareDate != null) { return this.endDate != null && compareDate != null && (this.endDate.isAfter(compareDate) || this.endDate.isEqual(compareDate));
if (this.endDate.isAfter(compareDate) || this.endDate.isEqual(compareDate)) {
return true;
}
}
return false;
} }
public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { public boolean isBetweenStartAndEndDate(final LocalDate compareDate) {
if (isStartDateBeforeOrEqual(compareDate)) { return isStartDateBeforeOrEqual(compareDate) && (this.endDate == null || isEndDateAfterOrEqual(compareDate));
if (this.endDate == null || isEndDateAfterOrEqual(compareDate)) {
return true;
}
}
return false;
} }
public boolean isValidRecurringDate(final LocalDate compareDate, final Boolean isSkipMeetingOnFirstDay, final Integer numberOfDays) { public boolean isValidRecurringDate(final LocalDate compareDate, final Boolean isSkipMeetingOnFirstDay, final Integer numberOfDays) {
@@ -153,10 +153,7 @@ public class Calendar extends AbstractAuditableWithUTCDateTimeCustom {
public static Calendar fromJson(final JsonCommand command) { public static Calendar fromJson(final JsonCommand command) {
// final Long entityId = command.getSupportedEntityId(); LocalTime meetingtime;
// final Integer entityTypeId =
// CalendarEntityType.valueOf(command.getSupportedEntityType().toUpperCase()).getValue();
LocalTime meetingtime = null;
final String title = command.stringValueOfParameterNamed(CalendarSupportedParameters.TITLE.getValue()); final String title = command.stringValueOfParameterNamed(CalendarSupportedParameters.TITLE.getValue());
final String description = command.stringValueOfParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue()); final String description = command.stringValueOfParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue());
final String location = command.stringValueOfParameterNamed(CalendarSupportedParameters.LOCATION.getValue()); final String location = command.stringValueOfParameterNamed(CalendarSupportedParameters.LOCATION.getValue());
@@ -304,10 +301,6 @@ public class Calendar extends AbstractAuditableWithUTCDateTimeCustom {
final String newMeetingType = CalendarType.fromInt(newValue).name(); final String newMeetingType = CalendarType.fromInt(newValue).name();
throw new CalendarParameterUpdateNotSupportedException("meeting.type", defaultUserMessage, newMeetingType, oldMeeingType); throw new CalendarParameterUpdateNotSupportedException("meeting.type", defaultUserMessage, newMeetingType, oldMeeingType);
/*
* final Integer newValue = command.integerValueSansLocaleOfParameterNamed(typeParamName);
* actualChanges.put(typeParamName, newValue); this.typeId = newValue;
*/
} }
final String repeatingParamName = CalendarSupportedParameters.REPEATING.getValue(); final String repeatingParamName = CalendarSupportedParameters.REPEATING.getValue();
@@ -401,11 +394,9 @@ public class Calendar extends AbstractAuditableWithUTCDateTimeCustom {
final Integer interval, final Integer repeatsOnDay, final Integer repeatsOnNthDay) { final Integer interval, final Integer repeatsOnDay, final Integer repeatsOnNthDay) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(9); final Map<String, Object> actualChanges = new LinkedHashMap<>(9);
if (calendarStartDate != null && this.startDate != null) { if (calendarStartDate != null && this.startDate != null && !calendarStartDate.equals(this.getStartDateLocalDate())) {
if (!calendarStartDate.equals(this.getStartDateLocalDate())) { actualChanges.put("startDate", calendarStartDate);
actualChanges.put("startDate", calendarStartDate); this.startDate = calendarStartDate;
this.startDate = calendarStartDate;
}
} }
final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay, repeatsOnNthDay); final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay, repeatsOnNthDay);
@@ -488,46 +479,21 @@ public class Calendar extends AbstractAuditableWithUTCDateTimeCustom {
} }
public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) {
if (this.startDate != null && compareDate != null) { return this.startDate != null && compareDate != null
if (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)) { && (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate));
return true;
}
}
return false;
} }
public boolean isStartDateAfter(final LocalDate compareDate) { public boolean isStartDateAfter(final LocalDate compareDate) {
if (this.startDate != null && compareDate != null && getStartDateLocalDate().isAfter(compareDate)) { return this.startDate != null && compareDate != null && getStartDateLocalDate().isAfter(compareDate);
return true;
}
return false;
}
public boolean isStartDateAfterOrEqual(final LocalDate compareDate) {
if (this.startDate != null && compareDate != null) {
if (getStartDateLocalDate().isAfter(compareDate) || getStartDateLocalDate().isEqual(compareDate)) {
return true;
}
}
return false;
} }
public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { public boolean isEndDateAfterOrEqual(final LocalDate compareDate) {
if (this.endDate != null && compareDate != null) { return this.endDate != null && compareDate != null
if (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)) { && (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate));
return true;
}
}
return false;
} }
public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { public boolean isBetweenStartAndEndDate(final LocalDate compareDate) {
if (isStartDateBeforeOrEqual(compareDate)) { return isStartDateBeforeOrEqual(compareDate) && (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate));
if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) {
return true;
}
}
return false;
} }
private static String constructRecurrence(final JsonCommand command, final Calendar calendar) { private static String constructRecurrence(final JsonCommand command, final Calendar calendar) {
@@ -104,30 +104,17 @@ public class CalendarHistory extends AbstractPersistableCustom {
} }
public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { public boolean isEndDateAfterOrEqual(final LocalDate compareDate) {
if (this.endDate != null && compareDate != null) { return this.endDate != null && compareDate != null
if (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)) { && (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate));
return true;
}
}
return false;
} }
public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) {
if (this.startDate != null && compareDate != null) { return this.startDate != null && compareDate != null
if (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)) { && (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate));
return true;
}
}
return false;
} }
public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { public boolean isBetweenStartAndEndDate(final LocalDate compareDate) {
if (isStartDateBeforeOrEqual(compareDate)) { return isStartDateBeforeOrEqual(compareDate) && (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate));
if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) {
return true;
}
}
return false;
} }
public void updateEndDate(LocalDate historyCalEndDate) { public void updateEndDate(LocalDate historyCalEndDate) {
@@ -833,7 +833,7 @@ public final class CalendarUtils {
LocalDate nextRepaymentDate = null; LocalDate nextRepaymentDate = null;
if (applyWorkingDays) { if (applyWorkingDays) {
if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDate) if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDate)
&& WorkingDaysUtil.getRepaymentRescheduleType(workingDays, newRepaymentDate).isMoveToNextRepaymentDay()) { && WorkingDaysUtil.getRepaymentRescheduleType(workingDays).isMoveToNextRepaymentDay()) {
newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1), loanRepaymentInterval, newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1), loanRepaymentInterval,
frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays, isCalledFirstTime, applyWorkingDays); frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays, isCalledFirstTime, applyWorkingDays);
} else { } else {
@@ -851,7 +851,7 @@ public final class CalendarUtils {
final LocalDate newRepaymentDateTemp = adjustRecurringDate(newRepaymentDate, numberOfDays); final LocalDate newRepaymentDateTemp = adjustRecurringDate(newRepaymentDate, numberOfDays);
if (applyWorkingDays) { if (applyWorkingDays) {
if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDateTemp) if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDateTemp)
&& WorkingDaysUtil.getRepaymentRescheduleType(workingDays, newRepaymentDateTemp).isMoveToNextRepaymentDay()) { && WorkingDaysUtil.getRepaymentRescheduleType(workingDays).isMoveToNextRepaymentDay()) {
newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1), newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1),
loanRepaymentInterval, frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays, loanRepaymentInterval, frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays,
isCalledFirstTime, applyWorkingDays); isCalledFirstTime, applyWorkingDays);
@@ -95,7 +95,7 @@ public enum DepositAccountType {
public String resourceName() { public String resourceName() {
String resourceName = "INVALID"; String resourceName;
switch (this) { switch (this) {
case FIXED_DEPOSIT: case FIXED_DEPOSIT:
@@ -28,7 +28,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -229,14 +228,10 @@ public final class SavingsAccountData implements Serializable {
this.savingsAmountOnHold = null; this.savingsAmountOnHold = null;
} }
public static final Comparator<SavingsAccountData> ClientNameComparator = new Comparator<SavingsAccountData>() { public static final Comparator<SavingsAccountData> ClientNameComparator = (savings1, savings2) -> {
String clientOfSavings1 = savings1.getClientName().toUpperCase(Locale.ENGLISH);
@Override String clientOfSavings2 = savings2.getClientName().toUpperCase(Locale.ENGLISH);
public int compare(SavingsAccountData savings1, SavingsAccountData savings2) { return clientOfSavings1.compareTo(clientOfSavings2);
String clientOfSavings1 = savings1.getClientName().toUpperCase(Locale.ENGLISH);
String clientOfSavings2 = savings2.getClientName().toUpperCase(Locale.ENGLISH);
return clientOfSavings1.compareTo(clientOfSavings2);
}
}; };
public void setNewSavingsAccountTransactionData(final SavingsAccountTransactionData savingsAccountTransactionData) { public void setNewSavingsAccountTransactionData(final SavingsAccountTransactionData savingsAccountTransactionData) {
@@ -395,7 +390,7 @@ public final class SavingsAccountData implements Serializable {
} }
public List<SavingsAccountTransactionData> getSavingsAccountTransactionsWithPivotConfig() { public List<SavingsAccountTransactionData> getSavingsAccountTransactionsWithPivotConfig() {
return this.transactions.stream().collect(Collectors.toList()); return this.transactions.stream().toList();
} }
public Boolean isAccrualBasedAccountingEnabledOnSavingsProduct() { public Boolean isAccrualBasedAccountingEnabledOnSavingsProduct() {
@@ -167,7 +167,7 @@ public class SavingsAccountSummaryData implements Serializable {
this.totalDeposits = wrapper.calculateTotalDeposits(currency, savingsAccountTransactions); this.totalDeposits = wrapper.calculateTotalDeposits(currency, savingsAccountTransactions);
this.totalWithdrawals = wrapper.calculateTotalWithdrawals(currency, savingsAccountTransactions); this.totalWithdrawals = wrapper.calculateTotalWithdrawals(currency, savingsAccountTransactions);
final HashMap<String, Money> map = updateRunningBalanceAndPivotDate(true, savingsAccountTransactions, interestTotal, final HashMap<String, Money> map = updateRunningBalanceAndPivotDate(true, savingsAccountTransactions, interestTotal,
overdraftInterestTotal, withHoldTaxTotal, currency); overdraftInterestTotal, withHoldTaxTotal);
interestTotal = map.get("interestTotal"); interestTotal = map.get("interestTotal");
withHoldTaxTotal = map.get("withHoldTax"); withHoldTaxTotal = map.get("withHoldTax");
overdraftInterestTotal = map.get("overdraftInterestTotal"); overdraftInterestTotal = map.get("overdraftInterestTotal");
@@ -200,7 +200,7 @@ public class SavingsAccountSummaryData implements Serializable {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private HashMap<String, Money> updateRunningBalanceAndPivotDate(final boolean backdatedTxnsAllowedTill, private HashMap<String, Money> updateRunningBalanceAndPivotDate(final boolean backdatedTxnsAllowedTill,
final List<SavingsAccountTransactionData> savingsAccountTransactions, Money interestTotal, Money overdraftInterestTotal, final List<SavingsAccountTransactionData> savingsAccountTransactions, Money interestTotal, Money overdraftInterestTotal,
Money withHoldTaxTotal, CurrencyData currency) { Money withHoldTaxTotal) {
boolean isUpdated = false; boolean isUpdated = false;
HashMap<String, Money> map = new HashMap<>(); HashMap<String, Money> map = new HashMap<>();
for (int i = savingsAccountTransactions.size() - 1; i >= 0; i--) { for (int i = savingsAccountTransactions.size() - 1; i >= 0; i--) {
@@ -257,7 +257,7 @@ public class SavingsAccountSummaryData implements Serializable {
this.totalWithholdTax = wrapper.calculateTotalWithholdTaxWithdrawal(currency, transactions); this.totalWithholdTax = wrapper.calculateTotalWithholdTaxWithdrawal(currency, transactions);
// boolean isUpdated = false; // boolean isUpdated = false;
updateRunningBalanceAndPivotDate(false, transactions, null, null, null, currency); updateRunningBalanceAndPivotDate(false, transactions, null, null, null);
this.accountBalance = Money.of(currency, this.totalDeposits).plus(this.totalInterestPosted).minus(this.totalWithdrawals) this.accountBalance = Money.of(currency, this.totalDeposits).plus(this.totalInterestPosted).minus(this.totalWithdrawals)
.minus(this.totalWithdrawalFees).minus(this.totalAnnualFees).minus(this.totalFeeCharge).minus(this.totalPenaltyCharge) .minus(this.totalWithdrawalFees).minus(this.totalAnnualFees).minus(this.totalFeeCharge).minus(this.totalPenaltyCharge)
@@ -661,16 +661,6 @@ public final class SavingsEnumerations {
return optionData; return optionData;
} }
public static List<EnumOptionData> depositTermFrequencyType(final SavingsPeriodFrequencyType[] types) {
final List<EnumOptionData> optionDatas = new ArrayList<>();
for (final SavingsPeriodFrequencyType type : types) {
if (!type.isInvalid()) {
optionDatas.add(recurringDepositFrequencyType(type));
}
}
return optionDatas;
}
public static EnumOptionData inMultiplesOfDepositTermFrequencyType(final int id) { public static EnumOptionData inMultiplesOfDepositTermFrequencyType(final int id) {
return depositTermFrequencyType(SavingsPeriodFrequencyType.fromInt(id)); return depositTermFrequencyType(SavingsPeriodFrequencyType.fromInt(id));
} }
@@ -702,16 +692,6 @@ public final class SavingsEnumerations {
return optionData; return optionData;
} }
public static List<EnumOptionData> inMultiplesOfDepositTermFrequencyType(final SavingsPeriodFrequencyType[] types) {
final List<EnumOptionData> optionDatas = new ArrayList<>();
for (final SavingsPeriodFrequencyType type : types) {
if (!type.isInvalid()) {
optionDatas.add(recurringDepositFrequencyType(type));
}
}
return optionDatas;
}
public static EnumOptionData depositType(final Integer id) { public static EnumOptionData depositType(final Integer id) {
return depositType(DepositAccountType.fromInt(id)); return depositType(DepositAccountType.fromInt(id));
} }
@@ -22,7 +22,6 @@ import org.apache.fineract.cob.COBBusinessStepService;
import org.apache.fineract.cob.common.CustomJobParameterResolver; import org.apache.fineract.cob.common.CustomJobParameterResolver;
import org.apache.fineract.cob.common.ResetContextTasklet; import org.apache.fineract.cob.common.ResetContextTasklet;
import org.apache.fineract.cob.conditions.LoanCOBEnabledCondition; import org.apache.fineract.cob.conditions.LoanCOBEnabledCondition;
import org.apache.fineract.cob.domain.LoanAccountLockRepository;
import org.apache.fineract.cob.listener.InlineCOBLoanItemListener; import org.apache.fineract.cob.listener.InlineCOBLoanItemListener;
import org.apache.fineract.infrastructure.jobs.domain.CustomJobParameterRepository; import org.apache.fineract.infrastructure.jobs.domain.CustomJobParameterRepository;
import org.apache.fineract.infrastructure.jobs.service.JobName; import org.apache.fineract.infrastructure.jobs.service.JobName;
@@ -60,8 +59,6 @@ public class LoanInlineCOBConfig {
@Autowired @Autowired
private COBBusinessStepService cobBusinessStepService; private COBBusinessStepService cobBusinessStepService;
@Autowired @Autowired
private LoanAccountLockRepository accountLockRepository;
@Autowired
private TransactionTemplate transactionTemplate; private TransactionTemplate transactionTemplate;
@Autowired @Autowired
private CustomJobParameterRepository customJobParameterRepository; private CustomJobParameterRepository customJobParameterRepository;
@@ -134,8 +134,9 @@ public class ChartOfAccountsImportHandler implements ImportHandler {
tagIdCodeValueData = new CodeValueData().setId(tagId); tagIdCodeValueData = new CodeValueData().setId(tagId);
} }
String description = ImportHandlerUtils.readAsString(ChartOfAcountsConstants.DESCRIPTION_COL, row); String description = ImportHandlerUtils.readAsString(ChartOfAcountsConstants.DESCRIPTION_COL, row);
return GLAccountData.importInstance(accountName, parentId, glCode, manualEntriesAllowed, accountTypeEnum, usageEnum, description, return new GLAccountData().setName(accountName).setParentId(parentId).setGlCode(glCode)
tagIdCodeValueData, row.getRowNum()); .setManualEntriesAllowed(manualEntriesAllowed).setType(accountTypeEnum).setUsage(usageEnum).setDescription(description)
.setTagId(tagIdCodeValueData).setRowIndex(row.getRowNum());
} }
private Count importEntity(final Workbook workbook, final List<GLAccountData> glAccounts, final List<JournalEntryData> glTransactions, private Count importEntity(final Workbook workbook, final List<GLAccountData> glAccounts, final List<JournalEntryData> glTransactions,
@@ -1867,7 +1867,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private void validateDatatable(final String datatable) { private void validateDatatable(final String datatable) {
final String sql = "SELECT COUNT(application_table_name) FROM x_registered_table WHERE registered_table_name = ?"; final String sql = "SELECT COUNT(application_table_name) FROM x_registered_table WHERE registered_table_name = ?";
final Integer count = jdbcTemplate.queryForObject(sql, Integer.class, datatable); final int count = jdbcTemplate.queryForObject(sql, Integer.class, datatable);
if (count == 0) { if (count == 0) {
throw new DatatableNotFoundException(datatable); throw new DatatableNotFoundException(datatable);
} }
@@ -2278,7 +2278,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
builder.append(" JOIN m_entity_datatable_check edc ON edc.x_registered_table_name = xrt.registered_table_name"); builder.append(" JOIN m_entity_datatable_check edc ON edc.x_registered_table_name = xrt.registered_table_name");
builder.append(" WHERE edc.x_registered_table_name = '" + datatableName + "'"); builder.append(" WHERE edc.x_registered_table_name = '" + datatableName + "'");
final Long count = this.jdbcTemplate.queryForObject(builder.toString(), Long.class); final Long count = this.jdbcTemplate.queryForObject(builder.toString(), Long.class);
return count > 0 ? true : false; return count > 0;
} }
} }
@@ -34,8 +34,8 @@ public class AmazonS3ConfigCondition extends PropertiesCondition {
} }
private boolean isAwsCredentialValid() { private boolean isAwsCredentialValid() {
try { try (var defaultCredentialsProvider = DefaultCredentialsProvider.create()) {
DefaultCredentialsProvider.create().resolveCredentials(); defaultCredentialsProvider.resolveCredentials();
DefaultAwsRegionProviderChain.builder().build().getRegion(); DefaultAwsRegionProviderChain.builder().build().getRegion();
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@@ -133,7 +133,7 @@ public class TwoFactorConfigurationServiceImpl implements TwoFactorConfiguration
@Cacheable(value = "tfConfig", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()+'|smsProvider'") @Cacheable(value = "tfConfig", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()+'|smsProvider'")
public Integer getSMSProviderId() { public Integer getSMSProviderId() {
Integer value = getIntegerConfig(TwoFactorConfigurationConstants.SMS_PROVIDER_ID, null); Integer value = getIntegerConfig(TwoFactorConfigurationConstants.SMS_PROVIDER_ID, null);
if (value < 1) { if (value == null || value < 1) {
return null; return null;
} }
return value; return value;
@@ -265,10 +265,7 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
+ " ci.entity_type_enum = ?"; + " ci.entity_type_enum = ?";
try { try {
int calendarInstaneId = this.jdbcTemplate.queryForObject(query, Integer.class, entityId, calendarId, entityTypeId); int calendarInstaneId = this.jdbcTemplate.queryForObject(query, Integer.class, entityId, calendarId, entityTypeId);
if (calendarInstaneId > 0) { return calendarInstaneId > 0;
return true;
}
return false;
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
return false; return false;
} }
@@ -202,7 +202,7 @@ public class DefaultScheduledDateGenerator implements ScheduledDateGenerator {
while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), adjustedDateDetailsDTO.getChangedScheduleDate())) { while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), adjustedDateDetailsDTO.getChangedScheduleDate())) {
final RepaymentRescheduleType repaymentRescheduleType = WorkingDaysUtil final RepaymentRescheduleType repaymentRescheduleType = WorkingDaysUtil
.getRepaymentRescheduleType(holidayDetailDTO.getWorkingDays(), adjustedDateDetailsDTO.getChangedScheduleDate()); .getRepaymentRescheduleType(holidayDetailDTO.getWorkingDays());
if (repaymentRescheduleType.isMoveToNextRepaymentDay()) { if (repaymentRescheduleType.isMoveToNextRepaymentDay()) {
while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(),
@@ -18,6 +18,7 @@
*/ */
package org.apache.fineract.portfolio.loanaccount.service; package org.apache.fineract.portfolio.loanaccount.service;
import static java.lang.Boolean.TRUE;
import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType; import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -2153,7 +2154,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
@Override @Override
public boolean isGuaranteeRequired(final Long loanId) { public boolean isGuaranteeRequired(final Long loanId) {
final String sql = "select pl.hold_guarantee_funds from m_loan ml inner join m_product_loan pl on pl.id = ml.product_id where ml.id=?"; final String sql = "select pl.hold_guarantee_funds from m_loan ml inner join m_product_loan pl on pl.id = ml.product_id where ml.id=?";
return this.jdbcTemplate.queryForObject(sql, Boolean.class, loanId); return TRUE.equals(this.jdbcTemplate.queryForObject(sql, Boolean.class, loanId));
} }
private static final class LoanTransactionDerivedComponentMapper implements RowMapper<LoanTransactionData> { private static final class LoanTransactionDerivedComponentMapper implements RowMapper<LoanTransactionData> {
@@ -27,7 +27,6 @@ import org.apache.fineract.portfolio.self.pockets.domain.PocketAccountMapping;
import org.apache.fineract.portfolio.self.pockets.domain.PocketAccountMappingRepositoryWrapper; import org.apache.fineract.portfolio.self.pockets.domain.PocketAccountMappingRepositoryWrapper;
import org.apache.fineract.portfolio.self.pockets.domain.PocketRepositoryWrapper; import org.apache.fineract.portfolio.self.pockets.domain.PocketRepositoryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -77,11 +76,8 @@ public class PocketAccountMappingReadPlatformServiceImpl implements PocketAccoun
@Override @Override
public boolean validatePocketAndAccountMapping(Long pocketId, Long accountId, Integer accountType) { public boolean validatePocketAndAccountMapping(Long pocketId, Long accountId, Integer accountType) {
final String sql = "select count(id) from m_pocket_accounts_mapping mapping where pocket_id = ? and account_id = ? and account_type = ?"; final String sql = "select count(id) from m_pocket_accounts_mapping mapping where pocket_id = ? and account_id = ? and account_type = ?";
try { int count = this.jdbcTemplate.queryForObject(sql, Integer.class, pocketId, accountId, accountType);
return this.jdbcTemplate.queryForObject(sql, Boolean.class, pocketId, accountId, accountType); return count > 0;
} catch (EmptyResultDataAccessException e) {
return false;
}
} }
} }
@@ -41,11 +41,8 @@ public class SelfServiceRegistrationReadPlatformServiceImpl implements SelfServi
sql = sql + " and mobile_no = ?"; sql = sql + " and mobile_no = ?";
params = new Object[] { accountNumber, firstName, lastName, mobileNumber }; params = new Object[] { accountNumber, firstName, lastName, mobileNumber };
} }
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); int count = this.jdbcTemplate.queryForObject(sql, Integer.class, params);
if (count == 0) { return count != 0;
return false;
}
return true;
} }
} }
@@ -218,10 +218,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
public boolean isUsernameExist(String username) { public boolean isUsernameExist(String username) {
String sql = "select count(*) from m_appuser where username = ?"; String sql = "select count(*) from m_appuser where username = ?";
Object[] params = new Object[] { username }; Object[] params = new Object[] { username };
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); int count = this.jdbcTemplate.queryForObject(sql, Integer.class, params);
if (count == 0) { return count != 0;
return false;
}
return true;
} }
} }
@@ -158,6 +158,7 @@ fineract.report.export.s3.bucket=${FINERACT_REPORT_EXPORT_S3_BUCKET_NAME:}
fineract.report.export.s3.enabled=${FINERACT_REPORT_EXPORT_S3_ENABLED:false} fineract.report.export.s3.enabled=${FINERACT_REPORT_EXPORT_S3_ENABLED:false}
fineract.jpa.statementLoggingEnabled=${FINERACT_STATEMENT_LOGGING_ENABLED:false} fineract.jpa.statementLoggingEnabled=${FINERACT_STATEMENT_LOGGING_ENABLED:false}
fineract.database.defaultMasterPassword=${FINERACT_DEFAULT_MASTER_PASSWORD:fineract}
fineract.notification.user-notification-system.enabled=${FINERACT_USER_NOTIFICATION_SYSTEM_ENABLED:true} fineract.notification.user-notification-system.enabled=${FINERACT_USER_NOTIFICATION_SYSTEM_ENABLED:true}
fineract.logging.json.enabled=${FINERACT_LOGGING_JSON_ENABLED:false} fineract.logging.json.enabled=${FINERACT_LOGGING_JSON_ENABLED:false}
@@ -86,6 +86,7 @@ fineract.report.export.s3.bucket=${FINERACT_REPORT_EXPORT_S3_BUCKET_NAME:}
fineract.report.export.s3.enabled=${FINERACT_REPORT_EXPORT_S3_ENABLED:false} fineract.report.export.s3.enabled=${FINERACT_REPORT_EXPORT_S3_ENABLED:false}
fineract.jpa.statementLoggingEnabled=${FINERACT_STATEMENT_LOGGING_ENABLED:false} fineract.jpa.statementLoggingEnabled=${FINERACT_STATEMENT_LOGGING_ENABLED:false}
fineract.database.defaultMasterPassword=${FINERACT_DEFAULT_MASTER_PASSWORD:fineract}
fineract.job.loan-cob-enabled=${FINERACT_JOB_LOAN_COB_ENABLED:true} fineract.job.loan-cob-enabled=${FINERACT_JOB_LOAN_COB_ENABLED:true}
@@ -1,43 +0,0 @@
/**
* 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.integrationtests;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.junit.jupiter.api.BeforeEach;
public class CurrencyIntegrationTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private SavingsAccountHelper savingsAccountHelper;
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
}