diff --git a/custom/acme/loan/job/src/test/java/AcmeNoopJobTaskletTest.java b/custom/acme/loan/job/src/test/java/AcmeNoopJobTaskletTest.java index f8b6e502611..4b8f076ec7d 100644 --- a/custom/acme/loan/job/src/test/java/AcmeNoopJobTaskletTest.java +++ b/custom/acme/loan/job/src/test/java/AcmeNoopJobTaskletTest.java @@ -17,7 +17,8 @@ * specific language governing permissions and limitations * 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 org.junit.jupiter.api.BeforeEach; @@ -47,7 +48,7 @@ public void setUp() { @Test public void testJobExecution() throws Exception { resultStatus = underTest.execute(stepContribution, chunkContext); - assertEquals(resultStatus, RepeatStatus.FINISHED); + assertEquals(FINISHED, resultStatus); } } diff --git a/fineract-client/src/main/java/org/apache/fineract/client/util/CallFailedRuntimeException.java b/fineract-client/src/main/java/org/apache/fineract/client/util/CallFailedRuntimeException.java index 333daa715ed..eb77e570ac6 100644 --- a/fineract-client/src/main/java/org/apache/fineract/client/util/CallFailedRuntimeException.java +++ b/fineract-client/src/main/java/org/apache/fineract/client/util/CallFailedRuntimeException.java @@ -19,6 +19,7 @@ package org.apache.fineract.client.util; import java.io.IOException; +import lombok.extern.slf4j.Slf4j; import retrofit2.Call; import retrofit2.Response; @@ -27,6 +28,7 @@ * * @author Michael Vorburger.ch */ +@Slf4j public class CallFailedRuntimeException extends RuntimeException { private final Call call; @@ -46,17 +48,17 @@ public CallFailedRuntimeException(Call call, Response response) { private static String message(Call call, Response response) { StringBuilder sb = new StringBuilder("HTTP failed: " + call.request() + "; " + response); - if (response.message() != null && !response.message().isEmpty()) { - sb.append("; message: " + response.message()); + if (null != response.message() && !response.message().isEmpty()) { + sb.append("; message: ").append(response.message()); } String errorBody; try { - errorBody = response.errorBody().string(); + errorBody = response.errorBody() != null ? response.errorBody().string() : null; if (errorBody != null) { - sb.append("; errorBody: " + errorBody); + sb.append("; errorBody: ").append(errorBody); } } catch (IOException e) { - // Ignore. + log.error("Exception during creating the {} message:", CallFailedRuntimeException.class.getSimpleName(), e); } return sb.toString(); } diff --git a/fineract-client/src/main/java/org/apache/fineract/client/util/JSON.java b/fineract-client/src/main/java/org/apache/fineract/client/util/JSON.java index cfbc15cbf0b..e6caa7ff9b2 100644 --- a/fineract-client/src/main/java/org/apache/fineract/client/util/JSON.java +++ b/fineract-client/src/main/java/org/apache/fineract/client/util/JSON.java @@ -23,6 +23,7 @@ import com.google.gson.TypeAdapter; import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import io.gsonfire.GsonFireBuilder; import java.io.IOException; @@ -35,10 +36,12 @@ import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; +import java.util.Objects; import okhttp3.RequestBody; import okhttp3.ResponseBody; import org.apache.fineract.client.models.ExternalId; import org.apache.fineract.client.util.adapter.ExternalIdAdapter; +import org.jetbrains.annotations.NotNull; import retrofit2.Converter; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; @@ -212,25 +215,28 @@ public void write(JsonWriter out, Date date) throws IOException { @Override public Date read(JsonReader in) throws IOException { try { - switch (in.peek()) { - case NULL: - in.nextNull(); - 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); - } + if (Objects.requireNonNull(in.peek()) == JsonToken.NULL) { + in.nextNull(); + return null; } + String date = in.nextString(); + return parseDate(date); } catch (IllegalArgumentException 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. diff --git a/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java b/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java index efbe147aaeb..b369bec3a69 100644 --- a/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java +++ b/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java @@ -32,7 +32,7 @@ public class FineractClientTechnicalTest { @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() { FineractClient.Builder builder = FineractClient.builder().baseURL("http://test/").tenant("default").basicAuth("mifos", "password"); builder.getRetrofitBuilder().validateEagerly(true); // see FINERACT-1221 diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelper.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelper.java index 6c3ced505de..f9e0a5a779b 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelper.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelper.java @@ -20,11 +20,8 @@ import jakarta.ws.rs.core.MultivaluedMap; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper; @@ -148,16 +145,4 @@ public static boolean genericResultSet(final MultivaluedMap quer public static boolean genericResultSetPassed(final MultivaluedMap queryParams) { return queryParams.getFirst("genericResultSet") != null; } - - public static Map asMap(final MultivaluedMap queryParameters) { - - final Map map = new HashMap<>(queryParameters.size()); - - for (final String parameterName : queryParameters.keySet()) { - final List values = queryParameters.get(parameterName); - map.put(parameterName, values.get(0)); - } - - return map; - } } diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/config/FineractProperties.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/config/FineractProperties.java index eeede352f33..cf9f5baaa44 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/config/FineractProperties.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/config/FineractProperties.java @@ -61,6 +61,7 @@ public class FineractProperties { private FineractTemplateProperties template; private FineractJpaProperties jpa; + private FineractDatabaseProperties database; private FineractQueryProperties query; private FineractApiProperties api; private FineractSecurityProperties security; @@ -398,6 +399,13 @@ public static class FineractJpaProperties { private boolean statementLoggingEnabled; } + @Getter + @Setter + public static class FineractDatabaseProperties { + + private String defaultMasterPassword; + } + @Getter @Setter public static class FineractQueryProperties { diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java index 87ac64e784f..29bb485e18f 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java @@ -18,8 +18,6 @@ */ package org.apache.fineract.infrastructure.core.data; -import static java.util.stream.Collectors.toList; - import com.google.common.base.Splitter; import com.google.gson.JsonArray; import java.math.BigDecimal; @@ -176,13 +174,10 @@ public DataValidatorBuilder notSameAsParameter(final String linkedParameterName, return this; } - /*** FIXME: Vishwas, why does this method have a parameter? Seems wrong ***/ - /* - * This method is not meant for validation, if you have mandatory boolean param and if it has invalid value or value - * not passed then call this method, this method is always used with input as false - */ - public DataValidatorBuilder trueOrFalseRequired1(final boolean trueOfFalseFieldProvided) { - if (!trueOfFalseFieldProvided && !this.ignoreNullValue) { + public DataValidatorBuilder trueOrFalseRequired(final Object trueOfFalseField) { + + if (trueOfFalseField != null && !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) @@ -191,22 +186,6 @@ public DataValidatorBuilder trueOrFalseRequired1(final boolean trueOfFalseFieldP defaultEnglishMessage.toString(), this.parameter); 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; } @@ -320,7 +299,7 @@ public DataValidatorBuilder isOneOfTheseValues(final Object... values) { final List rawValuesList = Arrays.asList(values); if (this.value == null || !rawValuesList.contains(this.value)) { - final List valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); + final List valuesList = Arrays.stream(values).map(Object::toString).toList(); final String valuesListStr = String.join(", ", valuesList); final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".is.not.one.of.expected.enumerations"); @@ -349,7 +328,7 @@ public DataValidatorBuilder isOneOfTheseStringValues(final Object... values) { final List rawValuesList = Arrays.asList(values); if (this.value == null || !rawValuesList.contains(this.value.toString().toLowerCase())) { - final List valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); + final List valuesList = Arrays.stream(values).map(Object::toString).toList(); final String valuesListStr = String.join(", ", valuesList); final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".is.not.one.of.expected.enumerations"); @@ -397,7 +376,7 @@ public DataValidatorBuilder isNotOneOfTheseValues(final Object... values) { final List rawValuesList = Arrays.asList(values); if (rawValuesList.contains(this.value)) { - final List valuesList = Arrays.stream(values).map(Object::toString).collect(toList()); + final List valuesList = Arrays.stream(values).map(Object::toString).toList(); final String valuesListStr = String.join(", ", valuesList); final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".is.one.of.unwanted.enumerations"); @@ -879,17 +858,15 @@ public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) { } public DataValidatorBuilder compareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) { - if (min != null && max != null) { - if (max.compareTo(min) < 0) { - final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") - .append(this.parameter).append(".is.not.within.expected.range"); - final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min) - .append(" should less than max number ").append(max).append("."); - final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), - defaultEnglishMessage.toString(), this.parameter, min, max); - this.dataValidationErrors.add(error); - return this; - } + if (min != null && max != null && max.compareTo(min) < 0) { + final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") + .append(this.parameter).append(".is.not.within.expected.range"); + final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min) + .append(" should less than max number ").append(max).append("."); + final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), this.parameter, min, max); + this.dataValidationErrors.add(error); + return this; } return this; } diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/database/DatabasePasswordEncryptor.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/database/DatabasePasswordEncryptor.java index 7dec6c30b90..161e84b7f2e 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/database/DatabasePasswordEncryptor.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/database/DatabasePasswordEncryptor.java @@ -34,8 +34,6 @@ public class DatabasePasswordEncryptor implements PasswordEncryptor { public static final String DEFAULT_ENCRYPTION = "AES/CBC/PKCS5Padding"; - public static final String DEFAULT_MASTER_PASSWORD = "fineract"; - private final FineractProperties fineractProperties; @SuppressWarnings("checkstyle:regexpsinglelinejava") @@ -54,7 +52,8 @@ public static void main(String[] args) { @Override public String encrypt(String plainPassword) { 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()) .map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION); return EncryptionUtil.encryptToBase64(encryption, masterPassword, plainPassword); @@ -63,7 +62,8 @@ public String encrypt(String plainPassword) { @Override public String decrypt(String encryptedPassword) { 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()) .map(FineractProperties.FineractTenantProperties::getEncryption).orElse(DEFAULT_ENCRYPTION); return EncryptionUtil.decryptFromBase64(encryption, masterPassword, encryptedPassword); @@ -73,7 +73,7 @@ public String getMasterPasswordHash() { String masterPassword = Optional.ofNullable(fineractProperties) // .map(FineractProperties::getTenant) // .map(FineractProperties.FineractTenantProperties::getMasterPassword) // - .orElse(DEFAULT_MASTER_PASSWORD); + .orElse(fineractProperties.getDatabase().getDefaultMasterPassword()); return BCrypt.hashpw(masterPassword.getBytes(StandardCharsets.UTF_8), BCrypt.gensalt()); } @@ -81,7 +81,7 @@ public boolean isMasterPasswordHashValid(String hashed) { String masterPassword = Optional.ofNullable(fineractProperties) // .map(FineractProperties::getTenant) // .map(FineractProperties.FineractTenantProperties::getMasterPassword) // - .orElse(DEFAULT_MASTER_PASSWORD); + .orElse(fineractProperties.getDatabase().getDefaultMasterPassword()); return BCrypt.checkpw(masterPassword, hashed); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/organisation/workingdays/service/WorkingDaysUtil.java b/fineract-core/src/main/java/org/apache/fineract/organisation/workingdays/service/WorkingDaysUtil.java index 68735cacf88..cb0d6e17eb4 100644 --- a/fineract-core/src/main/java/org/apache/fineract/organisation/workingdays/service/WorkingDaysUtil.java +++ b/fineract-core/src/main/java/org/apache/fineract/organisation/workingdays/service/WorkingDaysUtil.java @@ -71,8 +71,7 @@ public static void updateWorkingDayIfRepaymentDateIsNonWorkingDay(final Adjusted adjustedDateDetailsDTO.setChangedScheduleDate(changedScheduleDate); } - public static RepaymentRescheduleType getRepaymentRescheduleType(final WorkingDays workingDays, final LocalDate date) { - RepaymentRescheduleType rescheduleType = RepaymentRescheduleType.fromInt(workingDays.getRepaymentReschedulingType()); - return rescheduleType; + public static RepaymentRescheduleType getRepaymentRescheduleType(final WorkingDays workingDays) { + return RepaymentRescheduleType.fromInt(workingDays.getRepaymentReschedulingType()); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java index aba4e210ebe..9a5211a4721 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java @@ -377,30 +377,16 @@ private CalendarData(final Long id, final Long calendarInstanceId, final Long en } public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { - if (this.startDate != null && compareDate != null) { - if (this.startDate.isBefore(compareDate) || this.startDate.equals(compareDate)) { - return true; - } - } - return false; + return this.startDate != null && compareDate != null + && (this.startDate.isBefore(compareDate) || this.startDate.equals(compareDate)); } public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { - if (this.endDate != null && compareDate != null) { - if (this.endDate.isAfter(compareDate) || this.endDate.isEqual(compareDate)) { - return true; - } - } - return false; + return this.endDate != null && compareDate != null && (this.endDate.isAfter(compareDate) || this.endDate.isEqual(compareDate)); } public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { - if (isStartDateBeforeOrEqual(compareDate)) { - if (this.endDate == null || isEndDateAfterOrEqual(compareDate)) { - return true; - } - } - return false; + return isStartDateBeforeOrEqual(compareDate) && (this.endDate == null || isEndDateAfterOrEqual(compareDate)); } public boolean isValidRecurringDate(final LocalDate compareDate, final Boolean isSkipMeetingOnFirstDay, final Integer numberOfDays) { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/Calendar.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/Calendar.java index fbdff740ad1..ed8419b63f7 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/Calendar.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/Calendar.java @@ -153,10 +153,7 @@ public static Calendar createRepeatingCalendar(final String title, final LocalDa public static Calendar fromJson(final JsonCommand command) { - // final Long entityId = command.getSupportedEntityId(); - // final Integer entityTypeId = - // CalendarEntityType.valueOf(command.getSupportedEntityType().toUpperCase()).getValue(); - LocalTime meetingtime = null; + LocalTime meetingtime; final String title = command.stringValueOfParameterNamed(CalendarSupportedParameters.TITLE.getValue()); final String description = command.stringValueOfParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue()); final String location = command.stringValueOfParameterNamed(CalendarSupportedParameters.LOCATION.getValue()); @@ -304,10 +301,6 @@ public Map update(final JsonCommand command, final Boolean areAc final String newMeetingType = CalendarType.fromInt(newValue).name(); 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(); @@ -401,11 +394,9 @@ public Map updateRepeatingCalendar(final LocalDate calendarStart final Integer interval, final Integer repeatsOnDay, final Integer repeatsOnNthDay) { final Map actualChanges = new LinkedHashMap<>(9); - if (calendarStartDate != null && this.startDate != null) { - if (!calendarStartDate.equals(this.getStartDateLocalDate())) { - actualChanges.put("startDate", calendarStartDate); - this.startDate = calendarStartDate; - } + if (calendarStartDate != null && this.startDate != null && !calendarStartDate.equals(this.getStartDateLocalDate())) { + actualChanges.put("startDate", calendarStartDate); + this.startDate = calendarStartDate; } final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay, repeatsOnNthDay); @@ -488,46 +479,21 @@ public boolean isStartDateBefore(final LocalDate compareDate) { } public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { - if (this.startDate != null && compareDate != null) { - if (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)) { - return true; - } - } - return false; + return this.startDate != null && compareDate != null + && (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)); } public boolean isStartDateAfter(final LocalDate compareDate) { - if (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; + return this.startDate != null && compareDate != null && getStartDateLocalDate().isAfter(compareDate); } public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { - if (this.endDate != null && compareDate != null) { - if (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)) { - return true; - } - } - return false; + return this.endDate != null && compareDate != null + && (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)); } public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { - if (isStartDateBeforeOrEqual(compareDate)) { - if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) { - return true; - } - } - return false; + return isStartDateBeforeOrEqual(compareDate) && (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)); } private static String constructRecurrence(final JsonCommand command, final Calendar calendar) { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarHistory.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarHistory.java index 9de62a95019..7c40d8f2526 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarHistory.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarHistory.java @@ -104,30 +104,17 @@ public LocalDate getEndDateLocalDate() { } public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { - if (this.endDate != null && compareDate != null) { - if (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)) { - return true; - } - } - return false; + return this.endDate != null && compareDate != null + && (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)); } public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { - if (this.startDate != null && compareDate != null) { - if (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)) { - return true; - } - } - return false; + return this.startDate != null && compareDate != null + && (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)); } public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { - if (isStartDateBeforeOrEqual(compareDate)) { - if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) { - return true; - } - } - return false; + return isStartDateBeforeOrEqual(compareDate) && (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)); } public void updateEndDate(LocalDate historyCalEndDate) { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java index b6bc3494876..486c2fe9af1 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java @@ -833,7 +833,7 @@ public static LocalDate getNextRepaymentMeetingDate(final String recurringRule, LocalDate nextRepaymentDate = null; if (applyWorkingDays) { if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDate) - && WorkingDaysUtil.getRepaymentRescheduleType(workingDays, newRepaymentDate).isMoveToNextRepaymentDay()) { + && WorkingDaysUtil.getRepaymentRescheduleType(workingDays).isMoveToNextRepaymentDay()) { newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1), loanRepaymentInterval, frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays, isCalledFirstTime, applyWorkingDays); } else { @@ -851,7 +851,7 @@ public static LocalDate getNextRepaymentMeetingDate(final String recurringRule, final LocalDate newRepaymentDateTemp = adjustRecurringDate(newRepaymentDate, numberOfDays); if (applyWorkingDays) { if (WorkingDaysUtil.isNonWorkingDay(workingDays, newRepaymentDateTemp) - && WorkingDaysUtil.getRepaymentRescheduleType(workingDays, newRepaymentDateTemp).isMoveToNextRepaymentDay()) { + && WorkingDaysUtil.getRepaymentRescheduleType(workingDays).isMoveToNextRepaymentDay()) { newRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, newRepaymentDate.plusDays(1), loanRepaymentInterval, frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays, isCalledFirstTime, applyWorkingDays); diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountType.java index 200d03506fa..f9b3178b61a 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountType.java @@ -95,7 +95,7 @@ public String toString() { public String resourceName() { - String resourceName = "INVALID"; + String resourceName; switch (this) { case FIXED_DEPOSIT: diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountData.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountData.java index f24513978a1..1fcc9764ce9 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountData.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountData.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.stream.Collectors; import lombok.Getter; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -229,14 +228,10 @@ private SavingsAccountData(Long clientId, Long productId, Long fieldOfficerId, L this.savingsAmountOnHold = null; } - public static final Comparator ClientNameComparator = new Comparator() { - - @Override - public int compare(SavingsAccountData savings1, SavingsAccountData savings2) { - String clientOfSavings1 = savings1.getClientName().toUpperCase(Locale.ENGLISH); - String clientOfSavings2 = savings2.getClientName().toUpperCase(Locale.ENGLISH); - return clientOfSavings1.compareTo(clientOfSavings2); - } + public static final Comparator ClientNameComparator = (savings1, savings2) -> { + String clientOfSavings1 = savings1.getClientName().toUpperCase(Locale.ENGLISH); + String clientOfSavings2 = savings2.getClientName().toUpperCase(Locale.ENGLISH); + return clientOfSavings1.compareTo(clientOfSavings2); }; public void setNewSavingsAccountTransactionData(final SavingsAccountTransactionData savingsAccountTransactionData) { @@ -395,7 +390,7 @@ public Long officeId() { } public List getSavingsAccountTransactionsWithPivotConfig() { - return this.transactions.stream().collect(Collectors.toList()); + return this.transactions.stream().toList(); } public Boolean isAccrualBasedAccountingEnabledOnSavingsProduct() { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java index aa2176244b9..a4be4cde39d 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java @@ -167,7 +167,7 @@ public void updateSummaryWithPivotConfig(final CurrencyData currency, final Savi this.totalDeposits = wrapper.calculateTotalDeposits(currency, savingsAccountTransactions); this.totalWithdrawals = wrapper.calculateTotalWithdrawals(currency, savingsAccountTransactions); final HashMap map = updateRunningBalanceAndPivotDate(true, savingsAccountTransactions, interestTotal, - overdraftInterestTotal, withHoldTaxTotal, currency); + overdraftInterestTotal, withHoldTaxTotal); interestTotal = map.get("interestTotal"); withHoldTaxTotal = map.get("withHoldTax"); overdraftInterestTotal = map.get("overdraftInterestTotal"); @@ -200,7 +200,7 @@ public void updateFromInterestPeriodSummaries(final MonetaryCurrency currency, f @SuppressWarnings("unchecked") private HashMap updateRunningBalanceAndPivotDate(final boolean backdatedTxnsAllowedTill, final List savingsAccountTransactions, Money interestTotal, Money overdraftInterestTotal, - Money withHoldTaxTotal, CurrencyData currency) { + Money withHoldTaxTotal) { boolean isUpdated = false; HashMap map = new HashMap<>(); for (int i = savingsAccountTransactions.size() - 1; i >= 0; i--) { @@ -257,7 +257,7 @@ public void updateSummary(final CurrencyData currency, final SavingsAccountTrans this.totalWithholdTax = wrapper.calculateTotalWithholdTaxWithdrawal(currency, transactions); // 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) .minus(this.totalWithdrawalFees).minus(this.totalAnnualFees).minus(this.totalFeeCharge).minus(this.totalPenaltyCharge) diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java index eb4ba984ba9..9d14a871f35 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsEnumerations.java @@ -661,16 +661,6 @@ public static EnumOptionData depositTermFrequencyType(final SavingsPeriodFrequen return optionData; } - public static List depositTermFrequencyType(final SavingsPeriodFrequencyType[] types) { - final List optionDatas = new ArrayList<>(); - for (final SavingsPeriodFrequencyType type : types) { - if (!type.isInvalid()) { - optionDatas.add(recurringDepositFrequencyType(type)); - } - } - return optionDatas; - } - public static EnumOptionData inMultiplesOfDepositTermFrequencyType(final int id) { return depositTermFrequencyType(SavingsPeriodFrequencyType.fromInt(id)); } @@ -702,16 +692,6 @@ public static EnumOptionData inMultiplesOfDepositTermFrequencyType(final Savings return optionData; } - public static List inMultiplesOfDepositTermFrequencyType(final SavingsPeriodFrequencyType[] types) { - final List optionDatas = new ArrayList<>(); - for (final SavingsPeriodFrequencyType type : types) { - if (!type.isInvalid()) { - optionDatas.add(recurringDepositFrequencyType(type)); - } - } - return optionDatas; - } - public static EnumOptionData depositType(final Integer id) { return depositType(DepositAccountType.fromInt(id)); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanInlineCOBConfig.java b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanInlineCOBConfig.java index 194a4cd793a..d2e570cfc3b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanInlineCOBConfig.java +++ b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanInlineCOBConfig.java @@ -22,7 +22,6 @@ import org.apache.fineract.cob.common.CustomJobParameterResolver; import org.apache.fineract.cob.common.ResetContextTasklet; 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.infrastructure.jobs.domain.CustomJobParameterRepository; import org.apache.fineract.infrastructure.jobs.service.JobName; @@ -60,8 +59,6 @@ public class LoanInlineCOBConfig { @Autowired private COBBusinessStepService cobBusinessStepService; @Autowired - private LoanAccountLockRepository accountLockRepository; - @Autowired private TransactionTemplate transactionTemplate; @Autowired private CustomJobParameterRepository customJobParameterRepository; diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/chartofaccounts/ChartOfAccountsImportHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/chartofaccounts/ChartOfAccountsImportHandler.java index 563145e67c1..2dd0234bf96 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/chartofaccounts/ChartOfAccountsImportHandler.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/chartofaccounts/ChartOfAccountsImportHandler.java @@ -134,8 +134,9 @@ private GLAccountData readGlAccounts(final Row row) { tagIdCodeValueData = new CodeValueData().setId(tagId); } String description = ImportHandlerUtils.readAsString(ChartOfAcountsConstants.DESCRIPTION_COL, row); - return GLAccountData.importInstance(accountName, parentId, glCode, manualEntriesAllowed, accountTypeEnum, usageEnum, description, - tagIdCodeValueData, row.getRowNum()); + return new GLAccountData().setName(accountName).setParentId(parentId).setGlCode(glCode) + .setManualEntriesAllowed(manualEntriesAllowed).setType(accountTypeEnum).setUsage(usageEnum).setDescription(description) + .setTagId(tagIdCodeValueData).setRowIndex(row.getRowNum()); } private Count importEntity(final Workbook workbook, final List glAccounts, final List glTransactions, diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java index ae5f887002e..25456173ce8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java @@ -1867,7 +1867,7 @@ private String queryForApplicationTableName(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 Integer count = jdbcTemplate.queryForObject(sql, Integer.class, datatable); + final int count = jdbcTemplate.queryForObject(sql, Integer.class, datatable); if (count == 0) { throw new DatatableNotFoundException(datatable); } @@ -2278,7 +2278,7 @@ public boolean isDatatableAttachedToEntityDatatableCheck(final String datatableN 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 + "'"); final Long count = this.jdbcTemplate.queryForObject(builder.toString(), Long.class); - return count > 0 ? true : false; + return count > 0; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/s3/AmazonS3ConfigCondition.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/s3/AmazonS3ConfigCondition.java index 932b1bc9452..5a607f94c42 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/s3/AmazonS3ConfigCondition.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/s3/AmazonS3ConfigCondition.java @@ -34,8 +34,8 @@ protected boolean matches(FineractProperties properties) { } private boolean isAwsCredentialValid() { - try { - DefaultCredentialsProvider.create().resolveCredentials(); + try (var defaultCredentialsProvider = DefaultCredentialsProvider.create()) { + defaultCredentialsProvider.resolveCredentials(); DefaultAwsRegionProviderChain.builder().build().getRegion(); return true; } catch (Exception e) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/TwoFactorConfigurationServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/TwoFactorConfigurationServiceImpl.java index b3247e3da38..fd450535965 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/TwoFactorConfigurationServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/TwoFactorConfigurationServiceImpl.java @@ -133,7 +133,7 @@ public boolean isSMSEnabled() { @Cacheable(value = "tfConfig", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier()+'|smsProvider'") public Integer getSMSProviderId() { Integer value = getIntegerConfig(TwoFactorConfigurationConstants.SMS_PROVIDER_ID, null); - if (value < 1) { + if (value == null || value < 1) { return null; } return value; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java index fc1804a533f..a68888c40b0 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java @@ -265,10 +265,7 @@ public Boolean isCalendarAssociatedWithEntity(final Long entityId, final Long ca + " ci.entity_type_enum = ?"; try { int calendarInstaneId = this.jdbcTemplate.queryForObject(query, Integer.class, entityId, calendarId, entityTypeId); - if (calendarInstaneId > 0) { - return true; - } - return false; + return calendarInstaneId > 0; } catch (final EmptyResultDataAccessException e) { return false; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java index b4abfea6d03..04cc076c3af 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java @@ -202,7 +202,7 @@ private void checkAndUpdateWorkingDayIfRepaymentDateIsNonWorkingDay(final Adjust while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), adjustedDateDetailsDTO.getChangedScheduleDate())) { final RepaymentRescheduleType repaymentRescheduleType = WorkingDaysUtil - .getRepaymentRescheduleType(holidayDetailDTO.getWorkingDays(), adjustedDateDetailsDTO.getChangedScheduleDate()); + .getRepaymentRescheduleType(holidayDetailDTO.getWorkingDays()); if (repaymentRescheduleType.isMoveToNextRepaymentDay()) { while (WorkingDaysUtil.isNonWorkingDay(holidayDetailDTO.getWorkingDays(), diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index cd2e61499e2..a5e06b8984c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -18,6 +18,7 @@ */ package org.apache.fineract.portfolio.loanaccount.service; +import static java.lang.Boolean.TRUE; import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType; import java.math.BigDecimal; @@ -2153,7 +2154,7 @@ public Collection retrieveWaiverLoanTransactions(final Long @Override 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=?"; - 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 { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/pockets/service/PocketAccountMappingReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/pockets/service/PocketAccountMappingReadPlatformServiceImpl.java index 1f5f6d400f2..1c534767adc 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/pockets/service/PocketAccountMappingReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/pockets/service/PocketAccountMappingReadPlatformServiceImpl.java @@ -27,7 +27,6 @@ import org.apache.fineract.portfolio.self.pockets.domain.PocketAccountMappingRepositoryWrapper; import org.apache.fineract.portfolio.self.pockets.domain.PocketRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @@ -77,11 +76,8 @@ public PocketAccountMappingData retrieveAll() { @Override 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 = ?"; - try { - return this.jdbcTemplate.queryForObject(sql, Boolean.class, pocketId, accountId, accountType); - } catch (EmptyResultDataAccessException e) { - return false; - } + int count = this.jdbcTemplate.queryForObject(sql, Integer.class, pocketId, accountId, accountType); + return count > 0; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/registration/service/SelfServiceRegistrationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/registration/service/SelfServiceRegistrationReadPlatformServiceImpl.java index 30655c2a2b0..d26f8f6c25f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/registration/service/SelfServiceRegistrationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/registration/service/SelfServiceRegistrationReadPlatformServiceImpl.java @@ -41,11 +41,8 @@ public boolean isClientExist(String accountNumber, String firstName, String last sql = sql + " and mobile_no = ?"; params = new Object[] { accountNumber, firstName, lastName, mobileNumber }; } - Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); - if (count == 0) { - return false; - } - return true; + int count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); + return count != 0; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/useradministration/service/AppUserReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/useradministration/service/AppUserReadPlatformServiceImpl.java index ce0c87bec08..12d2949d0b0 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/useradministration/service/AppUserReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/useradministration/service/AppUserReadPlatformServiceImpl.java @@ -218,10 +218,7 @@ public String schema() { public boolean isUsernameExist(String username) { String sql = "select count(*) from m_appuser where username = ?"; Object[] params = new Object[] { username }; - Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); - if (count == 0) { - return false; - } - return true; + int count = this.jdbcTemplate.queryForObject(sql, Integer.class, params); + return count != 0; } } diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index 51325fa3b84..e4021daac11 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -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.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.logging.json.enabled=${FINERACT_LOGGING_JSON_ENABLED:false} diff --git a/fineract-provider/src/test/resources/application-test.properties b/fineract-provider/src/test/resources/application-test.properties index 28e79e2879a..5ce4972515a 100644 --- a/fineract-provider/src/test/resources/application-test.properties +++ b/fineract-provider/src/test/resources/application-test.properties @@ -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.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} diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrencyIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrencyIntegrationTest.java deleted file mode 100644 index b07c50b5790..00000000000 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrencyIntegrationTest.java +++ /dev/null @@ -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(); - } -}