You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ad...@apache.org on 2025/11/26 09:47:36 UTC
(fineract) 01/02: FINERACT-2380: move retrofit client based test to feign
This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
commit 5d2a9c5390d819b8a40a39ce4b357a3cc112c102
Author: Attila Budai <bu...@gmail.com>
AuthorDate: Tue Nov 18 14:30:54 2025 +0100
FINERACT-2380: move retrofit client based test to feign
---
.../fineract/client/feign/FineractFeignClient.java | 10 +
.../client/feign/FineractFeignClientConfig.java | 4 +-
.../services/ExternalAssetOwnersApiExtension.java | 40 +
.../LoanDisbursementDetailsApiExtension.java | 17 +-
.../client/feign/support/ApiResponseDecoder.java | 81 +
.../feign/util/CallFailedRuntimeException.java | 39 +-
.../fineract/client/feign/util/FeignCalls.java | 39 +-
.../src/main/resources/templates/java/api.mustache | 347 +-
fineract-e2e-tests-core/build.gradle | 2 +
.../apache/fineract/test/api/ApiConfiguration.java | 277 --
.../test/api/FineractClientConfiguration.java | 15 +-
.../test/data/accounttype/AccountTypeResolver.java | 34 +-
.../test/data/codevalue/CodeValueResolver.java | 30 +-
.../data/datatable/DatatableNameGenerator.java | 3 +-
.../apache/fineract/test/data/job/JobResolver.java | 24 +-
.../test/data/loanproduct/LoanProductResolver.java | 34 +-
.../test/data/paymenttype/PaymentTypeResolver.java | 29 +-
.../fineract/test/helper/BusinessDateHelper.java | 35 +-
.../apache/fineract/test/helper/CodeHelper.java | 32 +-
.../apache/fineract/test/helper/ErrorHelper.java | 53 -
.../fineract/test/helper/ErrorMessageHelper.java | 144 +-
.../apache/fineract/test/helper/ErrorResponse.java | 71 +-
.../test/helper/GlobalConfigurationHelper.java | 54 +-
.../fineract/test/helper/WorkFlowJobHelper.java | 27 +-
.../test/initializer/base/FineractInitializer.java | 13 +
.../global/ChargeGlobalInitializerStep.java | 135 +-
.../global/CobBusinessStepInitializerStep.java | 2 +-
.../global/CodeGlobalInitializerStep.java | 42 +-
.../global/CurrencyGlobalInitializerStep.java | 11 +-
.../global/DatatablesGlobalInitializerStep.java | 27 +-
.../global/DelinquencyGlobalInitializerStep.java | 79 +-
...ancialActivityMappingGlobalInitializerStep.java | 25 +-
.../global/FundGlobalInitializerStep.java | 32 +-
.../global/GLGlobalInitializerStep.java | 128 +-
.../global/LoanProductGlobalInitializerStep.java | 721 ++---
.../global/PaymentTypeGlobalInitializerStep.java | 57 +-
.../global/SavingsProductGlobalInitializer.java | 6 +-
.../global/SchedulerGlobalInitializerStep.java | 9 +-
...GlobalConfigurationScenarioInitializerStep.java | 8 +-
.../suite/ExternalEventSuiteInitializerStep.java | 62 +-
.../initializer/suite/JobSuiteInitializerStep.java | 99 +-
.../test/messaging/event/EventCheckHelper.java | 210 +-
.../test/messaging/store/MessageConsumer.java | 2 +-
.../apache/fineract/test/service/JobService.java | 27 +-
.../AssetExternalizationStepDef.java | 399 ++-
.../test/stepdef/common/BatchApiStepDef.java | 422 +--
.../test/stepdef/common/BusinessDateStepDef.java | 81 +-
.../test/stepdef/common/ClientStepDef.java | 52 +-
.../fineract/test/stepdef/common/EventStepDef.java | 9 +-
.../stepdef/common/GlobalConfigurationStepDef.java | 99 +-
.../test/stepdef/common/JournalEntriesStepDef.java | 322 +-
.../fineract/test/stepdef/common/UserStepDef.java | 37 +-
.../test/stepdef/datatable/DatatablesStepDef.java | 66 +-
.../fineract/test/stepdef/hook/MessagingHook.java | 36 +-
.../fineract/test/stepdef/loan/ChargeStepDef.java | 22 +-
.../test/stepdef/loan/InlineCOBStepDef.java | 32 +-
.../fineract/test/stepdef/loan/LoanCOBStepDef.java | 54 +-
.../stepdef/loan/LoanCapitalizedIncomeStepDef.java | 113 +-
.../stepdef/loan/LoanChargeAdjustmentStepDef.java | 112 +-
.../test/stepdef/loan/LoanChargeBackStepDef.java | 62 +-
.../test/stepdef/loan/LoanChargeStepDef.java | 231 +-
.../test/stepdef/loan/LoanDelinquencyStepDef.java | 346 +-
.../stepdef/loan/LoanInterestPauseStepDef.java | 103 +-
.../stepdef/loan/LoanOverrideFieldsStepDef.java | 33 +-
.../test/stepdef/loan/LoanReAgingStepDef.java | 217 +-
.../stepdef/loan/LoanReAmortizationStepDef.java | 40 +-
.../test/stepdef/loan/LoanRepaymentStepDef.java | 395 ++-
.../test/stepdef/loan/LoanReprocessStepDef.java | 13 +-
.../test/stepdef/loan/LoanRescheduleStepDef.java | 52 +-
.../fineract/test/stepdef/loan/LoanStepDef.java | 3374 +++++++++-----------
.../test/stepdef/saving/SavingsAccountStepDef.java | 121 +-
.../apache/fineract/test/support/EnumResolver.java | 3 +-
.../fineract/test/support/TestContextKey.java | 4 +
fineract-e2e-tests-runner/build.gradle | 1 +
.../test/resources/features/LoanReschedule.feature | 2 +-
.../feign/helpers/FeignBusinessDateHelper.java | 2 +-
.../client/feign/helpers/FeignLoanHelper.java | 2 +-
77 files changed, 4931 insertions(+), 5062 deletions(-)
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClient.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClient.java
index 8c049039f8..3a416e9119 100644
--- a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClient.java
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClient.java
@@ -61,6 +61,7 @@ import org.apache.fineract.client.feign.services.EntityDataTableApi;
import org.apache.fineract.client.feign.services.EntityFieldConfigurationApi;
import org.apache.fineract.client.feign.services.ExternalAssetOwnerLoanProductAttributesApi;
import org.apache.fineract.client.feign.services.ExternalAssetOwnersApi;
+import org.apache.fineract.client.feign.services.ExternalAssetOwnersApiExtension;
import org.apache.fineract.client.feign.services.ExternalEventConfigurationApi;
import org.apache.fineract.client.feign.services.ExternalServicesApi;
import org.apache.fineract.client.feign.services.FetchAuthenticatedUserDetailsApi;
@@ -95,6 +96,7 @@ import org.apache.fineract.client.feign.services.LoanCobCatchUpApi;
import org.apache.fineract.client.feign.services.LoanCollateralApi;
import org.apache.fineract.client.feign.services.LoanCollateralManagementApi;
import org.apache.fineract.client.feign.services.LoanDisbursementDetailsApi;
+import org.apache.fineract.client.feign.services.LoanDisbursementDetailsApiExtension;
import org.apache.fineract.client.feign.services.LoanInterestPauseApi;
import org.apache.fineract.client.feign.services.LoanProductsApi;
import org.apache.fineract.client.feign.services.LoanReschedulingApi;
@@ -392,6 +394,10 @@ public final class FineractFeignClient {
return create(ExternalAssetOwnersApi.class);
}
+ public ExternalAssetOwnersApiExtension externalAssetOwnersExtension() {
+ return create(ExternalAssetOwnersApiExtension.class);
+ }
+
public ExternalEventConfigurationApi externalEventConfiguration() {
return create(ExternalEventConfigurationApi.class);
}
@@ -528,6 +534,10 @@ public final class FineractFeignClient {
return create(LoanDisbursementDetailsApi.class);
}
+ public LoanDisbursementDetailsApiExtension loanDisbursementDetailsExtension() {
+ return create(LoanDisbursementDetailsApiExtension.class);
+ }
+
public LoanInterestPauseApi loanInterestPause() {
return create(LoanInterestPauseApi.class);
}
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClientConfig.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClientConfig.java
index 04fe8e1ef8..098dadfbb5 100644
--- a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClientConfig.java
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClientConfig.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
+import org.apache.fineract.client.feign.support.ApiResponseDecoder;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
@@ -95,7 +96,8 @@ public final class FineractFeignClientConfig {
Encoder multipartEncoder = new FineractMultipartEncoder(jacksonEncoder);
return Feign.builder().client(getOrCreateHttpClient()).encoder(multipartEncoder)
- .decoder(new JacksonDecoder(ObjectMapperFactory.getShared())).errorDecoder(new FineractErrorDecoder())
+ .decoder(new ApiResponseDecoder(new JacksonDecoder(ObjectMapperFactory.getShared())))
+ .errorDecoder(new FineractErrorDecoder())
.options(new Request.Options(connectTimeout, TimeUnit.MILLISECONDS, readTimeout, TimeUnit.MILLISECONDS, true))
.retryer(Retryer.NEVER_RETRY).requestInterceptor(new BasicAuthRequestInterceptor(username, password))
.requestInterceptor(new TenantIdRequestInterceptor(tenantId)).logger(new Slf4jLogger(apiType))
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/ExternalAssetOwnersApiExtension.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/ExternalAssetOwnersApiExtension.java
new file mode 100644
index 0000000000..90bcf7fd0e
--- /dev/null
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/ExternalAssetOwnersApiExtension.java
@@ -0,0 +1,40 @@
+/**
+ * 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.client.feign.services;
+
+import feign.Headers;
+import feign.Param;
+import feign.QueryMap;
+import feign.RequestLine;
+import java.util.Map;
+import org.apache.fineract.client.models.ExternalAssetOwnerRequest;
+import org.apache.fineract.client.models.PostInitiateTransferResponse;
+
+public interface ExternalAssetOwnersApiExtension {
+
+ @RequestLine("POST /v1/external-asset-owners/transfers/{id}")
+ @Headers("Content-Type: application/json")
+ PostInitiateTransferResponse transferRequestWithIdWithBody(@Param("id") Long id, ExternalAssetOwnerRequest body,
+ @QueryMap Map<String, Object> queryParams);
+
+ @RequestLine("POST /v1/external-asset-owners/transfers/external-id/{externalId}")
+ @Headers("Content-Type: application/json")
+ PostInitiateTransferResponse transferRequestWithId1WithBody(@Param("externalId") String externalId, ExternalAssetOwnerRequest body,
+ @QueryMap Map<String, Object> queryParams);
+}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanProductsCustomApi.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/LoanDisbursementDetailsApiExtension.java
similarity index 60%
rename from fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanProductsCustomApi.java
rename to fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/LoanDisbursementDetailsApiExtension.java
index 6fd53a274a..dece067344 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanProductsCustomApi.java
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/LoanDisbursementDetailsApiExtension.java
@@ -16,15 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.fineract.test.stepdef.loan;
+package org.apache.fineract.client.feign.services;
-import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
-import retrofit2.Call;
-import retrofit2.http.GET;
+import feign.Param;
+import feign.RequestLine;
+import org.apache.fineract.client.models.PostAddAndDeleteDisbursementDetailRequest;
-public interface LoanProductsCustomApi {
+public interface LoanDisbursementDetailsApiExtension {
+
+ @RequestLine("PUT /v1/loans/{loanId}/disbursements/editDisbursements")
+ PostAddAndDeleteDisbursementDetailRequest addAndDeleteDisbursementDetail(@Param("loanId") Long loanId,
+ PostAddAndDeleteDisbursementDetailRequest postAddAndDeleteDisbursementDetailRequest);
- @GET("v1/loanproducts/{productId}")
- Call<GetLoanProductsProductIdResponse> retrieveLoanProductDetails(@retrofit2.http.Path("productId") Long productId,
- @retrofit2.http.Query("template") String isTemplate);
}
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/support/ApiResponseDecoder.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/support/ApiResponseDecoder.java
new file mode 100644
index 0000000000..c0590678e9
--- /dev/null
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/support/ApiResponseDecoder.java
@@ -0,0 +1,81 @@
+/**
+ * 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.client.feign.support;
+
+import feign.Response;
+import feign.codec.Decoder;
+import java.io.IOException;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import org.apache.fineract.client.models.ApiResponse;
+
+/**
+ * Custom Feign decoder that handles ApiResponse<T> return types for *WithHttpInfo methods.
+ *
+ * When a Feign client method returns ApiResponse<T>, the standard JacksonDecoder cannot handle it because:
+ * <ul>
+ * <li>The server returns just T (the body), not ApiResponse<T></li>
+ * <li>ApiResponse wraps the body with HTTP status code and headers</li>
+ * </ul>
+ *
+ * This decoder:
+ * <ol>
+ * <li>Detects if the return type is ApiResponse<T></li>
+ * <li>Extracts the inner type T and delegates body decoding to the underlying decoder</li>
+ * <li>Wraps the decoded body with status code and headers into ApiResponse<T></li>
+ * </ol>
+ */
+public final class ApiResponseDecoder implements Decoder {
+
+ private final Decoder delegate;
+
+ public ApiResponseDecoder(Decoder delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Object decode(Response response, Type type) throws IOException {
+ if (isApiResponseType(type)) {
+ Type innerType = getApiResponseInnerType(type);
+ Object body = delegate.decode(response, innerType);
+ return new ApiResponse<>(response.status(), response.headers(), body);
+ }
+ return delegate.decode(response, type);
+ }
+
+ private boolean isApiResponseType(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType paramType = (ParameterizedType) type;
+ Type rawType = paramType.getRawType();
+ return rawType == ApiResponse.class;
+ }
+ return type == ApiResponse.class;
+ }
+
+ private Type getApiResponseInnerType(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType paramType = (ParameterizedType) type;
+ Type[] typeArgs = paramType.getActualTypeArguments();
+ if (typeArgs.length > 0) {
+ return typeArgs[0];
+ }
+ }
+ return Object.class;
+ }
+}
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/CallFailedRuntimeException.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/CallFailedRuntimeException.java
index c126899bb3..9e8c9ce1ce 100644
--- a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/CallFailedRuntimeException.java
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/CallFailedRuntimeException.java
@@ -18,13 +18,9 @@
*/
package org.apache.fineract.client.feign.util;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import feign.FeignException;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FeignException;
/**
* Exception thrown by {@link FeignCalls} utility when Feign calls fail.
@@ -49,7 +45,7 @@ public class CallFailedRuntimeException extends RuntimeException {
sb.append(", request=").append(e.request().url());
}
- String contentString = e.contentUTF8();
+ String contentString = e.responseBodyAsString();
if (contentString != null && !contentString.isEmpty()) {
sb.append(", errorBody=").append(contentString);
}
@@ -58,34 +54,9 @@ public class CallFailedRuntimeException extends RuntimeException {
}
private static String extractDeveloperMessage(FeignException e) {
- try {
- byte[] content = e.content();
- if (content == null || content.length == 0) {
- return e.getMessage();
- }
-
- String contentString = new String(content, StandardCharsets.UTF_8);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode root = mapper.readTree(contentString);
-
- if (root.has("developerMessage")) {
- return root.get("developerMessage").asText();
- }
-
- if (root.has("errors")) {
- JsonNode errors = root.get("errors");
- if (errors.isArray() && errors.size() > 0) {
- JsonNode firstError = errors.get(0);
- if (firstError.has("developerMessage")) {
- return firstError.get("developerMessage").asText();
- }
- }
- }
-
- return contentString;
- } catch (IOException ex) {
- log.warn("Failed to extract developer message from error response", ex);
- return e.getMessage();
+ if (e.getDeveloperMessage() != null) {
+ return e.getDeveloperMessage();
}
+ return e.getMessage();
}
}
diff --git a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/FeignCalls.java b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/FeignCalls.java
index 950c459c46..5d40d0dd39 100644
--- a/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/FeignCalls.java
+++ b/fineract-client-feign/src/main/java/org/apache/fineract/client/feign/util/FeignCalls.java
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.client.feign.util;
-import feign.FeignException;
import java.util.function.Supplier;
+import org.apache.fineract.client.feign.FeignException;
/**
* Extension methods for Feign calls. This class is recommended to be statically imported.
@@ -77,4 +77,41 @@ public final class FeignCalls {
public static <T> T execute(Supplier<T> feignCall) throws FeignException {
return feignCall.get();
}
+
+ /**
+ * Execute a Feign call expecting failure (for negative tests). Returns the exception with error details.
+ *
+ * @param feignCall
+ * the Feign call to execute
+ * @return CallFailedRuntimeException containing status code and error message
+ * @throws AssertionError
+ * if the call succeeds when failure was expected
+ */
+ public static CallFailedRuntimeException fail(Supplier<?> feignCall) {
+ try {
+ Object result = feignCall.get();
+ throw new AssertionError("Expected call to fail, but it succeeded with result: " + result);
+ } catch (FeignException e) {
+ return new CallFailedRuntimeException(e);
+ }
+ }
+
+ /**
+ * Execute a Feign call expecting failure with void return (for negative tests). Returns the exception with error
+ * details.
+ *
+ * @param feignCall
+ * the Feign call to execute
+ * @return CallFailedRuntimeException containing status code and error message
+ * @throws AssertionError
+ * if the call succeeds when failure was expected
+ */
+ public static CallFailedRuntimeException failVoid(Runnable feignCall) {
+ try {
+ feignCall.run();
+ throw new AssertionError("Expected call to fail, but it succeeded");
+ } catch (FeignException e) {
+ return new CallFailedRuntimeException(e);
+ }
+ }
}
diff --git a/fineract-client-feign/src/main/resources/templates/java/api.mustache b/fineract-client-feign/src/main/resources/templates/java/api.mustache
index 44edc0a3b7..47f42a5244 100644
--- a/fineract-client-feign/src/main/resources/templates/java/api.mustache
+++ b/fineract-client-feign/src/main/resources/templates/java/api.mustache
@@ -1,47 +1,326 @@
package {{package}};
-import feign.*;
-import feign.Param;
-import feign.RequestLine;
+{{#legacyDates}}
+import {{invokerPackage}}.ParamExpander;
+{{/legacyDates}}
+import {{modelPackage}}.ApiResponse;
{{#imports}}import {{import}};
{{/imports}}
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+{{#useBeanValidation}}
+import {{javaxPackage}}.validation.constraints.*;
+import {{javaxPackage}}.validation.Valid;
+
+{{/useBeanValidation}}
+import feign.*;
+{{>generatedAnnotation}}
public interface {{classname}} {
-{{#operations}}
- {{#operation}}
- /**
- * {{summary}}
- * {{notes}}
- {{#allParams}}
- * @param {{paramName}} {{description}}
- {{/allParams}}
- * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
- */
- @RequestLine("{{httpMethod}} {{path}}")
- {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}(
- {{#pathParams}}
- @Param("{{baseName}}") {{{dataType}}} {{paramName}}{{^-last}},{{/-last}}
- {{/pathParams}}
- {{#bodyParam}}
- {{#hasPathParams}},{{/hasPathParams}}{{{dataType}}} {{paramName}}
- {{/bodyParam}}
- {{#hasQueryParams}}
- {{#hasPathParams}}{{^bodyParam}},{{/bodyParam}}{{/hasPathParams}}{{#bodyParam}},{{/bodyParam}}
- @QueryMap Map<String, Object> queryParams
- {{/hasQueryParams}}
- {{#hasHeaderParams}}
- {{#hasPathParams}}{{^bodyParam}}{{^hasQueryParams}},{{/hasQueryParams}}{{/bodyParam}}{{/hasPathParams}}
- {{#bodyParam}}{{^hasQueryParams}},{{/hasQueryParams}}{{/bodyParam}}
- {{#hasQueryParams}},{{/hasQueryParams}}
- @HeaderMap Map<String, Object> headerParams
- {{/hasHeaderParams}}
- );
-
- {{/operation}}
+{{#operations}}{{#operation}}
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#allParams}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+{{/allParams}}
+{{#returnType}}
+ * @return {{.}}
+{{/returnType}}
+{{#externalDocs}}
+ * {{description}}
+ * @see <a href="{{url}}">{{summary}} Documentation</a>
+{{/externalDocs}}
+{{#isDeprecated}}
+ * @deprecated
+{{/isDeprecated}}
+ */
+{{#isDeprecated}}
+ @Deprecated
+{{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
+ @Headers({
+{{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+{{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/allParams}}@HeaderMap Map<String, String> headers);
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Convenience method with empty headers.
+{{#allParams}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+{{/allParams}}
+{{#returnType}}
+ * @return {{.}}
+{{/returnType}}
+{{#isDeprecated}}
+ * @deprecated
+{{/isDeprecated}}
+ */
+{{#isDeprecated}}
+ @Deprecated
+{{/isDeprecated}}
+ default {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}}({{#allParams}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
+ {{#returnType}}return {{/returnType}}{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}Map.of());
+ }
+
+ /**
+ * {{summary}}
+ * Similar to <code>{{operationId}}</code> but it also returns the http response headers .
+ * {{notes}}
+{{#allParams}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+{{/allParams}}
+{{#returnType}}
+ * @return A ApiResponse that wraps the response boyd and the http headers.
+{{/returnType}}
+{{#externalDocs}}
+ * {{description}}
+ * @see <a href="{{url}}">{{summary}} Documentation</a>
+{{/externalDocs}}
+{{#isDeprecated}}
+ * @deprecated
+{{/isDeprecated}}
+ */
+{{#isDeprecated}}
+ @Deprecated
+{{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
+ @Headers({
+{{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+{{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/allParams}}@HeaderMap Map<String, String> headers);
+
+
+ {{#hasQueryParams}}
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Note, this is equivalent to the other <code>{{operationId}}</code> method,
+ * but with the query parameters collected into a single Map parameter. This
+ * is convenient for services with optional query parameters, especially when
+ * used with the {@link {{operationIdCamelCase}}QueryParams} class that allows for
+ * building up this map in a fluent style.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Map of query parameters as name-value pairs
+ * <p>The following elements may be specified in the query map:</p>
+ * <ul>
+ {{#queryParams}}
+ * <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}</li>
+ {{/queryParams}}
+ * </ul>
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ {{#externalDocs}}
+ * {{description}}
+ * @see <a href="{{url}}">{{summary}} Documentation</a>
+ {{/externalDocs}}
+ {{#isDeprecated}}
+ * @deprecated
+ {{/isDeprecated}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
+ @Headers({
+{{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+{{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) {{operationIdCamelCas [...]
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Convenience method that uses typed QueryParams and empty headers.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Query parameters as typed object
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ default {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) {{operationIdC [...]
+ {{#returnType}}return {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{paramName}}, {{/isQueryParam}}{{/allParams}}queryParams, Map.of());
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Convenience method that accepts generic query parameters map.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Query parameters as generic map
+ * @param headers Custom headers to include in the request
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
+ @Headers({
+{{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+{{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<String, Object> q [...]
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Convenience method that accepts generic query parameters map with empty headers.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Query parameters as generic map
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ default {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<String, Ob [...]
+ {{#returnType}}return {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{paramName}}, {{/isQueryParam}}{{/allParams}}queryParams, Map.of());
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Note, this is equivalent to the other <code>{{operationId}}</code> that receives the query parameters as a map,
+ * but this one also exposes the Http response headers
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Map of query parameters as name-value pairs
+ * <p>The following elements may be specified in the query map:</p>
+ * <ul>
+ {{#queryParams}}
+ * <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}</li>
+ {{/queryParams}}
+ * </ul>
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ {{#externalDocs}}
+ * {{description}}
+ * @see <a href="{{url}}">{{summary}} Documentation</a>
+ {{/externalDocs}}
+ {{#isDeprecated}}
+ * @deprecated
+ {{/isDeprecated}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
+ @Headers({
+ {{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+ {{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=tr [...]
+
+
+ /**
+ * A convenience class for generating query parameters for the
+ * <code>{{operationId}}</code> method in a fluent style.
+ */
+ public static class {{operationIdCamelCase}}QueryParams extends HashMap<String, Object> {
+ {{#queryParams}}
+ public {{operationIdCamelCase}}QueryParams {{paramName}}(final {{{dataType}}} value) {
+ put("{{baseName}}", value);
+ return this;
+ }
+ {{/queryParams}}
+ }
+ {{/hasQueryParams}}
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Universal method that accepts generic query parameters map with headers.
+ * Useful for passing undocumented or optional query parameters.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Query parameters as generic map (e.g., template=true, associations=all)
+ * @param headers Custom headers to include in the request
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ @RequestLine("{{httpMethod}} {{{path}}}")
+ @Headers({
+{{#vendorExtensions.x-content-type}} "Content-Type: {{{vendorExtensions.x-content-type}}}",
+{{/vendorExtensions.x-content-type}} "Accept: {{#vendorExtensions.x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-accepts}}",{{#headerParams}}
+ "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}},
+ {{/-last}}{{/headerParams}}
+ })
+ {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}Universal({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<String, [...]
+
+ /**
+ * {{summary}}
+ * {{notes}}
+ * Universal method that accepts generic query parameters map with empty headers.
+ {{#allParams}}
+ {{^isQueryParam}}
+ * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}
+ {{/isQueryParam}}
+ {{/allParams}}
+ * @param queryParams Query parameters as generic map
+ {{#returnType}}
+ * @return {{.}}
+ {{/returnType}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ default {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}}Universal({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^isFormParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isFormParam}}{{#isFormParam}}@Param("{{baseName}}") {{/isFormParam}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<S [...]
+ {{#returnType}}return {{/returnType}}{{nickname}}Universal({{#allParams}}{{^isQueryParam}}{{paramName}}, {{/isQueryParam}}{{/allParams}}queryParams, Map.of());
+ }
+
+ {{/operation}}
{{/operations}}
}
diff --git a/fineract-e2e-tests-core/build.gradle b/fineract-e2e-tests-core/build.gradle
index fab9ef014e..d04d71ae12 100644
--- a/fineract-e2e-tests-core/build.gradle
+++ b/fineract-e2e-tests-core/build.gradle
@@ -59,6 +59,7 @@ tasks.named('compileTestJava') {
dependencies {
testImplementation(project(':fineract-avro-schemas'))
testImplementation(project(':fineract-client'))
+ testImplementation(project(':fineract-client-feign'))
testImplementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-test'
@@ -67,6 +68,7 @@ dependencies {
testImplementation 'com.github.spotbugs:spotbugs-annotations'
testImplementation 'com.squareup.retrofit2:retrofit:2.11.0'
+ testImplementation 'io.github.openfeign:feign-core:13.6'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
testImplementation 'org.apache.commons:commons-lang3:3.18.0'
testImplementation ('com.googlecode.json-simple:json-simple:1.1.1') {
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/ApiConfiguration.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/ApiConfiguration.java
deleted file mode 100644
index 64ff69666d..0000000000
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/ApiConfiguration.java
+++ /dev/null
@@ -1,277 +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.test.api;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.fineract.client.services.BatchApiApi;
-import org.apache.fineract.client.services.BusinessDateManagementApi;
-import org.apache.fineract.client.services.BusinessStepConfigurationApi;
-import org.apache.fineract.client.services.ChargesApi;
-import org.apache.fineract.client.services.ClientApi;
-import org.apache.fineract.client.services.CodeValuesApi;
-import org.apache.fineract.client.services.CodesApi;
-import org.apache.fineract.client.services.CurrencyApi;
-import org.apache.fineract.client.services.DataTablesApi;
-import org.apache.fineract.client.services.DefaultApi;
-import org.apache.fineract.client.services.DelinquencyRangeAndBucketsManagementApi;
-import org.apache.fineract.client.services.ExternalAssetOwnerLoanProductAttributesApi;
-import org.apache.fineract.client.services.ExternalAssetOwnersApi;
-import org.apache.fineract.client.services.ExternalEventConfigurationApi;
-import org.apache.fineract.client.services.FundsApi;
-import org.apache.fineract.client.services.GeneralLedgerAccountApi;
-import org.apache.fineract.client.services.GlobalConfigurationApi;
-import org.apache.fineract.client.services.InlineJobApi;
-import org.apache.fineract.client.services.InternalCobApi;
-import org.apache.fineract.client.services.JournalEntriesApi;
-import org.apache.fineract.client.services.LoanAccountLockApi;
-import org.apache.fineract.client.services.LoanBuyDownFeesApi;
-import org.apache.fineract.client.services.LoanCapitalizedIncomeApi;
-import org.apache.fineract.client.services.LoanChargesApi;
-import org.apache.fineract.client.services.LoanCobCatchUpApi;
-import org.apache.fineract.client.services.LoanDisbursementDetailsApi;
-import org.apache.fineract.client.services.LoanInterestPauseApi;
-import org.apache.fineract.client.services.LoanProductsApi;
-import org.apache.fineract.client.services.LoanTransactionsApi;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.client.services.MappingFinancialActivitiesToAccountsApi;
-import org.apache.fineract.client.services.PaymentTypeApi;
-import org.apache.fineract.client.services.RescheduleLoansApi;
-import org.apache.fineract.client.services.RolesApi;
-import org.apache.fineract.client.services.SavingsAccountApi;
-import org.apache.fineract.client.services.SavingsAccountTransactionsApi;
-import org.apache.fineract.client.services.SavingsProductApi;
-import org.apache.fineract.client.services.SchedulerApi;
-import org.apache.fineract.client.services.SchedulerJobApi;
-import org.apache.fineract.client.services.UsersApi;
-import org.apache.fineract.client.util.FineractClient;
-import org.apache.fineract.test.stepdef.loan.LoanProductsCustomApi;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-@RequiredArgsConstructor
-public class ApiConfiguration {
-
- private final FineractClient fineractClient;
-
- @Bean
- public SchedulerApi schedulerApi() {
- return fineractClient.createService(SchedulerApi.class);
- }
-
- @Bean
- public SchedulerJobApi schedulerJobApi() {
- return fineractClient.createService(SchedulerJobApi.class);
- }
-
- @Bean
- public CurrencyApi currencyApi() {
- return fineractClient.createService(CurrencyApi.class);
- }
-
- @Bean
- public DataTablesApi dataTablesApi() {
- return fineractClient.createService(DataTablesApi.class);
- }
-
- @Bean
- public ChargesApi chargesApi() {
- return fineractClient.createService(ChargesApi.class);
- }
-
- @Bean
- public GeneralLedgerAccountApi generalLedgerAccountApi() {
- return fineractClient.createService(GeneralLedgerAccountApi.class);
- }
-
- @Bean
- public LoanProductsApi loanProductsApi() {
- return fineractClient.createService(LoanProductsApi.class);
- }
-
- @Bean
- public LoanProductsCustomApi loanProductsCustomApi() {
- return fineractClient.createService(LoanProductsCustomApi.class);
- }
-
- @Bean
- public SavingsProductApi savingsProductApi() {
- return fineractClient.createService(SavingsProductApi.class);
- }
-
- @Bean
- public SavingsAccountTransactionsApi savingsAccountTransactionsApi() {
- return fineractClient.createService(SavingsAccountTransactionsApi.class);
- }
-
- @Bean
- public SavingsAccountApi savingsAccountApi() {
- return fineractClient.createService(SavingsAccountApi.class);
- }
-
- @Bean
- public CodesApi codesApi() {
- return fineractClient.createService(CodesApi.class);
- }
-
- @Bean
- public CodeValuesApi codeValuesApi() {
- return fineractClient.createService(CodeValuesApi.class);
- }
-
- @Bean
- public DelinquencyRangeAndBucketsManagementApi delinquencyRangeAndBucketsManagementApi() {
- return fineractClient.createService(DelinquencyRangeAndBucketsManagementApi.class);
- }
-
- @Bean
- public FundsApi fundsApi() {
- return fineractClient.createService(FundsApi.class);
- }
-
- @Bean
- public GlobalConfigurationApi globalConfigurationApi() {
- return fineractClient.createService(GlobalConfigurationApi.class);
- }
-
- @Bean
- public PaymentTypeApi paymentTypeApi() {
- return fineractClient.createService(PaymentTypeApi.class);
- }
-
- @Bean
- public BusinessDateManagementApi businessDateManagementApi() {
- return fineractClient.createService(BusinessDateManagementApi.class);
- }
-
- @Bean
- public ClientApi clientApi() {
- return fineractClient.createService(ClientApi.class);
- }
-
- @Bean
- public BatchApiApi batchApiApi() {
- return fineractClient.createService(BatchApiApi.class);
- }
-
- @Bean
- public LoansApi loansApi() {
- return fineractClient.createService(LoansApi.class);
- }
-
- @Bean
- public JournalEntriesApi journalEntriesApi() {
- return fineractClient.createService(JournalEntriesApi.class);
- }
-
- @Bean
- public InlineJobApi inlineJobApi() {
- return fineractClient.createService(InlineJobApi.class);
- }
-
- @Bean
- public LoanTransactionsApi loanTransactionsApi() {
- return fineractClient.createService(LoanTransactionsApi.class);
- }
-
- @Bean
- public LoanChargesApi loanChargesApi() {
- return fineractClient.createService(LoanChargesApi.class);
- }
-
- @Bean
- public ExternalEventConfigurationApi externalEventConfigurationApi() {
- return fineractClient.createService(ExternalEventConfigurationApi.class);
- }
-
- @Bean
- public LoanCobCatchUpApi loanCobCatchUpApi() {
- return fineractClient.createService(LoanCobCatchUpApi.class);
- }
-
- @Bean
- public RolesApi rolesApi() {
- return fineractClient.createService(RolesApi.class);
- }
-
- @Bean
- public UsersApi usersApi() {
- return fineractClient.createService(UsersApi.class);
- }
-
- @Bean
- public ExternalAssetOwnersApi externalAssetOwnersApi() {
- return fineractClient.createService(ExternalAssetOwnersApi.class);
- }
-
- @Bean
- public ExternalAssetOwnerLoanProductAttributesApi externalAssetOwnerLoanProductAttributesApi() {
- return fineractClient.createService(ExternalAssetOwnerLoanProductAttributesApi.class);
- }
-
- @Bean
- public BusinessStepConfigurationApi businessStepConfigurationApi() {
- return fineractClient.createService(BusinessStepConfigurationApi.class);
- }
-
- @Bean
- public MappingFinancialActivitiesToAccountsApi mappingFinancialActivitiesToAccountsApi() {
- return fineractClient.createService(MappingFinancialActivitiesToAccountsApi.class);
- }
-
- @Bean
- public LoanAccountLockApi loanAccountLockApi() {
- return fineractClient.createService(LoanAccountLockApi.class);
- }
-
- @Bean
- public DefaultApi defaultApi() {
- return fineractClient.createService(DefaultApi.class);
- }
-
- @Bean
- public RescheduleLoansApi rescheduleLoansApi() {
- return fineractClient.createService(RescheduleLoansApi.class);
- }
-
- @Bean
- public LoanInterestPauseApi loanInterestPauseApi() {
- return fineractClient.createService(LoanInterestPauseApi.class);
- }
-
- @Bean
- public LoanDisbursementDetailsApi loanDisbursementDetailsApi() {
- return fineractClient.createService(LoanDisbursementDetailsApi.class);
- }
-
- @Bean
- public LoanBuyDownFeesApi loanBuyDownFeesApi() {
- return fineractClient.createService(LoanBuyDownFeesApi.class);
- }
-
- @Bean
- public LoanCapitalizedIncomeApi loanCapitalizedIncomeApi() {
- return fineractClient.createService(LoanCapitalizedIncomeApi.class);
- }
-
- @Bean
- public InternalCobApi internalCobApi() {
- return fineractClient.createService(InternalCobApi.class);
- }
-}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/FineractClientConfiguration.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/FineractClientConfiguration.java
index 27a71041e8..b690df76a4 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/FineractClientConfiguration.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/api/FineractClientConfiguration.java
@@ -18,10 +18,10 @@
*/
package org.apache.fineract.test.api;
-import java.time.Duration;
+import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.client.util.FineractClient;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -33,15 +33,18 @@ public class FineractClientConfiguration {
private final ApiProperties apiProperties;
@Bean
- public FineractClient fineractClient() {
+ public FineractFeignClient fineractFeignClient() {
String baseUrl = apiProperties.getBaseUrl();
String username = apiProperties.getUsername();
String password = apiProperties.getPassword();
String tenantId = apiProperties.getTenantId();
long readTimeout = apiProperties.getReadTimeout();
String apiBaseUrl = baseUrl + "/fineract-provider/api/";
- log.info("Using base URL '{}'", apiBaseUrl);
- return FineractClient.builder().readTimeout(Duration.ofSeconds(readTimeout)).basicAuth(username, password).tenant(tenantId)
- .baseURL(apiBaseUrl).insecure(true).build();
+ boolean debugEnabled = Boolean.parseBoolean(System.getProperty("fineract.feign.debug", "false"));
+
+ FineractFeignClient client = FineractFeignClient.builder().baseUrl(apiBaseUrl).credentials(username, password).tenantId(tenantId)
+ .disableSslVerification(true).debug(debugEnabled).connectTimeout(60, TimeUnit.SECONDS)
+ .readTimeout((int) readTimeout, TimeUnit.SECONDS).build();
+ return client;
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/accounttype/AccountTypeResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/accounttype/AccountTypeResolver.java
index 0788f7b953..26dc6cfbb6 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/accounttype/AccountTypeResolver.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/accounttype/AccountTypeResolver.java
@@ -18,41 +18,35 @@
*/
package org.apache.fineract.test.data.accounttype;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetGLAccountsResponse;
-import org.apache.fineract.client.services.GeneralLedgerAccountApi;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@Slf4j
public class AccountTypeResolver {
- private final GeneralLedgerAccountApi glaApi;
+ private final FineractFeignClient fineractClient;
@Cacheable(key = "#accountType.getName()", value = "accountTypesByName")
public long resolve(AccountType accountType) {
- try {
- String accountTypeName = accountType.getName();
- log.debug("Resolving account type by name [{}]", accountTypeName);
- Response<List<GetGLAccountsResponse>> response = glaApi.retrieveAllAccounts(null, "", 1, true, false, false).execute();
- if (!response.isSuccessful()) {
- throw new IllegalStateException("Unable to get account types. Status code was HTTP " + response.code());
- }
- List<GetGLAccountsResponse> accountTypeResponses = response.body();
- GetGLAccountsResponse foundAtr = accountTypeResponses.stream()//
- .filter(atr -> accountTypeName.equals(atr.getName()))//
- .findAny()//
- .orElseThrow(() -> new IllegalArgumentException("Account type [%s] not found".formatted(accountTypeName)));//
+ String accountTypeName = accountType.getName();
+ log.debug("Resolving account type by name [{}]", accountTypeName);
+ List<GetGLAccountsResponse> accountTypeResponses = ok(() -> fineractClient.generalLedgerAccount().retrieveAllAccountsUniversal(
+ Map.of("usage", 1, "manualEntriesAllowed", true, "disabled", false, "fetchRunningBalance", false)));
+ GetGLAccountsResponse foundAtr = accountTypeResponses.stream()//
+ .filter(atr -> accountTypeName.equals(atr.getName()))//
+ .findAny()//
+ .orElseThrow(() -> new IllegalArgumentException("Account type [%s] not found".formatted(accountTypeName)));//
- return foundAtr.getId();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ return foundAtr.getId();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/codevalue/CodeValueResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/codevalue/CodeValueResolver.java
index 9c93cd56c2..2875b14686 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/codevalue/CodeValueResolver.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/codevalue/CodeValueResolver.java
@@ -18,41 +18,33 @@
*/
package org.apache.fineract.test.data.codevalue;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetCodeValuesDataResponse;
-import org.apache.fineract.client.services.CodeValuesApi;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@Slf4j
public class CodeValueResolver {
- private final CodeValuesApi codeValuesApi;
+ private final FineractFeignClient fineractClient;
@Cacheable(key = "#codeValue.getName()", value = "codeValuesByName")
public long resolve(Long codeId, CodeValue codeValue) {
- try {
- String codeValueName = codeValue.getName();
-
- log.debug("Resolving code value by code id and name [{}]", codeValue);
- Response<List<GetCodeValuesDataResponse>> response = codeValuesApi.retrieveAllCodeValues(codeId).execute();
- if (!response.isSuccessful()) {
- throw new IllegalStateException("Unable to get payment types. Status code was HTTP " + response.code());
- }
+ String codeValueName = codeValue.getName();
- List<GetCodeValuesDataResponse> codeValuesResponses = response.body();
- GetCodeValuesDataResponse foundPtr = codeValuesResponses.stream().filter(ptr -> codeValueName.equals(ptr.getName())).findAny()
- .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(codeValueName)));
+ log.debug("Resolving code value by code id and name [{}]", codeValue);
+ List<GetCodeValuesDataResponse> codeValuesResponses = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(codeId, Map.of()));
+ GetCodeValuesDataResponse foundPtr = codeValuesResponses.stream().filter(ptr -> codeValueName.equals(ptr.getName())).findAny()
+ .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(codeValueName)));
- return foundPtr.getId();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ return foundPtr.getId();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/datatable/DatatableNameGenerator.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/datatable/DatatableNameGenerator.java
index 4f99baba39..4b56587192 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/datatable/DatatableNameGenerator.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/datatable/DatatableNameGenerator.java
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.test.data.datatable;
+import java.util.Locale;
import org.apache.fineract.test.helper.Utils;
import org.springframework.stereotype.Component;
@@ -25,6 +26,6 @@ import org.springframework.stereotype.Component;
public class DatatableNameGenerator {
public String generate(DatatableEntityType entityType) {
- return Utils.randomStringGenerator("dt_%s_".formatted(entityType.getReferencedTableName()), 5).toLowerCase();
+ return Utils.randomStringGenerator("dt_%s_".formatted(entityType.getReferencedTableName()), 5).toLowerCase(Locale.ROOT);
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/job/JobResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/job/JobResolver.java
index 4e562ce3ad..c8095b2da4 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/job/JobResolver.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/job/JobResolver.java
@@ -18,34 +18,28 @@
*/
package org.apache.fineract.test.data.job;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetJobsResponse;
-import org.apache.fineract.client.services.SchedulerJobApi;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@Slf4j
public class JobResolver {
- private final SchedulerJobApi schedulerJobApi;
+ private final FineractFeignClient fineractClient;
@Cacheable(key = "#job.getShortName()", value = "jobsByShortName")
public long resolve(Job job) {
- try {
- String shortName = job.getShortName();
- log.debug("Resolving job by short-name [{}]", shortName);
- Response<GetJobsResponse> response = schedulerJobApi.retrieveByShortName(shortName).execute();
- if (!response.isSuccessful()) {
- throw new IllegalStateException("Unable to get job. Status code was HTTP " + response.code());
- }
- return response.body().getJobId();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ String shortName = job.getShortName();
+ log.debug("Resolving job by short-name [{}]", shortName);
+ GetJobsResponse response = ok(() -> fineractClient.schedulerJob().retrieveByShortName(shortName, Map.of()));
+ return response.getJobId();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/LoanProductResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/LoanProductResolver.java
index 3f62a67595..18c7e9607d 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/LoanProductResolver.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/LoanProductResolver.java
@@ -18,39 +18,33 @@
*/
package org.apache.fineract.test.data.loanproduct;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetLoanProductsResponse;
-import org.apache.fineract.client.services.LoanProductsApi;
-import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@Slf4j
public class LoanProductResolver {
- private final LoanProductsApi loanProductsApi;
+ private final FineractFeignClient fineractClient;
- @Cacheable(key = "#loanProduct.getName()", value = "loanProductsByName")
public long resolve(LoanProduct loanProduct) {
- try {
- String loanProductName = loanProduct.getName();
- log.debug("Resolving loan product by name [{}]", loanProductName);
- Response<List<GetLoanProductsResponse>> response = loanProductsApi.retrieveAllLoanProducts().execute();
- if (!response.isSuccessful()) {
- throw new IllegalStateException("Unable to get loan products. Status code was HTTP " + response.code());
- }
+ String loanProductName = loanProduct.getName();
+ log.debug("Resolving loan product by name [{}]", loanProductName);
+ List<GetLoanProductsResponse> loanProductsResponses = ok(() -> fineractClient.loanProducts().retrieveAllLoanProducts(Map.of()));
+
+ log.info("Retrieved {} loan products from API", loanProductsResponses.size());
+ log.info("Available loan products: {}", loanProductsResponses.stream().map(GetLoanProductsResponse::getName).toList());
- List<GetLoanProductsResponse> loanProductsResponses = response.body();
- GetLoanProductsResponse foundLpr = loanProductsResponses.stream().filter(lpr -> loanProductName.equals(lpr.getName())).findAny()
- .orElseThrow(() -> new IllegalArgumentException("Loan product [%s] not found".formatted(loanProductName)));
- return foundLpr.getId();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ GetLoanProductsResponse foundLpr = loanProductsResponses.stream().filter(lpr -> loanProductName.equals(lpr.getName())).findAny()
+ .orElseThrow(() -> new IllegalArgumentException("Loan product [%s] not found".formatted(loanProductName)));
+ return foundLpr.getId();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java
index 25364e2b35..0b75e696c4 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java
@@ -18,40 +18,33 @@
*/
package org.apache.fineract.test.data.paymenttype;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.PaymentTypeData;
-import org.apache.fineract.client.services.PaymentTypeApi;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@Slf4j
public class PaymentTypeResolver {
- private final PaymentTypeApi paymentTypeApi;
+ private final FineractFeignClient fineractClient;
@Cacheable(key = "#paymentType.getName()", value = "paymentTypesByName")
public long resolve(PaymentType paymentType) {
- try {
- String paymentTypeName = paymentType.getName();
- log.debug("Resolving payment type by name [{}]", paymentTypeName);
- Response<List<PaymentTypeData>> response = paymentTypeApi.getAllPaymentTypes(false).execute();
- if (!response.isSuccessful()) {
- throw new IllegalStateException("Unable to get payment types. Status code was HTTP " + response.code());
- }
+ String paymentTypeName = paymentType.getName();
+ log.debug("Resolving payment type by name [{}]", paymentTypeName);
+ List<PaymentTypeData> paymentTypesResponses = ok(() -> fineractClient.paymentType().getAllPaymentTypesUniversal(Map.of()));
- List<PaymentTypeData> paymentTypesResponses = response.body();
- PaymentTypeData foundPtr = paymentTypesResponses.stream().filter(ptr -> paymentTypeName.equals(ptr.getName())).findAny()
- .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(paymentTypeName)));
+ PaymentTypeData foundPtr = paymentTypesResponses.stream().filter(ptr -> paymentTypeName.equals(ptr.getName())).findAny()
+ .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(paymentTypeName)));
- return foundPtr.getId();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ return foundPtr.getId();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/BusinessDateHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/BusinessDateHelper.java
index 4c4c170f26..4e3105f309 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/BusinessDateHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/BusinessDateHelper.java
@@ -18,17 +18,21 @@
*/
package org.apache.fineract.test.helper;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.time.format.DateTimeFormatter;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.BusinessDateResponse;
import org.apache.fineract.client.models.BusinessDateUpdateRequest;
import org.apache.fineract.client.models.BusinessDateUpdateResponse;
-import org.apache.fineract.client.services.BusinessDateManagementApi;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
+@Slf4j
@RequiredArgsConstructor
@Component
public class BusinessDateHelper {
@@ -38,18 +42,23 @@ public class BusinessDateHelper {
public static final String BUSINESS_DATE = "BUSINESS_DATE";
public static final String COB = "COB_DATE";
- private final BusinessDateManagementApi businessDateManagementApi;
+ private final FineractFeignClient fineractClient;
- public void setBusinessDate(String businessDate) throws IOException {
+ public void setBusinessDate(String businessDate) {
BusinessDateUpdateRequest businessDateRequest = defaultBusinessDateRequest().date(businessDate);
+ try {
+ BusinessDateUpdateResponse response = ok(
+ () -> fineractClient.businessDateManagement().updateBusinessDate(null, businessDateRequest, Map.of()));
+ TestContext.INSTANCE.set(TestContextKey.BUSINESS_DATE_RESPONSE, response);
+ ok(() -> fineractClient.businessDateManagement().getBusinessDate(BUSINESS_DATE, Map.of()));
- Response<BusinessDateUpdateResponse> businessDateRequestResponse = businessDateManagementApi
- .updateBusinessDate(null, businessDateRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(businessDateRequestResponse);
- TestContext.INSTANCE.set(TestContextKey.BUSINESS_DATE_RESPONSE, businessDateRequestResponse);
+ } catch (Exception e) {
+ log.error("Error: {}", e.getMessage());
+ throw e;
+ }
}
- public void setBusinessDateToday() throws IOException {
+ public void setBusinessDateToday() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
String today = formatter.format(Utils.now());
setBusinessDate(today);
@@ -60,7 +69,9 @@ public class BusinessDateHelper {
.locale(DEFAULT_LOCALE);
}
- public String getBusinessDate() throws IOException {
- return businessDateManagementApi.getBusinessDate(BUSINESS_DATE).toString();
+ public String getBusinessDate() {
+ log.debug("Getting business date (using Feign)");
+ BusinessDateResponse response = ok(() -> fineractClient.businessDateManagement().getBusinessDate(BUSINESS_DATE, Map.of()));
+ return response.toString();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/CodeHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/CodeHelper.java
index d0a75faf7b..4b0dcdac46 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/CodeHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/CodeHelper.java
@@ -18,16 +18,15 @@
*/
package org.apache.fineract.test.helper;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.util.Map;
import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetCodesResponse;
import org.apache.fineract.client.models.PostCodeValueDataResponse;
import org.apache.fineract.client.models.PostCodeValuesDataRequest;
-import org.apache.fineract.client.services.CodeValuesApi;
-import org.apache.fineract.client.services.CodesApi;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@@ -37,31 +36,30 @@ public class CodeHelper {
private static final String STATE_CODE_NAME = "STATE";
private static final String ADDRESS_TYPE_CODE_NAME = "ADDRESS_TYPE";
- private final CodesApi codesApi;
- private final CodeValuesApi codeValuesApi;
+ private final FineractFeignClient fineractClient;
- public Response<PostCodeValueDataResponse> createAddressTypeCodeValue(String addressTypeName) throws IOException {
+ public PostCodeValueDataResponse createAddressTypeCodeValue(String addressTypeName) {
Long codeId = retrieveCodeByName(ADDRESS_TYPE_CODE_NAME).getId();
- return codeValuesApi.createCodeValue(codeId, new PostCodeValuesDataRequest().name(addressTypeName)).execute();
+ return ok(
+ () -> fineractClient.codeValues().createCodeValue(codeId, new PostCodeValuesDataRequest().name(addressTypeName), Map.of()));
}
- public Response<PostCodeValueDataResponse> createCountryCodeValue(String countryName) throws IOException {
+ public PostCodeValueDataResponse createCountryCodeValue(String countryName) {
Long codeId = retrieveCodeByName(COUNTRY_CODE_NAME).getId();
- return codeValuesApi.createCodeValue(codeId, new PostCodeValuesDataRequest().name(countryName)).execute();
+ return ok(() -> fineractClient.codeValues().createCodeValue(codeId, new PostCodeValuesDataRequest().name(countryName), Map.of()));
}
- public Response<PostCodeValueDataResponse> createStateCodeValue(String stateName) throws IOException {
+ public PostCodeValueDataResponse createStateCodeValue(String stateName) {
Long codeId = retrieveCodeByName(STATE_CODE_NAME).getId();
- return codeValuesApi.createCodeValue(codeId, new PostCodeValuesDataRequest().name(stateName)).execute();
+ return ok(() -> fineractClient.codeValues().createCodeValue(codeId, new PostCodeValuesDataRequest().name(stateName), Map.of()));
}
- @SneakyThrows
public GetCodesResponse retrieveCodeByName(String name) {
- return codesApi.retrieveCodes().execute().body().stream().filter(r -> name.equals(r.getName())).findAny()
+ return ok(() -> fineractClient.codes().retrieveCodes(Map.of())).stream().filter(r -> name.equals(r.getName())).findAny()
.orElseThrow(() -> new IllegalArgumentException("Code with name " + name + " has not been found"));
}
- public Response<PostCodeValueDataResponse> createCodeValue(Long codeId, PostCodeValuesDataRequest request) throws IOException {
- return codeValuesApi.createCodeValue(codeId, request).execute();
+ public PostCodeValueDataResponse createCodeValue(Long codeId, PostCodeValuesDataRequest request) {
+ return ok(() -> fineractClient.codeValues().createCodeValue(codeId, request, Map.of()));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorHelper.java
deleted file mode 100644
index ea27ebb005..0000000000
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorHelper.java
+++ /dev/null
@@ -1,53 +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.test.helper;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.util.List;
-import org.apache.fineract.client.models.BatchResponse;
-import retrofit2.Response;
-
-public final class ErrorHelper {
-
- private ErrorHelper() {}
-
- public static void checkSuccessfulApiCall(Response response) throws IOException {
- assertThat(response.isSuccessful()).as(ErrorMessageHelper.requestFailed(response)).isTrue();
-
- if (response.code() != 200 && response.code() != 202 && response.code() != 204) {
- throw new AssertionError(ErrorMessageHelper.requestFailedWithCode(response));
- }
- }
-
- public static void checkFailedApiCall(Response response, int requiredCode) throws IOException {
- assertThat(!response.isSuccessful()).as(ErrorMessageHelper.requestFailed(response)).isTrue();
-
- if (response.code() != requiredCode) {
- throw new AssertionError("Request success but should fail with code: " + requiredCode);
- }
- }
-
- public static void checkSuccessfulBatchApiCall(Response<List<BatchResponse>> batchResponseList) {
- batchResponseList.body().forEach(response -> {
- assertThat(response.getStatusCode()).as(ErrorMessageHelper.batchRequestFailedWithCode(response)).isEqualTo(200);
- });
- }
-}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java
index a687fdedad..fb89bbdad9 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java
@@ -23,12 +23,10 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.client.models.BatchResponse;
-import org.apache.fineract.client.models.GetJournalEntriesTransactionIdResponse;
import org.apache.fineract.client.models.Header;
import org.apache.fineract.client.models.LoanAccountLockResponseDTO;
import retrofit2.Response;
@@ -134,10 +132,6 @@ public final class ErrorMessageHelper {
}
- public static String transactionDateInFutureFailureMsg() {
- return "The transaction date cannot be in the future.";
- }
-
public static String repaymentUndoFailureDueToChargeOff(Long loanId) {
String loanIdStr = String.valueOf(loanId);
return String.format("Loan transaction: %s adjustment is not allowed before or on the date when the loan got charged-off",
@@ -286,11 +280,6 @@ public final class ErrorMessageHelper {
expected);
}
- public static String wrongDataInTransactionsTransactionDate(String actual, String expected) {
- return String.format("Wrong data in Transactions / Transaction date. Actual value is: %s - But expected value is: %s", actual,
- expected);
- }
-
public static String transactionIsNotReversedError(Boolean actual, Boolean expected) {
return String.format("The transaction should be reversed, but it is not. Actual value is: %s - But expected value is: %s", actual,
expected);
@@ -303,34 +292,6 @@ public final class ErrorMessageHelper {
expectedToStr);
}
- public static String wrongAmountInTransactionsPrincipal(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Transactions / Principal. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongAmountInTransactionsInterest(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Transactions / Interest. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongAmountInTransactionsFees(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Transactions / Fees. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongAmountInTransactionsPenalties(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Transactions / Penalties. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
public static String wrongAmountInTransactionsOverpayment(Double actual, Double expected) {
String actualToStr = actual.toString();
String expectedToStr = expected.toString();
@@ -338,57 +299,10 @@ public final class ErrorMessageHelper {
expectedToStr);
}
- public static String wrongAmountInTransactionsBalance(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Transactions / Loan Balance. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
public static String transactionHasNullResourceValue(String transactionType, String resourceName) {
return String.format("The transaction %s should has non-null value for %s, but it is null.", transactionType, resourceName);
}
- public static String wrongDataInChargesName(String actual, String expected) {
- return String.format("Wrong data in Charges / Name. Actual value is: %s - But expected value is: %s", actual, expected);
- }
-
- public static String wrongDataInChargesIsPenalty(String actual, String expected) {
- return String.format("Wrong data in Charges / isPenalty. Actual value is: %s - But expected value is: %s", actual, expected);
- }
-
- public static String wrongDataInChargesDueDate(String actual, String expected) {
- return String.format("Wrong data in Charges / Due Date. Actual value is: %s - But expected value is: %s", actual, expected);
- }
-
- public static String wrongDataInChargesAmountDue(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Charges / Due amount. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongDataInChargesAmountPaid(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Charges / Paid amount. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongDataInChargesAmountWaived(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Charges / Waived amount. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
- public static String wrongDataInChargesAmountOutstanding(Double actual, Double expected) {
- String actualToStr = actual.toString();
- String expectedToStr = expected.toString();
- return String.format("Wrong amount in Charges / Outstanding amount. Actual amount is: %s - But expected amount is: %s", actualToStr,
- expectedToStr);
- }
-
public static String wrongAmountInTotalOutstanding(Double actual, Double expected) {
String actualToStr = actual.toString();
String expectedToStr = expected.toString();
@@ -464,20 +378,6 @@ public final class ErrorMessageHelper {
return "Loan Repayment (or its types) or Waiver is not allowed. Loan Account is not active.";
}
- public static String noTransactionMetCriteria(String transactionType, String date) {
- return String.format(
- "There are no transaction in Transactions met the following criteria: Transaction type = %s, Transaction date = %s",
- transactionType, date);
- }
-
- public static String missingMatchInJournalEntries(Map<String, String> entryPairs,
- List<GetJournalEntriesTransactionIdResponse> entryDataList) {
- String entryPairsStr = entryPairs.toString();
- String entryDataListStr = entryDataList.toString();
- return String.format("One or more entry pairs missing from Journal entries. Expected entry pairs: %s. Actual Journal entries: %s",
- entryPairsStr, entryDataListStr);
- }
-
public static String wrongErrorCodeInFailedChargeAdjustment(Integer actual, Integer expected) {
return String.format("Not the expected error code in error body: Actual error message is: %s. Expected error code is: %s",
actual.toString(), expected.toString());
@@ -596,31 +496,6 @@ public final class ErrorMessageHelper {
resourceId, line, actual, expected);
}
- public static String wrongDataInJournalEntriesGlAccountType(int line, String actual, String expected) {
- return String.format("Wrong data in Journal entries, line %s / GL account type. " //
- + "Actual value is: %s - But expected value is: %s", line, actual, expected);
- }
-
- public static String wrongDataInJournalEntriesGlAccountCode(int line, String actual, String expected) {
- return String.format("Wrong data in Journal entries, line %s / GL account code. Actual value is: %s - But expected value is: %s",
- line, actual, expected);
- }
-
- public static String wrongDataInJournalEntriesGlAccountName(int line, String actual, String expected) {
- return String.format("Wrong data in Journal entries, line %s / GL account name. Actual value is: %s - But expected value is: %s",
- line, actual, expected);
- }
-
- public static String wrongDataInJournalEntriesDebit(int line, String actual, String expected) {
- return String.format("Wrong data in Journal entries, line %s / Debit. Actual value is: %s - But expected value is: %s", line,
- actual, expected);
- }
-
- public static String wrongDataInJournalEntriesCredit(int line, String actual, String expected) {
- return String.format("Wrong data in Journal entries, line %s / Credit. Actual value is: %s - But expected value is: %s", line,
- actual, expected);
- }
-
public static String wrongDataInActualMaturityDate(String actual, String expected) {
return String.format("Wrong data in Loan details/Timeline/actualMaturityDate. Actual value is: %s - But expected value is: %s",
actual, expected);
@@ -707,10 +582,6 @@ public final class ErrorMessageHelper {
return String.format("No attribute %s for loan product %s is found!", attributeKey, loanProduct);
}
- public static String wrongData(String actual, String expected) {
- return String.format("Wrong data. Actual value is: %s - But expected value is: %s", actual, expected);
- }
-
public static String wrongValueInExternalAssetDetails(int line, List<List<String>> actual, List<String> expected) {
String lineStr = String.valueOf(line);
String expectedStr = expected.toString();
@@ -774,13 +645,13 @@ public final class ErrorMessageHelper {
expectedStr);
}
- public static String listOfLockedLoansNotEmpty(Response<LoanAccountLockResponseDTO> response) {
- String bodyStr = response.body().toString();
+ public static String listOfLockedLoansNotEmpty(LoanAccountLockResponseDTO response) {
+ String bodyStr = response.toString();
return String.format("List of locked loan accounts is not empty. Actual response is: %n%s", bodyStr);
}
- public static String listOfLockedLoansContainsLoan(Long loanId, Response<LoanAccountLockResponseDTO> response) {
- String bodyStr = response.body().toString();
+ public static String listOfLockedLoansContainsLoan(Long loanId, LoanAccountLockResponseDTO response) {
+ String bodyStr = response.toString();
return String.format("List of locked loan accounts contains the loan with loanId %s. List of locked loans: %n%s", loanId, bodyStr);
}
@@ -1081,6 +952,13 @@ public final class ErrorMessageHelper {
actual, expected);
}
+ public static String wrongAmountInDeferredCapitalizedIncome(BigDecimal actual, BigDecimal expected) {
+ String actualToStr = actual == null ? "null" : actual.toString();
+ String expectedToStr = expected == null ? "null" : expected.toString();
+ return String.format("Wrong amount in Deferred Capitalized Income. Actual amount is: %s - But expected amount is: %s", actualToStr,
+ expectedToStr);
+ }
+
public static String reAgeChargedOffLoanFailure() {
return "Loan re-aging is not allowed on charged-off loan.";
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorResponse.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorResponse.java
index f746d56a37..cbac529b4c 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorResponse.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorResponse.java
@@ -18,13 +18,14 @@
*/
package org.apache.fineract.test.helper;
-import com.google.gson.Gson;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.apache.fineract.client.util.JSON;
+import org.apache.fineract.client.feign.ObjectMapperFactory;
import retrofit2.Response;
@NoArgsConstructor
@@ -32,36 +33,88 @@ import retrofit2.Response;
@Setter
public class ErrorResponse {
- private static final Gson GSON = new JSON().getGson();
+ private static final ObjectMapper OBJECT_MAPPER = ObjectMapperFactory.getShared();
private String developerMessage;
private Integer httpStatusCode;
- private List<Error> errors;
+ private List<ErrorDetail> errors;
+
+ public ErrorDetail getSingleError() {
+ if (hasTopLevelErrorOnly()) {
+ return createErrorFromDeveloperMessage();
+ }
+
+ if (errors == null || errors.isEmpty()) {
+ if (this.developerMessage != null) {
+ return createErrorFromDeveloperMessage();
+ }
+ throw new IllegalStateException("No errors found in response");
+ }
- public Error getSingleError() {
if (errors.size() != 1) {
throw new IllegalStateException("Multiple errors found");
- } else {
- return errors.iterator().next();
}
+
+ return errors.iterator().next();
+ }
+
+ private boolean hasTopLevelErrorOnly() {
+ return this.httpStatusCode != null && this.httpStatusCode == 400 && this.developerMessage != null
+ && this.developerMessage.contains("invalid") && (this.errors == null || this.errors.isEmpty());
+ }
+
+ private ErrorDetail createErrorFromDeveloperMessage() {
+ ErrorDetail error = new ErrorDetail();
+ error.setDeveloperMessage(this.developerMessage);
+ return error;
}
public static ErrorResponse from(Response retrofitResponse) {
try {
String errorBody = retrofitResponse.errorBody().string();
- return GSON.fromJson(errorBody, ErrorResponse.class);
+ return OBJECT_MAPPER.readValue(errorBody, ErrorResponse.class);
} catch (IOException e) {
throw new RuntimeException("Error while parsing the error body", e);
}
}
+ public static ErrorResponse fromFeignException(feign.FeignException feignException) {
+ try {
+ String errorBody = feignException.contentUTF8();
+ return OBJECT_MAPPER.readValue(errorBody, ErrorResponse.class);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException("Error while parsing the error body", e);
+ }
+ }
+
+ public static ErrorResponse fromFeignException(org.apache.fineract.client.feign.FeignException feignException) {
+ try {
+ String errorBody = feignException.responseBodyAsString();
+ ErrorResponse errorResponse = OBJECT_MAPPER.readValue(errorBody, ErrorResponse.class);
+ errorResponse.setHttpStatusCode(feignException.status());
+ return errorResponse;
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException("Error while parsing the error body", e);
+ }
+ }
+
@NoArgsConstructor
@Getter
@Setter
- public static class Error {
+ public static class ErrorDetail {
private String developerMessage;
private List<ErrorMessageArg> args;
+
+ public String getDeveloperMessageWithoutPrefix() {
+ if (developerMessage == null) {
+ return null;
+ }
+ if (developerMessage.startsWith("[") && developerMessage.contains("] ")) {
+ return developerMessage.substring(developerMessage.indexOf("] ") + 2);
+ }
+ return developerMessage;
+ }
}
@NoArgsConstructor
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/GlobalConfigurationHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/GlobalConfigurationHelper.java
index fefacea9e6..7a2d6a6464 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/GlobalConfigurationHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/GlobalConfigurationHelper.java
@@ -18,66 +18,60 @@
*/
package org.apache.fineract.test.helper;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
-import java.io.IOException;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GlobalConfigurationPropertyData;
import org.apache.fineract.client.models.PutGlobalConfigurationsRequest;
-import org.apache.fineract.client.models.PutGlobalConfigurationsResponse;
-import org.apache.fineract.client.services.GlobalConfigurationApi;
-import org.apache.http.HttpStatus;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
public class GlobalConfigurationHelper {
- private final GlobalConfigurationApi globalConfigurationApi;
+ private final FineractFeignClient fineractClient;
- public void disableGlobalConfiguration(String configKey, Long value) throws IOException {
+ public void disableGlobalConfiguration(String configKey, Long value) {
switchAndSetGlobalConfiguration(configKey, false, value);
}
- public void enableGlobalConfiguration(String configKey, Long value) throws IOException {
+ public void enableGlobalConfiguration(String configKey, Long value) {
switchAndSetGlobalConfiguration(configKey, true, value);
}
- private void switchAndSetGlobalConfiguration(String configKey, boolean enabled, Long value) throws IOException {
- Response<GlobalConfigurationPropertyData> configuration = globalConfigurationApi.retrieveOneByName(configKey).execute();
- ErrorHelper.checkSuccessfulApiCall(configuration);
- Long configId = configuration.body().getId();
+ private void switchAndSetGlobalConfiguration(String configKey, boolean enabled, Long value) {
+ GlobalConfigurationPropertyData configuration = ok(
+ () -> fineractClient.globalConfiguration().retrieveOneByName(configKey, Map.of()));
+ Long configId = configuration.getId();
PutGlobalConfigurationsRequest updateRequest = new PutGlobalConfigurationsRequest().enabled(enabled).value(value);
- Response<PutGlobalConfigurationsResponse> updateResponse = globalConfigurationApi.updateConfiguration1(configId, updateRequest)
- .execute();
- assertThat(updateResponse.code()).isEqualTo(HttpStatus.SC_OK);
- Response<GlobalConfigurationPropertyData> updatedConfiguration = globalConfigurationApi.retrieveOneByName(configKey).execute();
- boolean isEnabled = BooleanUtils.toBoolean(updatedConfiguration.body().getEnabled());
+ ok(() -> fineractClient.globalConfiguration().updateConfiguration1(configId, updateRequest, Map.of()));
+ GlobalConfigurationPropertyData updatedConfiguration = ok(
+ () -> fineractClient.globalConfiguration().retrieveOneByName(configKey, Map.of()));
+ boolean isEnabled = BooleanUtils.toBoolean(updatedConfiguration.getEnabled());
assertThat(isEnabled).isEqualTo(enabled);
}
- public void setGlobalConfigValueString(String configKey, String value) throws IOException {
- Response<GlobalConfigurationPropertyData> configuration = globalConfigurationApi.retrieveOneByName(configKey).execute();
- ErrorHelper.checkSuccessfulApiCall(configuration);
- Long configId = configuration.body().getId();
+ public void setGlobalConfigValueString(String configKey, String value) {
+ GlobalConfigurationPropertyData configuration = ok(
+ () -> fineractClient.globalConfiguration().retrieveOneByName(configKey, Map.of()));
+ Long configId = configuration.getId();
PutGlobalConfigurationsRequest updateRequest = new PutGlobalConfigurationsRequest().enabled(true).stringValue(value);
- Response<PutGlobalConfigurationsResponse> updateResponse = globalConfigurationApi.updateConfiguration1(configId, updateRequest)
- .execute();
- assertThat(updateResponse.code()).isEqualTo(HttpStatus.SC_OK);
- Response<GlobalConfigurationPropertyData> updatedConfiguration = globalConfigurationApi.retrieveOneByName(configKey).execute();
- boolean isEnabled = BooleanUtils.toBoolean(updatedConfiguration.body().getEnabled());
+ ok(() -> fineractClient.globalConfiguration().updateConfiguration1(configId, updateRequest, Map.of()));
+ GlobalConfigurationPropertyData updatedConfiguration = ok(
+ () -> fineractClient.globalConfiguration().retrieveOneByName(configKey, Map.of()));
+ boolean isEnabled = BooleanUtils.toBoolean(updatedConfiguration.getEnabled());
assertThat(isEnabled).isEqualTo(true);
}
- public GlobalConfigurationPropertyData getGlobalConfiguration(String configKey) throws IOException {
- Response<GlobalConfigurationPropertyData> configuration = globalConfigurationApi.retrieveOneByName(configKey).execute();
- ErrorHelper.checkSuccessfulApiCall(configuration);
- return configuration.body();
+ public GlobalConfigurationPropertyData getGlobalConfiguration(String configKey) {
+ return ok(() -> fineractClient.globalConfiguration().retrieveOneByName(configKey, Map.of()));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/WorkFlowJobHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/WorkFlowJobHelper.java
index 1a4f2ece3c..c1c5621a86 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/WorkFlowJobHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/WorkFlowJobHelper.java
@@ -18,18 +18,20 @@
*/
package org.apache.fineract.test.helper;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.Comparator;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.BusinessStep;
import org.apache.fineract.client.models.BusinessStepRequest;
import org.apache.fineract.client.models.JobBusinessStepConfigData;
-import org.apache.fineract.client.services.BusinessStepConfigurationApi;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@RequiredArgsConstructor
@Component
@@ -38,9 +40,9 @@ public class WorkFlowJobHelper {
private static final String WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS = "LOAN_CLOSE_OF_BUSINESS";
- private final BusinessStepConfigurationApi businessStepConfigurationApi;
+ private final FineractFeignClient fineractClient;
- public void setWorkflowJobs() throws IOException {
+ public void setWorkflowJobs() {
List<BusinessStep> businessSteps = List.of(new BusinessStep().stepName("APPLY_CHARGE_TO_OVERDUE_LOANS").order(1L), //
new BusinessStep().stepName("LOAN_DELINQUENCY_CLASSIFICATION").order(2L), //
new BusinessStep().stepName("CHECK_LOAN_REPAYMENT_DUE").order(3L), //
@@ -55,18 +57,15 @@ public class WorkFlowJobHelper {
new BusinessStep().stepName("EXTERNAL_ASSET_OWNER_TRANSFER").order(12L)//
);
BusinessStepRequest request = new BusinessStepRequest().businessSteps(businessSteps);
- Response<Void> response = businessStepConfigurationApi.updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, request)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- // --- log changes ---
+ executeVoid(() -> fineractClient.businessStepConfiguration().updateJobBusinessStepConfig(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS,
+ request, Map.of()));
logChanges();
}
- private void logChanges() throws IOException {
- // --- log changes ---
- Response<JobBusinessStepConfigData> changesResponse = businessStepConfigurationApi
- .retrieveAllConfiguredBusinessStep(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS).execute();
- List<BusinessStep> businessStepsChanged = changesResponse.body().getBusinessSteps();
+ private void logChanges() {
+ JobBusinessStepConfigData changesResponse = ok(() -> fineractClient.businessStepConfiguration()
+ .retrieveAllConfiguredBusinessStep(WORKFLOW_NAME_LOAN_CLOSE_OF_BUSINESS, Map.of()));
+ List<BusinessStep> businessStepsChanged = changesResponse.getBusinessSteps();
List<String> changes = businessStepsChanged//
.stream()//
.sorted(Comparator.comparingLong(BusinessStep::getOrder))//
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/base/FineractInitializer.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/base/FineractInitializer.java
index d08129406f..cb245fa72e 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/base/FineractInitializer.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/base/FineractInitializer.java
@@ -41,6 +41,12 @@ public class FineractInitializer implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
+ // ALWAYS log initializer counts at INFO level for debugging
+ log.info("=== FineractInitializer.afterPropertiesSet() called ===");
+ log.info("Global initializers count: {}", globalInitializerSteps.size());
+ log.info("Suite initializers count: {}", suiteInitializerSteps.size());
+ log.info("Scenario initializers count: {}", scenarioInitializerSteps.size());
+
if (log.isDebugEnabled()) {
String globalInitializers = globalInitializerSteps.stream().map(Object::getClass).map(Class::getName)
.collect(Collectors.joining(", "));
@@ -54,6 +60,11 @@ public class FineractInitializer implements InitializingBean {
Suite initializers: [{}]
Scenario initializers: [{}]
""", globalInitializers, suiteInitializers, scenarioInitializers);
+ } else {
+ // Always log the suite initializers at INFO since this is critical
+ String suiteInitializers = suiteInitializerSteps.stream().map(Object::getClass).map(Class::getName)
+ .collect(Collectors.joining(", "));
+ log.info("Suite initializers: [{}]", suiteInitializers);
}
}
@@ -65,7 +76,9 @@ public class FineractInitializer implements InitializingBean {
}
public void setupDefaultsForSuite() throws Exception {
+ log.info("=== setupDefaultsForSuite() called - {} suite initializers to execute ===", suiteInitializerSteps.size());
for (FineractSuiteInitializerStep initializerStep : suiteInitializerSteps) {
+ log.info("Executing suite initializer: {}", initializerStep.getClass().getName());
initializerStep.initializeForSuite();
}
businessDateHelper.setBusinessDateToday();
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java
index 20e8318071..0a98ddad8d 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java
@@ -18,10 +18,18 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
+import org.apache.fineract.client.models.ChargeData;
import org.apache.fineract.client.models.ChargeRequest;
import org.apache.fineract.client.models.PostChargesResponse;
-import org.apache.fineract.client.services.ChargesApi;
import org.apache.fineract.test.data.ChargeCalculationType;
import org.apache.fineract.test.data.ChargePaymentMode;
import org.apache.fineract.test.data.ChargeProductAppliesTo;
@@ -31,8 +39,8 @@ import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
+@Slf4j
@RequiredArgsConstructor
@Component
public class ChargeGlobalInitializerStep implements FineractGlobalInitializerStep {
@@ -78,137 +86,128 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT = ChargeCalculationType.PERCENTAGE_DISBURSEMENT_AMOUNT.value;
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST = ChargeCalculationType.PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST.value;
- private final ChargesApi chargesApi;
+ private final FineractFeignClient fineractClient;
@Override
public void initialize() throws Exception {
- // Loan - % late (overdue) fee
- ChargeRequest requestLoanPercentLate = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_PERCENTAGE_LATE_FEE,
- CHARGE_TIME_TYPE_OVERDUE_FEES, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, CHARGE_AMOUNT_OVERDUE_PERCENTAGE, true, true);
- Response<PostChargesResponse> responseLoanPercentLate = chargesApi.createCharge(requestLoanPercentLate).execute();
+ List<ChargeData> existingCharges = new ArrayList<>();
+ try {
+ existingCharges = fineractClient.charges().retrieveAllCharges(Map.of());
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing charges, will create them", e);
+ }
+
+ final List<ChargeData> charges = existingCharges;
+
+ PostChargesResponse responseLoanPercentLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
+ CHARGE_LOAN_PERCENTAGE_LATE_FEE, CHARGE_TIME_TYPE_OVERDUE_FEES, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
+ CHARGE_AMOUNT_OVERDUE_PERCENTAGE, true, true);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_LATE_CREATE_RESPONSE, responseLoanPercentLate);
- // Loan - % processing fee
- ChargeRequest requestLoanPercentProcessing = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_PERCENTAGE_PROCESSING_FEE,
- CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_AMOUNT_PERCENTAGE,
- true, false);
- Response<PostChargesResponse> responseLoanPercentProcessing = chargesApi.createCharge(requestLoanPercentProcessing).execute();
+ PostChargesResponse responseLoanPercentProcessing = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
+ CHARGE_LOAN_PERCENTAGE_PROCESSING_FEE, CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE,
+ CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_AMOUNT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_PROCESSING_CREATE_RESPONSE, responseLoanPercentProcessing);
- // Loan - fixed late (overdue) fee
- ChargeRequest requestLoanFixedLate = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_FIXED_LATE_FEE,
+ PostChargesResponse responseLoanFixedLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_FIXED_LATE_FEE,
CHARGE_TIME_TYPE_OVERDUE_FEES, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, true);
- Response<PostChargesResponse> responseLoanFixedLate = chargesApi.createCharge(requestLoanFixedLate).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_FIXED_LATE_CREATE_RESPONSE, responseLoanFixedLate);
- // Loan - fixed returned payment fee
- ChargeRequest requestLoanFixedReturnedPayment = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanFixedReturnedPayment = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_FIXED_RETURNED_PAYMENT_FEE, CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT,
CHARGE_AMOUNT_FLAT, true, false);
- Response<PostChargesResponse> responseLoanFixedReturnedPayment = chargesApi.createCharge(requestLoanFixedReturnedPayment).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_FIXED_RETURNED_PAYMENT_CREATE_RESPONSE, responseLoanFixedReturnedPayment);
- // Loan - snooze fee
- ChargeRequest requestLoanSnooze = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_SNOOZE_FEE,
+ PostChargesResponse responseLoanSnooze = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_SNOOZE_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
- Response<PostChargesResponse> responseLoanSnooze = chargesApi.createCharge(requestLoanSnooze).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_SNOOZE_FEE_CREATE_RESPONSE, responseLoanSnooze);
- // Loan - NSF fee
- ChargeRequest requestLoanNsf = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_NSF_FEE,
+ PostChargesResponse responseLoanNsf = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_NSF_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, true);
- Response<PostChargesResponse> responseLoanNsf = chargesApi.createCharge(requestLoanNsf).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_NSF_FEE_CREATE_RESPONSE, responseLoanNsf);
- // Loan - Disbursement % fee
- ChargeRequest requestLoanDisbursePercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_DISBURSEMENT_PERCENT_FEE,
- CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true,
- false);
- Response<PostChargesResponse> responseLoanDisbursePercent = chargesApi.createCharge(requestLoanDisbursePercent).execute();
+ PostChargesResponse responseLoanDisbursePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
+ CHARGE_LOAN_DISBURSEMENT_PERCENT_FEE, CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
+ CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE, responseLoanDisbursePercent);
- // Loan - Tranche Disbursement % fee
- ChargeRequest requestLoanTrancheDisbursePercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanTrancheDisbursePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_PERCENT_FEE, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true, false);
- Response<PostChargesResponse> responseLoanTrancheDisbursePercent = chargesApi.createCharge(requestLoanTrancheDisbursePercent)
- .execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE,
responseLoanTrancheDisbursePercent);
- // Loan - Installment % fee Amount + Interest
- final ChargeRequest requestLoanInstallmentPercentAmountPlusInterest = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanInstallmentPercentAmountPlusInterest = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT_PLUS_INTEREST, CHARGE_TIME_TYPE_INSTALLMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_INSTALLMENT_FEE_AMOUNT_PERCENTAGE, true, false);
- final Response<PostChargesResponse> responseLoanInstallmentPercentAmountPlusInterest = chargesApi
- .createCharge(requestLoanInstallmentPercentAmountPlusInterest).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_AMOUNT_PLUS_INTEREST_CREATE_RESPONSE,
responseLoanInstallmentPercentAmountPlusInterest);
- // Loan - % late (overdue) fee amount+interest
- ChargeRequest requestLoanPercentAmountPlusInterestLate = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanPercentAmountPlusInterestLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST, CHARGE_TIME_TYPE_OVERDUE_FEES,
CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_AMOUNT_OVERDUE_PERCENTAGE, true, true);
- Response<PostChargesResponse> responseLoanPercentAmountPlusInterestLate = chargesApi
- .createCharge(requestLoanPercentAmountPlusInterestLate).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_LATE_AMOUNT_PLUS_INTEREST_CREATE_RESPONSE,
responseLoanPercentAmountPlusInterestLate);
- // Client - fixed fee
- ChargeRequest requestClientFixed = defaultChargesRequest(CHARGE_APPLIES_TO_CLIENT, CHARGE_CLIENT_FIXED_FEE,
+ PostChargesResponse responseClientFixed = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_CLIENT, CHARGE_CLIENT_FIXED_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
- Response<PostChargesResponse> responseClientFixed = chargesApi.createCharge(requestClientFixed).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE, responseClientFixed);
- // Loan - Disbursement fixed fee
- ChargeRequest requestDisbursementCharge = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_DISBURSEMENT_CHARGE,
- CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
- Response<PostChargesResponse> responseDisbursementCharge = chargesApi.createCharge(requestDisbursementCharge).execute();
+ PostChargesResponse responseDisbursementCharge = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
+ CHARGE_DISBURSEMENT_CHARGE, CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE, responseDisbursementCharge);
- // Loan - Tranche Disbursement Charge (Flat)
- ChargeRequest requestTrancheDisbursementCharge = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseTrancheDisbursementCharge = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, 10.0,
true, false);
- Response<PostChargesResponse> responseTrancheDisbursementCharge = chargesApi.createCharge(requestTrancheDisbursementCharge)
- .execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE,
responseTrancheDisbursementCharge);
- // Loan - Tranche Disbursement Charge (%)
- ChargeRequest requestTrancheDisbursementChargePercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseTrancheDisbursementChargePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, 2.0, true, false);
- Response<PostChargesResponse> responseTrancheDisbursementChargePercent = chargesApi
- .createCharge(requestTrancheDisbursementChargePercent).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE,
responseTrancheDisbursementChargePercent);
- // Loan - Installment flat fee
- final ChargeRequest requestLoanInstallmentFlat = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_INSTALLMENT_FEE_FLAT,
- CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_INSTALLMENT_FEE_AMOUNT_FLAT, true, false);
- final Response<PostChargesResponse> responseLoanInstallmentFlat = chargesApi.createCharge(requestLoanInstallmentFlat).execute();
+ PostChargesResponse responseLoanInstallmentFlat = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
+ CHARGE_LOAN_INSTALLMENT_FEE_FLAT, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_FLAT,
+ CHARGE_INSTALLMENT_FEE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_FLAT_CREATE_RESPONSE, responseLoanInstallmentFlat);
- // Loan - Installment % fee Amount
- final ChargeRequest requestLoanInstallmentPercentAmount = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanInstallmentPercentAmount = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
CHARGE_INSTALLMENT_FEE_AMOUNT_PERCENTAGE, true, false);
- final Response<PostChargesResponse> responseLoanInstallmentPercentAmount = chargesApi
- .createCharge(requestLoanInstallmentPercentAmount).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_AMOUNT_CREATE_RESPONSE,
responseLoanInstallmentPercentAmount);
- // Loan - Installment % fee Interest
- final ChargeRequest requestLoanInstallmentPercentInterest = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
+ PostChargesResponse responseLoanInstallmentPercentInterest = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_INTEREST, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST,
CHARGE_AMOUNT_PERCENTAGE, true, false);
- final Response<PostChargesResponse> responseLoanInstallmentPercentInterest = chargesApi
- .createCharge(requestLoanInstallmentPercentInterest).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_INTEREST_CREATE_RESPONSE,
responseLoanInstallmentPercentInterest);
}
+ private PostChargesResponse createChargeIfNotExists(List<ChargeData> existingCharges, Enum<ChargeProductAppliesTo> appliesTo,
+ String name, Integer chargeTimeType, Integer chargeCalculationType, Double amount, Boolean isActive, Boolean isPenalty)
+ throws Exception {
+ ChargeRequest request = defaultChargesRequest(appliesTo, name, chargeTimeType, chargeCalculationType, amount, isActive, isPenalty);
+
+ try {
+ return ok(() -> fineractClient.charges().createCharge(request, Map.of()));
+ } catch (CallFailedRuntimeException e) {
+ if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
+ log.debug("Charge '{}' already exists, retrieving existing charge", name);
+ ChargeData existing = existingCharges.stream().filter(c -> name.equals(c.getName())).findFirst().orElse(null);
+ if (existing != null) {
+ PostChargesResponse response = new PostChargesResponse();
+ response.setResourceId(existing.getId());
+ return response;
+ }
+ }
+ throw e;
+ }
+ }
+
public static ChargeRequest defaultChargesRequest(Enum<ChargeProductAppliesTo> appliesTo, String name, Integer chargeTimeType,
Integer chargeCalculationType, Double amount, Boolean isActive, Boolean isPenalty) throws Exception {
ChargeRequest request = new ChargeRequest();
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CobBusinessStepInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CobBusinessStepInitializerStep.java
index b5f08f40eb..c4bee5fa87 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CobBusinessStepInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CobBusinessStepInitializerStep.java
@@ -29,7 +29,7 @@ public class CobBusinessStepInitializerStep implements FineractGlobalInitializer
private final WorkFlowJobHelper workFlowJobHelper;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
workFlowJobHelper.setWorkflowJobs();
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CodeGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CodeGlobalInitializerStep.java
index 9a2c9f5b3a..4e7ccc9190 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CodeGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CodeGlobalInitializerStep.java
@@ -18,19 +18,23 @@
*/
package org.apache.fineract.test.initializer.global;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.PostCodeValuesDataRequest;
import org.apache.fineract.client.models.PostCodesRequest;
import org.apache.fineract.client.models.PutCodeValuesDataRequest;
-import org.apache.fineract.client.services.CodeValuesApi;
-import org.apache.fineract.client.services.CodesApi;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -114,11 +118,10 @@ public class CodeGlobalInitializerStep implements FineractGlobalInitializerStep
public static final String CODE_VALUE_WRITE_OFF_REASON_TEST_2 = "Forgiven";
public static final String CODE_VALUE_WRITE_OFF_REASON_TEST_3 = "Test";
- private final CodesApi codesApi;
- private final CodeValuesApi codeValuesApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
createCodeNames();
createCodeValues();
}
@@ -267,9 +270,14 @@ public class CodeGlobalInitializerStep implements FineractGlobalInitializerStep
postCodeValuesDataRequest.position(position);
try {
- codeValuesApi.createCodeValue(codeId, postCodeValuesDataRequest).execute();
- } catch (IOException e) {
- throw new RuntimeException("Error while creating code value", e);
+ executeVoid(() -> fineractClient.codeValues().createCodeValue(codeId, postCodeValuesDataRequest, Map.of()));
+ log.info("Code value '{}' created successfully", name);
+ } catch (CallFailedRuntimeException e) {
+ if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
+ log.debug("Code value '{}' already exists, skipping creation", name);
+ return;
+ }
+ throw e;
}
});
}
@@ -282,11 +290,7 @@ public class CodeGlobalInitializerStep implements FineractGlobalInitializerStep
putCodeValuesDataRequest.name(name);
putCodeValuesDataRequest.position(position);
- try {
- codeValuesApi.updateCodeValue(codeId, (long) position, putCodeValuesDataRequest).execute();
- } catch (IOException e) {
- throw new RuntimeException("Error while updating code value", e);
- }
+ executeVoid(() -> fineractClient.codeValues().updateCodeValue(codeId, (long) position, putCodeValuesDataRequest, Map.of()));
});
}
@@ -301,11 +305,13 @@ public class CodeGlobalInitializerStep implements FineractGlobalInitializerStep
codesNameList.add(CODE_NAME_ACTIVE_DUTY_TAG);
codesNameList.forEach(codeName -> {
- PostCodesRequest postCodesRequest = new PostCodesRequest();
try {
- codesApi.createCode(postCodesRequest.name(codeName)).execute();
- } catch (IOException e) {
- throw new RuntimeException("Error while creating code", e);
+ fineractClient.codes().retrieveCodeByName(codeName);
+ // Code already exists, skip creation
+ } catch (Exception e) {
+ // Code doesn't exist, create it
+ PostCodesRequest postCodesRequest = new PostCodesRequest();
+ executeVoid(() -> fineractClient.codes().createCode(postCodesRequest.name(codeName), Map.of()));
}
});
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CurrencyGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CurrencyGlobalInitializerStep.java
index ad8a2d52bf..4b8f73a52b 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CurrencyGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CurrencyGlobalInitializerStep.java
@@ -18,11 +18,14 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.CurrencyUpdateRequest;
-import org.apache.fineract.client.services.CurrencyApi;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.core.Ordered;
@@ -36,12 +39,12 @@ public class CurrencyGlobalInitializerStep implements FineractGlobalInitializerS
public static final List<String> CURRENCIES = Arrays.asList("EUR", "USD");
- private final CurrencyApi currencyApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
var request = new CurrencyUpdateRequest();
- var response = currencyApi.updateCurrencies(request.currencies(CURRENCIES)).execute();
+ var response = ok(() -> fineractClient.currency().updateCurrencies(request.currencies(CURRENCIES), Map.of()));
TestContext.INSTANCE.set(TestContextKey.PUT_CURRENCIES_RESPONSE, response);
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DatatablesGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DatatablesGlobalInitializerStep.java
index a7237213da..f76d5952a3 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DatatablesGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DatatablesGlobalInitializerStep.java
@@ -18,16 +18,21 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.PostColumnHeaderData;
import org.apache.fineract.client.models.PostDataTablesRequest;
-import org.apache.fineract.client.services.DataTablesApi;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -71,10 +76,10 @@ public class DatatablesGlobalInitializerStep implements FineractGlobalInitialize
public static final String DATA_TABLE_3_COLUMN_5_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_5_CODE = "active_duty_tag";
- private final DataTablesApi dataTablesApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
// autopay
PostColumnHeaderData column1 = new PostColumnHeaderData();
column1.name(DATA_TABLE_1_COLUMN_1_NAME);
@@ -97,7 +102,7 @@ public class DatatablesGlobalInitializerStep implements FineractGlobalInitialize
postDataTablesRequest.multiRow(true);
postDataTablesRequest.columns(columns);
- dataTablesApi.createDatatable(postDataTablesRequest).execute();
+ createDatatableIdempotent(postDataTablesRequest);
// scheduled payments
PostColumnHeaderData columnScheduled1 = new PostColumnHeaderData();
@@ -134,7 +139,7 @@ public class DatatablesGlobalInitializerStep implements FineractGlobalInitialize
postDataTablesRequestScheduled.multiRow(true);
postDataTablesRequestScheduled.columns(columnsScheduled);
- dataTablesApi.createDatatable(postDataTablesRequestScheduled).execute();
+ createDatatableIdempotent(postDataTablesRequestScheduled);
// 3 tags
PostColumnHeaderData column3Tags1 = new PostColumnHeaderData();
@@ -181,6 +186,16 @@ public class DatatablesGlobalInitializerStep implements FineractGlobalInitialize
postDataTablesRequest3Tags.multiRow(false);
postDataTablesRequest3Tags.columns(columns3Tags);
- dataTablesApi.createDatatable(postDataTablesRequest3Tags).execute();
+ createDatatableIdempotent(postDataTablesRequest3Tags);
+ }
+
+ private void createDatatableIdempotent(PostDataTablesRequest datatableRequest) {
+ String datatableName = datatableRequest.getDatatableName();
+ try {
+ fineractClient.dataTables().getDatatable(datatableName, Map.of());
+ } catch (Exception e) {
+ log.debug("Datatable '{}' does not exist yet, will create it", datatableName);
+ executeVoid(() -> fineractClient.dataTables().createDatatable(datatableRequest, Map.of()));
+ }
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DelinquencyGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DelinquencyGlobalInitializerStep.java
index 9231bee606..f022a26a94 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DelinquencyGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/DelinquencyGlobalInitializerStep.java
@@ -18,18 +18,26 @@
*/
package org.apache.fineract.test.initializer.global;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.DelinquencyBucketData;
import org.apache.fineract.client.models.DelinquencyBucketRequest;
+import org.apache.fineract.client.models.DelinquencyRangeData;
import org.apache.fineract.client.models.DelinquencyRangeRequest;
-import org.apache.fineract.client.services.DelinquencyRangeAndBucketsManagementApi;
+import org.apache.fineract.client.models.PostDelinquencyRangeResponse;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -39,18 +47,38 @@ public class DelinquencyGlobalInitializerStep implements FineractGlobalInitializ
public static final List<Integer> DEFAULT_DELINQUENCY_RANGES = Arrays.asList(1, 3, 30, 60, 90, 120, 150, 180, 240);
public static final String DEFAULT_DELINQUENCY_BUCKET_NAME = "Default delinquency bucket";
- private final DelinquencyRangeAndBucketsManagementApi delinquencyApi;
+ private final FineractFeignClient fineractClient;
+
+ private final List<Long> createdRangeIds = new ArrayList<>();
@Override
- public void initialize() throws Exception {
+ public void initialize() {
setDefaultDelinquencyRanges();
setDefaultDelinquencyBucket();
}
- public void setDefaultDelinquencyRanges() throws IOException {
+ public void setDefaultDelinquencyRanges() {
+ List<DelinquencyRangeData> existingRanges;
+ try {
+ existingRanges = fineractClient.delinquencyRangeAndBucketsManagement().getDelinquencyRanges(Map.of());
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing delinquency ranges, will create them", e);
+ existingRanges = new ArrayList<>();
+ }
+
for (int i = 0; i < DEFAULT_DELINQUENCY_RANGES.size() - 1; i++) {
+ String classification = "Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(i).toString();
+
+ DelinquencyRangeData existingRange = existingRanges.stream().filter(r -> classification.equals(r.getClassification()))
+ .findFirst().orElse(null);
+
+ if (existingRange != null) {
+ createdRangeIds.add(existingRange.getId());
+ continue;
+ }
+
DelinquencyRangeRequest postDelinquencyRangeRequest = new DelinquencyRangeRequest();
- postDelinquencyRangeRequest.classification("Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(i).toString());
+ postDelinquencyRangeRequest.classification(classification);
postDelinquencyRangeRequest.locale(DEFAULT_LOCALE);
if (DEFAULT_DELINQUENCY_RANGES.get(i) == 1) {
postDelinquencyRangeRequest.minimumAgeDays(1);
@@ -60,30 +88,49 @@ public class DelinquencyGlobalInitializerStep implements FineractGlobalInitializ
postDelinquencyRangeRequest.maximumAgeDays(DEFAULT_DELINQUENCY_RANGES.get(i + 1));
}
- delinquencyApi.createDelinquencyRange(postDelinquencyRangeRequest).execute();
+ PostDelinquencyRangeResponse response = ok(() -> fineractClient.delinquencyRangeAndBucketsManagement()
+ .createDelinquencyRange(postDelinquencyRangeRequest, Map.of()));
+ createdRangeIds.add(response.getResourceId());
+ }
+
+ String lastClassification = "Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(DEFAULT_DELINQUENCY_RANGES.size() - 1).toString();
+ DelinquencyRangeData existingLastRange = existingRanges.stream().filter(r -> lastClassification.equals(r.getClassification()))
+ .findFirst().orElse(null);
+
+ if (existingLastRange != null) {
+ createdRangeIds.add(existingLastRange.getId());
+ return;
}
DelinquencyRangeRequest lastRange = new DelinquencyRangeRequest();
- lastRange.classification("Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(DEFAULT_DELINQUENCY_RANGES.size() - 1).toString());
+ lastRange.classification(lastClassification);
lastRange.locale(DEFAULT_LOCALE);
lastRange.minimumAgeDays(DEFAULT_DELINQUENCY_RANGES.get(DEFAULT_DELINQUENCY_RANGES.size() - 1) + 1);
lastRange.maximumAgeDays(null);
- delinquencyApi.createDelinquencyRange(lastRange).execute();
+ PostDelinquencyRangeResponse lastResponse = ok(
+ () -> fineractClient.delinquencyRangeAndBucketsManagement().createDelinquencyRange(lastRange, Map.of()));
+ createdRangeIds.add(lastResponse.getResourceId());
}
- public void setDefaultDelinquencyBucket() throws IOException {
- List<Long> rangesNr = new ArrayList<>();
+ public void setDefaultDelinquencyBucket() {
+ try {
+ List<DelinquencyBucketData> existingBuckets = fineractClient.delinquencyRangeAndBucketsManagement()
+ .getDelinquencyBuckets(Map.of());
+ boolean bucketExists = existingBuckets.stream().anyMatch(b -> DEFAULT_DELINQUENCY_BUCKET_NAME.equals(b.getName()));
- for (int i = 1; i < DEFAULT_DELINQUENCY_RANGES.size() + 1; i++) {
- rangesNr.add((long) DEFAULT_DELINQUENCY_RANGES.indexOf(DEFAULT_DELINQUENCY_RANGES.get(i - 1)));
+ if (bucketExists) {
+ return;
+ }
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing delinquency buckets, will create default bucket", e);
}
- rangesNr.add((long) DEFAULT_DELINQUENCY_RANGES.size());
DelinquencyBucketRequest postDelinquencyBucketRequest = new DelinquencyBucketRequest();
postDelinquencyBucketRequest.name(DEFAULT_DELINQUENCY_BUCKET_NAME);
- postDelinquencyBucketRequest.ranges(rangesNr);
+ postDelinquencyBucketRequest.ranges(createdRangeIds);
- delinquencyApi.createDelinquencyBucket(postDelinquencyBucketRequest).execute();
+ executeVoid(() -> fineractClient.delinquencyRangeAndBucketsManagement().createDelinquencyBucket(postDelinquencyBucketRequest,
+ Map.of()));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FinancialActivityMappingGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FinancialActivityMappingGlobalInitializerStep.java
index 66885e39de..f13d754d5d 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FinancialActivityMappingGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FinancialActivityMappingGlobalInitializerStep.java
@@ -18,11 +18,17 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.PostFinancialActivityAccountsRequest;
-import org.apache.fineract.client.services.MappingFinancialActivitiesToAccountsApi;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
public class FinancialActivityMappingGlobalInitializerStep implements FineractGlobalInitializerStep {
@@ -30,13 +36,22 @@ public class FinancialActivityMappingGlobalInitializerStep implements FineractGl
public static final Long FINANCIAL_ACTIVITY_ID_ASSET_TRANSFER = 100L;
public static final Long GL_ACCOUNT_ID_ASSET_TRANSFER = 21L;
- private final MappingFinancialActivitiesToAccountsApi mappingFinancialActivitiesToAccountsApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
-
+ public void initialize() {
PostFinancialActivityAccountsRequest request = new PostFinancialActivityAccountsRequest()
.financialActivityId(FINANCIAL_ACTIVITY_ID_ASSET_TRANSFER).glAccountId(GL_ACCOUNT_ID_ASSET_TRANSFER);
- mappingFinancialActivitiesToAccountsApi.createGLAccount(request).execute();
+
+ try {
+ executeVoid(() -> fineractClient.mappingFinancialActivitiesToAccounts().createGLAccount(request, Map.of()));
+ log.info("Financial activity mapping created successfully");
+ } catch (CallFailedRuntimeException e) {
+ if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
+ log.debug("Financial activity mapping already exists, skipping creation");
+ return;
+ }
+ throw e;
+ }
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FundGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FundGlobalInitializerStep.java
index c9c04f2651..d67a1b9900 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FundGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FundGlobalInitializerStep.java
@@ -18,16 +18,21 @@
*/
package org.apache.fineract.test.initializer.global;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.FundData;
import org.apache.fineract.client.models.FundRequest;
-import org.apache.fineract.client.services.FundsApi;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@Component
@RequiredArgsConstructor
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -36,21 +41,30 @@ public class FundGlobalInitializerStep implements FineractGlobalInitializerStep
public static final String FUNDS_LENDER_A = "Lender A";
public static final String FUNDS_LENDER_B = "Lender B";
- private final FundsApi fundsApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
+ List<FundData> existingFunds = new ArrayList<>();
+ try {
+ existingFunds = fineractClient.funds().retrieveFunds(Map.of());
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing funds, will create them", e);
+ }
+
+ final List<FundData> funds = existingFunds;
List<String> fundNames = new ArrayList<>();
fundNames.add(FUNDS_LENDER_A);
fundNames.add(FUNDS_LENDER_B);
fundNames.forEach(name -> {
+ boolean fundExists = funds.stream().anyMatch(f -> name.equals(f.getName()));
+ if (fundExists) {
+ return;
+ }
+
FundRequest postFundsRequest = new FundRequest();
postFundsRequest.name(name);
- try {
- fundsApi.createFund(postFundsRequest).execute();
- } catch (IOException e) {
- throw new RuntimeException("Error while creating fund", e);
- }
+ executeVoid(() -> fineractClient.funds().createFund(postFundsRequest, Map.of()));
});
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GLGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GLGlobalInitializerStep.java
index e0d20e5e64..8be948b3fe 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GLGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GLGlobalInitializerStep.java
@@ -18,9 +18,16 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetGLAccountsResponse;
import org.apache.fineract.client.models.PostGLAccountsRequest;
-import org.apache.fineract.client.services.GeneralLedgerAccountApi;
import org.apache.fineract.test.data.GLAType;
import org.apache.fineract.test.data.GLAUsage;
import org.apache.fineract.test.factory.GLAccountRequestFactory;
@@ -28,6 +35,7 @@ import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -87,82 +95,52 @@ public class GLGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String GLA_GL_CODE_23 = "450280";
public static final String GLA_GL_CODE_24 = "450281";
- private final GeneralLedgerAccountApi glaApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
+ public void initialize() {
+ List<GetGLAccountsResponse> existingAccounts = new ArrayList<>();
+ try {
+ existingAccounts = fineractClient.generalLedgerAccount().retrieveAllAccountsUniversal(Map.of());
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing GL accounts, will create them", e);
+ }
+
+ final List<GetGLAccountsResponse> accounts = existingAccounts;
+
+ createGLAccountIfNotExists(accounts, GLA_NAME_1, GLA_GL_CODE_1, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_2, GLA_GL_CODE_2, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_3, GLA_GL_CODE_3, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_4, GLA_GL_CODE_4, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_5, GLA_GL_CODE_5, GLA_TYPE_LIABILITY);
+ createGLAccountIfNotExists(accounts, GLA_NAME_6, GLA_GL_CODE_6, GLA_TYPE_LIABILITY);
+ createGLAccountIfNotExists(accounts, GLA_NAME_7, GLA_GL_CODE_7, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_8, GLA_GL_CODE_8, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_9, GLA_GL_CODE_9, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_10, GLA_GL_CODE_10, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_11, GLA_GL_CODE_11, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_12, GLA_GL_CODE_12, GLA_TYPE_EXPENSE);
+ createGLAccountIfNotExists(accounts, GLA_NAME_13, GLA_GL_CODE_13, GLA_TYPE_EXPENSE);
+ createGLAccountIfNotExists(accounts, GLA_NAME_14, GLA_GL_CODE_14, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_15, GLA_GL_CODE_15, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_16, GLA_GL_CODE_16, GLA_TYPE_EXPENSE);
+ createGLAccountIfNotExists(accounts, GLA_NAME_17, GLA_GL_CODE_17, GLA_TYPE_LIABILITY);
+ createGLAccountIfNotExists(accounts, GLA_NAME_18, GLA_GL_CODE_18, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_19, GLA_GL_CODE_19, GLA_TYPE_EXPENSE);
+ createGLAccountIfNotExists(accounts, GLA_NAME_20, GLA_GL_CODE_20, GLA_TYPE_INCOME);
+ createGLAccountIfNotExists(accounts, GLA_NAME_21, GLA_GL_CODE_21, GLA_TYPE_ASSET);
+ createGLAccountIfNotExists(accounts, GLA_NAME_22, GLA_GL_CODE_22, GLA_TYPE_LIABILITY);
+ createGLAccountIfNotExists(accounts, GLA_NAME_23, GLA_GL_CODE_23, GLA_TYPE_EXPENSE);
+ createGLAccountIfNotExists(accounts, GLA_NAME_24, GLA_GL_CODE_24, GLA_TYPE_INCOME);
+ }
+
+ private void createGLAccountIfNotExists(List<GetGLAccountsResponse> existingAccounts, String name, String glCode, Integer type) {
+ boolean accountExists = existingAccounts.stream().anyMatch(a -> glCode.equals(a.getGlCode()));
+ if (accountExists) {
+ return;
+ }
- PostGLAccountsRequest postGLAccountsRequest1 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_1, GLA_GL_CODE_1,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest1).execute();
- PostGLAccountsRequest postGLAccountsRequest2 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_2, GLA_GL_CODE_2,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest2).execute();
- PostGLAccountsRequest postGLAccountsRequest3 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_3, GLA_GL_CODE_3,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest3).execute();
- PostGLAccountsRequest postGLAccountsRequest4 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_4, GLA_GL_CODE_4,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest4).execute();
- PostGLAccountsRequest postGLAccountsRequest5 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_5, GLA_GL_CODE_5,
- GLA_TYPE_LIABILITY, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest5).execute();
- PostGLAccountsRequest postGLAccountsRequest6 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_6, GLA_GL_CODE_6,
- GLA_TYPE_LIABILITY, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest6).execute();
- PostGLAccountsRequest postGLAccountsRequest7 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_7, GLA_GL_CODE_7,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest7).execute();
- PostGLAccountsRequest postGLAccountsRequest8 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_8, GLA_GL_CODE_8,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest8).execute();
- PostGLAccountsRequest postGLAccountsRequest9 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_9, GLA_GL_CODE_9,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest9).execute();
- PostGLAccountsRequest postGLAccountsRequest10 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_10, GLA_GL_CODE_10,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest10).execute();
- PostGLAccountsRequest postGLAccountsRequest11 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_11, GLA_GL_CODE_11,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest11).execute();
- PostGLAccountsRequest postGLAccountsRequest12 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_12, GLA_GL_CODE_12,
- GLA_TYPE_EXPENSE, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest12).execute();
- PostGLAccountsRequest postGLAccountsRequest13 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_13, GLA_GL_CODE_13,
- GLA_TYPE_EXPENSE, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest13).execute();
- PostGLAccountsRequest postGLAccountsRequest14 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_14, GLA_GL_CODE_14,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest14).execute();
- PostGLAccountsRequest postGLAccountsRequest15 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_15, GLA_GL_CODE_15,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest15).execute();
- PostGLAccountsRequest postGLAccountsRequest16 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_16, GLA_GL_CODE_16,
- GLA_TYPE_EXPENSE, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest16).execute();
- PostGLAccountsRequest postGLAccountsRequest17 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_17, GLA_GL_CODE_17,
- GLA_TYPE_LIABILITY, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest17).execute();
- PostGLAccountsRequest postGLAccountsRequest18 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_18, GLA_GL_CODE_18,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest18).execute();
- PostGLAccountsRequest postGLAccountsRequest19 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_19, GLA_GL_CODE_19,
- GLA_TYPE_EXPENSE, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest19).execute();
- PostGLAccountsRequest postGLAccountsRequest20 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_20, GLA_GL_CODE_20,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest20).execute();
- PostGLAccountsRequest postGLAccountsRequest21 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_21, GLA_GL_CODE_21,
- GLA_TYPE_ASSET, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest21).execute();
- PostGLAccountsRequest postGLAccountsRequest22 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_22, GLA_GL_CODE_22,
- GLA_TYPE_LIABILITY, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest22).execute();
- PostGLAccountsRequest postGLAccountsRequest23 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_23, GLA_GL_CODE_23,
- GLA_TYPE_EXPENSE, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest23).execute();
- PostGLAccountsRequest postGLAccountsRequest24 = GLAccountRequestFactory.defaultGLAccountRequest(GLA_NAME_24, GLA_GL_CODE_24,
- GLA_TYPE_INCOME, GLA_USAGE_DETAIL, true);
- glaApi.createGLAccount1(postGLAccountsRequest24).execute();
+ PostGLAccountsRequest request = GLAccountRequestFactory.defaultGLAccountRequest(name, glCode, type, GLA_USAGE_DETAIL, true);
+ executeVoid(() -> fineractClient.generalLedgerAccount().createGLAccount1(request, Map.of()));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
index a9bbdca24e..b535f0fddf 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.apache.fineract.client.models.LoanProductRelatedDetail.DaysInYearCustomStrategyEnum.FEB_29_PERIOD_ONLY;
import static org.apache.fineract.test.data.ChargeOffBehaviour.ZERO_INTEREST;
import static org.apache.fineract.test.data.TransactionProcessingStrategyCode.ADVANCED_PAYMENT_ALLOCATION;
@@ -33,12 +34,16 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.AdvancedPaymentData;
import org.apache.fineract.client.models.AllowAttributeOverrides;
import org.apache.fineract.client.models.CreditAllocationData;
import org.apache.fineract.client.models.CreditAllocationOrder;
+import org.apache.fineract.client.models.GetLoanProductsResponse;
import org.apache.fineract.client.models.LoanProductChargeData;
import org.apache.fineract.client.models.LoanProductPaymentAllocationRule;
import org.apache.fineract.client.models.PaymentAllocationOrder;
@@ -46,7 +51,6 @@ import org.apache.fineract.client.models.PostClassificationToIncomeAccountMappin
import org.apache.fineract.client.models.PostLoanProductsRequest;
import org.apache.fineract.client.models.PostLoanProductsResponse;
import org.apache.fineract.client.models.PostWriteOffReasonToExpenseAccountMappings;
-import org.apache.fineract.client.services.LoanProductsApi;
import org.apache.fineract.test.data.AdvancePaymentsAdjustmentType;
import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.data.DaysInMonthType;
@@ -67,13 +71,13 @@ import org.apache.fineract.test.helper.CodeHelper;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
+@Slf4j
@RequiredArgsConstructor
@Component
public class LoanProductGlobalInitializerStep implements FineractGlobalInitializerStep {
- private final LoanProductsApi loanProductsApi;
+ private final FineractFeignClient fineractClient;
private final LoanProductsRequestFactory loanProductsRequestFactory;
private final CodeHelper codeHelper;
private final CodeValueResolver codeValueResolver;
@@ -83,7 +87,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
// LP1
String name = DefaultLoanProduct.LP1.getName();
PostLoanProductsRequest loanProductsRequest = loanProductsRequestFactory.defaultLoanProductsRequestLP1().name(name);
- Response<PostLoanProductsResponse> response = loanProductsApi.createLoanProduct(loanProductsRequest).execute();
+ PostLoanProductsResponse response = createLoanProductIdempotent(loanProductsRequest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1, response);
// LP1 product with due date and overdue date for repayment in config
@@ -92,7 +96,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(DefaultLoanProduct.LP1_DUE_DATE.getName())//
.dueDaysForRepaymentEvent(3)//
.overDueDaysForRepaymentEvent(3);//
- Response<PostLoanProductsResponse> responseDueDate = loanProductsApi.createLoanProduct(loanProductsRequestDueDate).execute();
+ PostLoanProductsResponse responseDueDate = createLoanProductIdempotent(loanProductsRequestDueDate);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_DUE_DATE, responseDueDate);
// LP1 with 12% FLAT interest
@@ -100,8 +104,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name2 = DefaultLoanProduct.LP1_INTEREST_FLAT.getName();
PostLoanProductsRequest loanProductsRequestInterestFlat = loanProductsRequestFactory.defaultLoanProductsRequestLP1InterestFlat()
.name(name2);
- Response<PostLoanProductsResponse> responseInterestFlat = loanProductsApi.createLoanProduct(loanProductsRequestInterestFlat)
- .execute();
+ PostLoanProductsResponse responseInterestFlat = createLoanProductIdempotent(loanProductsRequestInterestFlat);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT, responseInterestFlat);
// LP1 with 12% DECLINING BALANCE interest, interest period: Same as payment period
@@ -109,8 +112,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name3 = DefaultLoanProduct.LP1_INTEREST_DECLINING_BALANCE_PERIOD_SAME_AS_PAYMENT.getName();
PostLoanProductsRequest loanProductsRequestInterestDecliningPeriodSameAsPayment = loanProductsRequestFactory
.defaultLoanProductsRequestLP1InterestDeclining().name(name3);
- Response<PostLoanProductsResponse> responseInterestDecliningPeriodSameAsPayment = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningPeriodSameAsPayment).execute();
+ PostLoanProductsResponse responseInterestDecliningPeriodSameAsPayment = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningPeriodSameAsPayment);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_PERIOD_SAME_AS_PAYMENT,
responseInterestDecliningPeriodSameAsPayment);
@@ -120,8 +123,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
PostLoanProductsRequest loanProductsRequestInterestDecliningPeriodDaily = loanProductsRequestFactory
.defaultLoanProductsRequestLP1InterestDeclining().name(name4)
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value).allowPartialPeriodInterestCalcualtion(false);
- Response<PostLoanProductsResponse> responseInterestDecliningPeriodDaily = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningPeriodDaily).execute();
+ PostLoanProductsResponse responseInterestDecliningPeriodDaily = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningPeriodDaily);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_PERIOD_DAILY,
responseInterestDecliningPeriodDaily);
@@ -131,8 +134,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name5 = DefaultLoanProduct.LP1_1MONTH_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_MONTHLY.getName();
PostLoanProductsRequest loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingMonthly = loanProductsRequestFactory
.defaultLoanProductsRequestLP11MonthInterestDecliningBalanceDailyRecalculationCompoundingMonthly().name(name5);
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceDailyRecalculationCompoundingMonthly = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingMonthly).execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceDailyRecalculationCompoundingMonthly = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingMonthly);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_1MONTH_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_MONTHLY,
responseInterestDecliningBalanceDailyRecalculationCompoundingMonthly);
@@ -143,8 +146,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name6 = DefaultLoanProduct.LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_NONE.getName();
PostLoanProductsRequest loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNone = loanProductsRequestFactory
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone().name(name6);
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceDailyRecalculationCompoundingNone = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNone).execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceDailyRecalculationCompoundingNone = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNone);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_NONE,
responseInterestDecliningBalanceDailyRecalculationCompoundingNone);
@@ -158,10 +161,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
.name(name7)//
.rescheduleStrategyMethod(AdvancePaymentsAdjustmentType.REDUCE_NUMBER_OF_INSTALLMENTS.value);//
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleReduceNrInstallments = loanProductsApi
- .createLoanProduct(
- loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleReduceNrInstallments)
- .execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleReduceNrInstallments = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleReduceNrInstallments);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_NONE_RESCHEDULE_REDUCE_NR_INSTALLMENTS,
responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleReduceNrInstallments);
@@ -175,10 +176,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
.name(name8)//
.rescheduleStrategyMethod(AdvancePaymentsAdjustmentType.RESCHEDULE_NEXT_REPAYMENTS.value);//
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleRescheduleNextRepayments = loanProductsApi
- .createLoanProduct(
- loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleRescheduleNextRepayments)
- .execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleRescheduleNextRepayments = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleRescheduleNextRepayments);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_NONE_RESCHEDULE_NEXT_REPAYMENTS,
responseInterestDecliningBalanceDailyRecalculationCompoundingNoneRescheduleRescheduleNextRepayments);
@@ -191,8 +190,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone()//
.name(name9)//
.recalculationRestFrequencyType(RecalculationRestFrequencyType.SAME_AS_REPAYMENT.value);//
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceDailyRecalculationSameAsRepaymentCompoundingNone = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningBalanceDailyRecalculationSameAsRepaymentCompoundingNone).execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceDailyRecalculationSameAsRepaymentCompoundingNone = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceDailyRecalculationSameAsRepaymentCompoundingNone);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_SAME_AS_REPAYMENT_COMPOUNDING_NONE,
responseInterestDecliningBalanceDailyRecalculationSameAsRepaymentCompoundingNone);
@@ -213,10 +212,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowPartialPeriodInterestCalcualtion(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseInterestDecliningBalanceSaRRecalculationSameAsRepaymentCompoundingNoneMultiDisbursement = loanProductsApi
- .createLoanProduct(
- loanProductsRequestInterestDecliningBalanceSaRRecalculationSameAsRepaymentCompoundingNoneMultiDisbursement)
- .execute();
+ PostLoanProductsResponse responseInterestDecliningBalanceSaRRecalculationSameAsRepaymentCompoundingNoneMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningBalanceSaRRecalculationSameAsRepaymentCompoundingNoneMultiDisbursement);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_SAR_RECALCULATION_SAME_AS_REPAYMENT_COMPOUNDING_NONE_MULTI_DISBURSEMENT,
responseInterestDecliningBalanceSaRRecalculationSameAsRepaymentCompoundingNoneMultiDisbursement);
@@ -229,8 +226,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name11)//
.transactionProcessingStrategyCode(
TransactionProcessingStrategyCode.DUE_PENALTY_FEE_INTEREST_PRINCIPAL_IN_ADVANCE_PRINCIPAL_PENALTY_FEE_INTEREST.value);//
- Response<PostLoanProductsResponse> responseDueInAdvance = loanProductsApi.createLoanProduct(loanProductsRequestDueInAdvance)
- .execute();
+ PostLoanProductsResponse responseDueInAdvance = createLoanProductIdempotent(loanProductsRequestDueInAdvance);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE,
responseDueInAdvance);
@@ -243,8 +239,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name12)//
.transactionProcessingStrategyCode(
TransactionProcessingStrategyCode.DUE_PENALTY_FEE_INTEREST_PRINCIPAL_IN_ADVANCE_PRINCIPAL_PENALTY_FEE_INTEREST.value);//
- Response<PostLoanProductsResponse> responseDueInAdvanceInterestFlat = loanProductsApi
- .createLoanProduct(loanProductsRequestDueInAdvanceInterestFlat).execute();
+ PostLoanProductsResponse responseDueInAdvanceInterestFlat = createLoanProductIdempotent(
+ loanProductsRequestDueInAdvanceInterestFlat);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE_INTEREST_FLAT,
responseDueInAdvanceInterestFlat);
@@ -255,8 +251,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(DefaultLoanProduct.LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE.getName())//
.transactionProcessingStrategyCode(
TransactionProcessingStrategyCode.DUE_PENALTY_INTEREST_PRINCIPAL_FEE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE.value);//
- Response<PostLoanProductsResponse> responseDueInAdvance2 = loanProductsApi.createLoanProduct(loanProductsRequestDueInAdvance2)
- .execute();
+ PostLoanProductsResponse responseDueInAdvance2 = createLoanProductIdempotent(loanProductsRequestDueInAdvance2);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE,
responseDueInAdvance2);
@@ -269,8 +264,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(DefaultLoanProduct.LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE_INTEREST_FLAT.getName())//
.transactionProcessingStrategyCode(
TransactionProcessingStrategyCode.DUE_PENALTY_INTEREST_PRINCIPAL_FEE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE.value);//
- Response<PostLoanProductsResponse> responseDueInAdvanceInterestFlat2 = loanProductsApi
- .createLoanProduct(loanProductsRequestDueInAdvanceInterestFlat2).execute();
+ PostLoanProductsResponse responseDueInAdvanceInterestFlat2 = createLoanProductIdempotent(
+ loanProductsRequestDueInAdvanceInterestFlat2);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_PAYMENT_STRATEGY_DUE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE_INTEREST_FLAT,
responseDueInAdvanceInterestFlat2);
@@ -284,8 +279,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestFlat()//
.name(name13)//
.charges(charges);//
- Response<PostLoanProductsResponse> responseInterestFlatOverdueFeeAmount = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatOverdueFeeAmount).execute();
+ PostLoanProductsResponse responseInterestFlatOverdueFeeAmount = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatOverdueFeeAmount);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_OVERDUE_FROM_AMOUNT,
responseInterestFlatOverdueFeeAmount);
@@ -298,8 +293,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestFlat()//
.name(name14)//
.charges(chargesInterest);//
- Response<PostLoanProductsResponse> responseInterestFlatOverdueFeeAmountInterest = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatOverdueFeeAmountInterest).execute();
+ PostLoanProductsResponse responseInterestFlatOverdueFeeAmountInterest = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatOverdueFeeAmountInterest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_OVERDUE_FROM_AMOUNT_INTEREST,
responseInterestFlatOverdueFeeAmountInterest);
@@ -309,8 +304,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
PostLoanProductsRequest loanProductsRequestDownPayment = loanProductsRequestFactory.defaultLoanProductsRequestLP2()//
.name(name15)//
.enableAutoRepaymentForDownPayment(false);//
- Response<PostLoanProductsResponse> responseDownPayment = loanProductsApi.createLoanProduct(loanProductsRequestDownPayment)
- .execute();
+ PostLoanProductsResponse responseDownPayment = createLoanProductIdempotent(loanProductsRequestDownPayment);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT, responseDownPayment);
// LP2 with Down-payment+autopayment
@@ -318,8 +312,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name16 = DefaultLoanProduct.LP2_DOWNPAYMENT_AUTO.getName();
PostLoanProductsRequest loanProductsRequestDownPaymentAuto = loanProductsRequestFactory.defaultLoanProductsRequestLP2()
.name(name16);
- Response<PostLoanProductsResponse> responseDownPaymentAuto = loanProductsApi.createLoanProduct(loanProductsRequestDownPaymentAuto)
- .execute();
+ PostLoanProductsResponse responseDownPaymentAuto = createLoanProductIdempotent(loanProductsRequestDownPaymentAuto);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_AUTO, responseDownPaymentAuto);
// LP2 with Down-payment+autopayment + advanced payment allocation
@@ -335,8 +328,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocation = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAutoAdvPaymentAllocation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocation = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAutoAdvPaymentAllocation);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_AUTO_ADVANCED_PAYMENT_ALLOCATION,
responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocation);
@@ -354,8 +347,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPaymentAllocation = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPaymentAllocation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPaymentAllocation = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPaymentAllocation);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADVANCED_PAYMENT_ALLOCATION,
responseLoanProductsRequestDownPaymentAdvPaymentAllocation);
@@ -366,8 +359,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP2InterestFlat()//
.name(name18)//
.enableAutoRepaymentForDownPayment(false);//
- Response<PostLoanProductsResponse> responseDownPaymentInterest = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentInterest).execute();
+ PostLoanProductsResponse responseDownPaymentInterest = createLoanProductIdempotent(loanProductsRequestDownPaymentInterest);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_INTEREST, responseDownPaymentInterest);
// LP2 with Down-payment and interest
@@ -375,8 +367,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
String name19 = DefaultLoanProduct.LP2_DOWNPAYMENT_INTEREST_AUTO.getName();
PostLoanProductsRequest loanProductsRequestDownPaymentInterestAuto = loanProductsRequestFactory
.defaultLoanProductsRequestLP2InterestFlat().name(name19);
- Response<PostLoanProductsResponse> responseDownPaymentInterestAuto = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentInterestAuto).execute();
+ PostLoanProductsResponse responseDownPaymentInterestAuto = createLoanProductIdempotent(loanProductsRequestDownPaymentInterestAuto);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_INTEREST_AUTO,
responseDownPaymentInterestAuto);
@@ -396,8 +387,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADVANCED_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE,
responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanSchedule);
@@ -418,8 +409,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleVertical = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleVertical).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleVertical = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleVertical);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADVANCED_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_VERTICAL,
responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleVertical);
@@ -443,8 +434,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleInstLvlDelinquency = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleInstLvlDelinquency).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleInstLvlDelinquency = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleInstLvlDelinquency);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADVANCED_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_INSTALLMENT_LEVEL_DELINQUENCY,
responseLoanProductsRequestDownPaymentAdvPaymentAllocationProgressiveLoanScheduleInstLvlDelinquency);
@@ -470,8 +461,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPmtAllocProgSchedInstLvlDelinquencyCreditAllocation = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPmtAllocProgSchedInstLvlDelinquencyCreditAllocation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPmtAllocProgSchedInstLvlDelinquencyCreditAllocation = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPmtAllocProgSchedInstLvlDelinquencyCreditAllocation);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADV_PMT_ALLOC_PROG_SCHEDULE_HOR_INST_LVL_DELINQUENCY_CREDIT_ALLOCATION,
responseLoanProductsRequestDownPaymentAdvPmtAllocProgSchedInstLvlDelinquencyCreditAllocation);
@@ -497,8 +488,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPmtAllocFixedLength = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPmtAllocFixedLength).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPmtAllocFixedLength = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPmtAllocFixedLength);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_ADV_PMT_ALLOC_FIXED_LENGTH,
responseLoanProductsRequestDownPaymentAdvPmtAllocFixedLength);
@@ -516,8 +507,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocationRepaymentStartSubmitted = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAutoAdvPaymentAllocationRepaymentStartSubmitted).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocationRepaymentStartSubmitted = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAutoAdvPaymentAllocationRepaymentStartSubmitted);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_AUTO_ADVANCED_REPAYMENT_ALLOCATION_PAYMENT_START_SUBMITTED,
responseLoanProductsRequestDownPaymentAutoAdvPaymentAllocationRepaymentStartSubmitted);
@@ -543,8 +534,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvPaymentAllocationInterestFlatMultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvPaymentAllocationInterestFlatMultiDisbursement).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvPaymentAllocationInterestFlatMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvPaymentAllocationInterestFlatMultiDisbursement);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_INTEREST_FLAT_ADV_PMT_ALLOC_MULTIDISBURSE,
responseLoanProductsRequestDownPaymentAdvPaymentAllocationInterestFlatMultiDisbursement);
@@ -560,8 +551,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActual = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActual).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActual = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActual);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActual);
@@ -578,8 +569,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030 = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030 = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030);
@@ -600,8 +591,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030MultiDisburse).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030MultiDisburse);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_MULTIDISBURSE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburse);
@@ -625,8 +616,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburseDownPayment = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030MultiDisburseDownPayment).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburseDownPayment = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030MultiDisburseDownPayment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_MULTIDISBURSE_DOWNPAYMENT,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030MultiDisburseDownPayment);
@@ -644,8 +635,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi365Actual = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterest365Actual).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi365Actual = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterest365Actual);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_365_ACTUAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi365Actual);
@@ -664,8 +655,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030Downpayment = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterest36030Downpayment).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030Downpayment = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterest36030Downpayment);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_DOWNPAYMENT,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030Downpayment);
@@ -682,8 +673,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualAccrualActivity).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualAccrualActivity);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualAccrualActivity);
@@ -696,8 +687,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.enableAccrualActivityPosting(true)//
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value)//
.allowPartialPeriodInterestCalcualtion(false);//
- Response<PostLoanProductsResponse> responseInterestDecliningPeriodDailyAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningPeriodDailyAccrualActivity).execute();
+ PostLoanProductsResponse responseInterestDecliningPeriodDailyAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningPeriodDailyAccrualActivity);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_PERIOD_DAILY_ACCRUAL_ACTIVITY,
responseInterestDecliningPeriodDailyAccrualActivity);
@@ -711,9 +702,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.enableAccrualActivityPosting(true)//
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value)//
.allowPartialPeriodInterestCalcualtion(false);//
- Response<PostLoanProductsResponse> responseLP1InterestDecliningBalanceDailyRecalculationCompoundingNoneAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNoneAccrualActivity)
- .execute();
+ PostLoanProductsResponse responseLP1InterestDecliningBalanceDailyRecalculationCompoundingNoneAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNoneAccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_BALANCE_DAILY_RECALCULATION_COMPOUNDING_NONE_ACCRUAL_ACTIVITY,
responseLP1InterestDecliningBalanceDailyRecalculationCompoundingNoneAccrualActivity);
@@ -732,8 +722,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("INTEREST_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefund = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefund).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefund = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefund);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_REFUND,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefund);
@@ -760,8 +750,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloese = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPreclose).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloese = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPreclose);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_PRECLOSE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloese);
@@ -789,8 +779,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDate = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillRestFrequencyDate).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDate = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillRestFrequencyDate);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_REST_FREQUENCY_DATE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDate);
@@ -818,8 +808,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillPreCloese = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcSameAsRepTillPreclose).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillPreCloese = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcSameAsRepTillPreclose);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_SAME_AS_REP_TILL_PRECLOSE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillPreCloese);
@@ -848,9 +838,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillRestFrequencyDate = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcSameAsRepTillRestFrequencyDate)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillRestFrequencyDate = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcSameAsRepTillRestFrequencyDate);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_SAME_AS_REP_TILL_REST_FREQUENCY_DATE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcSameAsRepTillRestFrequencyDate);
@@ -869,8 +858,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "NEXT_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLP1AdvPmtAllocProgressiveLoanScheduleHorizontal = loanProductsApi
- .createLoanProduct(loanProductsRequestLP1AdvPmtAllocProgressiveLoanScheduleHorizontal).execute();
+ PostLoanProductsResponse responseLP1AdvPmtAllocProgressiveLoanScheduleHorizontal = createLoanProductIdempotent(
+ loanProductsRequestLP1AdvPmtAllocProgressiveLoanScheduleHorizontal);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_ADVANCED_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL,
responseLP1AdvPmtAllocProgressiveLoanScheduleHorizontal);
@@ -900,8 +889,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseWholeTerm = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseWholeTerm).execute();
+ PostLoanProductsResponse responseLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseWholeTerm = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseWholeTerm);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_PRECLOSE_WHOLE_TERM,
responseLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseWholeTerm);
@@ -932,8 +921,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "REAMORTIZATION"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "LAST_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE,
responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedule);
@@ -959,8 +948,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("INTEREST_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_REFUND_FULL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull);
@@ -989,8 +978,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocationPenFeeIntPrincipal("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocationPenFeeIntPrincipal("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocationPenFeeIntPrincipal("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloesePmtAlloc1 = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPreclosePmtAlloc1).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloesePmtAlloc1 = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPreclosePmtAlloc1);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_PRECLOSE_PMT_ALLOC_1,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillPreCloesePmtAlloc1);
@@ -1015,9 +1004,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.recalculationRestFrequencyInterval(1)//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "LAST_INSTALLMENT")));//
- Response<PostLoanProductsResponse> loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseLastInstallmentResponse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseLastInstallment)
- .execute();
+ PostLoanProductsResponse loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseLastInstallmentResponse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseLastInstallment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_PRECLOSE_LAST_INSTALLMENT,
loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseLastInstallmentResponse);
@@ -1038,8 +1026,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.supportedInterestRefundTypes(Arrays.asList("MERCHANT_ISSUED_REFUND", "PAYOUT_REFUND"))//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculation = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundRecalculation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculation = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundRecalculation);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_REFUND_INTEREST_RECALCULATION,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculation);
@@ -1071,8 +1059,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseDownPayment = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestRecalculationEmi36030MultiDisburseDownPayment).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseDownPayment = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestRecalculationEmi36030MultiDisburseDownPayment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_RECALCULATION_DAILY_EMI_360_30_MULTIDISBURSE_DOWNPAYMENT,
responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseDownPayment);
@@ -1113,9 +1101,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvCustomPaymentAllocationInterestRecalculationDaily36030MultiDisburse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvCustomPaymentAllocationInterestRecalculationDailyEmi36030MultiDisburse)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvCustomPaymentAllocationInterestRecalculationDaily36030MultiDisburse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvCustomPaymentAllocationInterestRecalculationDailyEmi36030MultiDisburse);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_INTEREST_RECALCULATION_DAILY_EMI_360_30_MULTIDISBURSE,
responseLoanProductsRequestLP2AdvCustomPaymentAllocationInterestRecalculationDaily36030MultiDisburse);
@@ -1145,9 +1132,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcNoCalcOnPastDueDailyTillPreClose = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalcDailyNoCalcOnPastDueTillPreclose)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcNoCalcOnPastDueDailyTillPreClose = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalcDailyNoCalcOnPastDueTillPreclose);
TestContext.INSTANCE.set(TestContextKey.temp,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcNoCalcOnPastDueDailyTillPreClose);
@@ -1177,9 +1163,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentAllocationInterestRecalculationDailyNoCalcOnPastDue36030MultiDisburse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentAllocationInterestRecalculationDailyNoCalcOnPastDueEmi36030MultiDisburse)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentAllocationInterestRecalculationDailyNoCalcOnPastDue36030MultiDisburse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentAllocationInterestRecalculationDailyNoCalcOnPastDueEmi36030MultiDisburse);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_PAYMENT_ALLOCATION_INTEREST_RECALCULATION_DAILY_NO_CALC_ON_PAST_DUE_EMI_360_30_MULTIDISBURSE,
responseLoanProductsRequestLP2AdvPaymentAllocationInterestRecalculationDailyNoCalcOnPastDue36030MultiDisburse);
@@ -1211,9 +1196,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseAutoDownPayment = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestRecalculationEmi36030MultiDisburseAutoDownPayment)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseAutoDownPayment = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestRecalculationEmi36030MultiDisburseAutoDownPayment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_RECALCULATION_DAILY_EMI_360_30_MULTIDISBURSE_AUTO_DOWNPAYMENT,
responseLoanProductsRequestLP2AdvancedpaymentInterestRecalculation36030MultiDisburseAutoDownPayment);
@@ -1229,9 +1213,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")))
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourProgressiveLoanSchedule)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ZERO_INTEREST_CHARGE_OFF_BEHAVIOUR,
responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourProgressiveLoanSchedule);
@@ -1269,8 +1252,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvZeroInterestChargeOffBehaviourProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvZeroInterestChargeOffBehaviourProgressiveLoanSchedule);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF_BEHAVIOUR,
responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourProgressiveLoanSchedule);
@@ -1301,8 +1284,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))) //
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR,
responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule);
@@ -1335,9 +1318,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowPartialPeriodInterestCalcualtion(true)//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyAllowPartialPeriod = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyAllowPartialPeriod)
- .execute();
+ PostLoanProductsResponse responseLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyAllowPartialPeriod = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyAllowPartialPeriod);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_ALLOW_PARTIAL_PERIOD,
responseLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyAllowPartialPeriod);
@@ -1364,8 +1346,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyChargeOff).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ZERO_INTEREST_CHARGE_OFF,
responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030InterestRecalculationDailyChargeOff);
@@ -1381,8 +1363,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"))) //
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentNoInterestInterestRecalculationChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentNoInterestInterestRecalculationChargeOff).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentNoInterestInterestRecalculationChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentNoInterestInterestRecalculationChargeOff);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF,
responseLoanProductsRequestLP2AdvancedPaymentNoInterestInterestRecalculationChargeOff);
@@ -1403,8 +1385,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestAutoDownpaymentEmiActualActualAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestAutoDownpaymentEmiActualActualAccrualActivity).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestAutoDownpaymentEmiActualActualAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestAutoDownpaymentEmiActualActualAccrualActivity);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestAutoDownpaymentEmiActualActualAccrualActivity);
@@ -1432,9 +1414,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseloanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyAccrualActivityPosting = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyAccrualActivityPosting)
- .execute();
+ PostLoanProductsResponse responseloanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyAccrualActivityPosting = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyAccrualActivityPosting);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_ACCRUAL_ACTIVITY_POSTING,
responseloanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyAccrualActivityPosting);
@@ -1452,8 +1433,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi360Actual = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterest360Actual).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi360Actual = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterest360Actual);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_ACTUAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi360Actual);
@@ -1476,8 +1457,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestFeePrincipal = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestFeePrincipal).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestFeePrincipal = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestFeePrincipal);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_CHARGEBACK_INTEREST_FEE_PRINCIPAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestFeePrincipal);
@@ -1501,8 +1482,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackPrincipalInterestFee = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackPrincipalInterestFee).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackPrincipalInterestFee = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackPrincipalInterestFee);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_CHARGEBACK_PRINCIPAL_INTEREST_FEE,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackPrincipalInterestFee);
@@ -1526,9 +1507,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestPenaltyFeePrincipal = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestPenaltyFeePrincipal)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestPenaltyFeePrincipal = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestPenaltyFeePrincipal);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_CHARGEBACK_INTEREST_PENALTY_FEE_PRINCIPAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyEmi36030ChargebackInterestPenaltyFeePrincipal);
@@ -1553,8 +1533,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRecalculationDaily = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRecalculationDaily).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRecalculationDaily = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRecalculationDaily);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALCULATION_DAILY,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRecalculationDaily);
@@ -1578,8 +1558,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030AccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmi36030AccrualActivity).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030AccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmi36030AccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_ACCRUAL_ACTIVITY,
responseLoanProductsRequestLP2AdvancedPaymentInterestEmi36030AccrualActivity);
@@ -1617,8 +1597,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule2 = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule2).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule2 = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule2);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR,
responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourProgressiveLoanSchedule2);
@@ -1637,8 +1617,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> loanProductsResponseChargebackAllocation = loanProductsApi
- .createLoanProduct(loanProductsRequestChargebackAllocation).execute();
+ PostLoanProductsResponse loanProductsResponseChargebackAllocation = createLoanProductIdempotent(
+ loanProductsRequestChargebackAllocation);
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST_RESPONSE,
loanProductsResponseChargebackAllocation);
@@ -1658,8 +1638,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> loanProductsResponseChargebackAllocationPrincipalFirst = loanProductsApi
- .createLoanProduct(loanProductsRequestChargebackAllocationPrincipalFirst).execute();
+ PostLoanProductsResponse loanProductsResponseChargebackAllocationPrincipalFirst = createLoanProductIdempotent(
+ loanProductsRequestChargebackAllocationPrincipalFirst);
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST_RESPONSE,
loanProductsResponseChargebackAllocationPrincipalFirst);
@@ -1689,10 +1669,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_PENALTY_FEE_PRINCIPAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestPenaltyFeePrincipal);
@@ -1723,9 +1701,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_FEE_PRINCIPAL,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackInterestFeePrincipal);
@@ -1756,9 +1733,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_PRINCIPAL_INTEREST_FEE,
responseLoanProductsRequestLP2AdvancedpaymentInterestDailyInterestRecalcEmi36030ChargebackPrincipalInterestFee);
@@ -1787,10 +1763,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL))) //
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(
- loanProductsRequestAdvCustomInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestAdvCustomInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR_LAST_INSTALLMENT_STRATEGY,
responseLoanProductsRequestAdvCustomInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule);
@@ -1826,10 +1800,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL))) //
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(
- loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR_LAST_INSTALLMENT_STRATEGY,
responseLoanProductsRequestAdvCustomAccelerateMaturityChargeOffBehaviourLastInstallmentStrategyProgressiveLoanSchedule);
@@ -1855,8 +1827,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmi36030AccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestRecognitionOnDisbursementEmi36030AccrualActivity).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmi36030AccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestRecognitionOnDisbursementEmi36030AccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_RECOGNITION_DISBURSEMENT_DAILY_EMI_360_30_ACCRUAL_ACTIVITY,
responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmi36030AccrualActivity);
@@ -1883,9 +1855,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmiActualActualAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestRecognitionOnDisbursementEmiActualActual30AccrualActivity)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmiActualActualAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestRecognitionOnDisbursementEmiActualActual30AccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_RECOGNITION_DISBURSEMENT_DAILY_EMI_ACTUAL_ACTUAL_ACCRUAL_ACTIVITY,
responseLoanProductsRequestLP2AdvancedPaymentInterestInterestRecognitionOnDisbursementEmiActualActualAccrualActivity);
@@ -1912,8 +1883,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcAccountingRuleNone = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcAccountingRuleNone).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcAccountingRuleNone = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcAccountingRuleNone);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_ACCOUNTING_RULE_NONE,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcAccountingRuleNone);
@@ -1941,8 +1912,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))) //
.chargeOffBehaviour("ZERO_INTEREST");//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyZeroIntChargeOffIntRecognitionFromDisbDate = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInterestRecalcDailyZeroIntChargeOffIntRecognitionFromDisbDate).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyZeroIntChargeOffIntRecognitionFromDisbDate = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInterestRecalcDailyZeroIntChargeOffIntRecognitionFromDisbDate);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INT_RECALCULATION_ZERO_INT_CHARGE_OFF_INT_RECOGNITION_FROM_DISB_DATE,
responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyZeroIntChargeOffIntRecognitionFromDisbDate);
@@ -1968,9 +1939,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterestEmiActualActualLeapYearInterestRecalculationDaily = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmiActualActualLeapYearInterestRecalculationDaily)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterestEmiActualActualLeapYearInterestRecalculationDaily = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmiActualActualLeapYearInterestRecalculationDaily);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_LEAP_YEAR_INTEREST_RECALCULATION_DAILY,
responseLoanProductsRequestLP2AdvancedPaymentInterestEmiActualActualLeapYearInterestRecalculationDaily);
@@ -1983,8 +1953,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.preClosureInterestCalculationStrategy(1).rescheduleStrategyMethod(1).interestRecalculationCompoundingMethod(0)
.recalculationRestFrequencyType(2).recalculationRestFrequencyInterval(1)
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value).allowPartialPeriodInterestCalcualtion(false);
- final Response<PostLoanProductsResponse> responseInterestDecliningPeriodDailyIntRecalc = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestDecliningPeriodDailyIntRecalc).execute();
+ final PostLoanProductsResponse responseInterestDecliningPeriodDailyIntRecalc = createLoanProductIdempotent(
+ loanProductsRequestInterestDecliningPeriodDailyIntRecalc);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_DECLINING_PERIOD_DAILY_INT_RECALC,
responseInterestDecliningPeriodDailyIntRecalc);
@@ -1995,8 +1965,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.defaultLoanProductsRequestLP1InterestDeclining().name(name82).isInterestRecalculationEnabled(false)
.daysInYearType(DaysInYearType.DAYS360.value).daysInMonthType(DaysInMonthType.DAYS30.value)
.interestCalculationPeriodType(InterestCalculationPeriodTime.DAILY.value).allowPartialPeriodInterestCalcualtion(false);
- final Response<PostLoanProductsResponse> responseInterest36030DecliningPeriodDailyIntRecalc = loanProductsApi
- .createLoanProduct(loanProductsRequestInterest36030DecliningPeriodDailyIntRecalc).execute();
+ final PostLoanProductsResponse responseInterest36030DecliningPeriodDailyIntRecalc = createLoanProductIdempotent(
+ loanProductsRequestInterest36030DecliningPeriodDailyIntRecalc);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_360_30__DECLINING_PERIOD_DAILY_INT_RECALC,
responseInterest36030DecliningPeriodDailyIntRecalc);
@@ -2022,8 +1992,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReason = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReason).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReason = createLoanProductIdempotent(
+ loanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReason);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF_DELINQUENT_REASON,
responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReason);
@@ -2070,8 +2040,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE) //
));//
- Response<PostLoanProductsResponse> responseLoanProductsResponseAdvDPCustomPaymentAllocationProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvDPCustomPaymentAllocationProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsResponseAdvDPCustomPaymentAllocationProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvDPCustomPaymentAllocationProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_DP_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE,
responseLoanProductsResponseAdvDPCustomPaymentAllocationProgressiveLoanSchedule);
@@ -2120,8 +2090,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE) //
));//
- Response<PostLoanProductsResponse> responseLoanProductsResponseAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule).execute();
+ PostLoanProductsResponse responseLoanProductsResponseAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule = createLoanProductIdempotent(
+ loanProductsRequestAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_DP_IR_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE,
responseLoanProductsResponseAdvDPIRCustomPaymentAllocationProgressiveLoanSchedule);
@@ -2150,8 +2120,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_DISBURSEMENT_CHARGES,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyDisbursementCharge);
@@ -2182,8 +2152,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(false)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburse);
@@ -2214,9 +2184,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseDisbursementCharge);
@@ -2245,9 +2214,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyCashAccountingDisbursementCharge);
@@ -2280,8 +2248,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReasonIntRecalc = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReasonIntRecalc).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReasonIntRecalc = createLoanProductIdempotent(
+ loanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReasonIntRecalc);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF_DELINQUENT_REASON_INTEREST_RECALC,
responseLoanProductsRequestAdvZeroInterestChargeOffProgressiveDelinquentReasonIntRecalc);
@@ -2293,8 +2261,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name91)//
.shortName(loanProductsRequestFactory.generateShortNameSafely())//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF,
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff);
@@ -2308,8 +2276,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name92)//
.shortName(loanProductsRequestFactory.generateShortNameSafely())//
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullAccelerateMaturityChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullAccelerateMaturityChargeOff).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullAccelerateMaturityChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullAccelerateMaturityChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ACCELERATE_MATURITY_CHARGE_OFF,
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullAccelerateMaturityChargeOff);
@@ -2329,8 +2297,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("INTEREST_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualNoInterestRecalcRefundFull = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedPaymentInterestEmiActualActualNoInterestRecalcRefundFull).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualNoInterestRecalcRefundFull = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedPaymentInterestEmiActualActualNoInterestRecalcRefundFull);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_REFUND_FULL,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualNoInterestRecalcRefundFull);
@@ -2343,9 +2311,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name94)//
.shortName(loanProductsRequestFactory.generateShortNameSafely())//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullZeroIntChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullZeroIntChargeOff)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullZeroIntChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullZeroIntChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF,
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullZeroIntChargeOff);
@@ -2359,10 +2326,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.name(name95)//
.shortName(loanProductsRequestFactory.generateShortNameSafely())//
.chargeOffBehaviour("ACCELERATE_MATURITY");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullAccelerateMaturityChargeOff = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullAccelerateMaturityChargeOff)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullAccelerateMaturityChargeOff = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullAccelerateMaturityChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ACC_MATUR_CHARGE_OFF,
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualNoInterestRecalcIntRefundFullAccelerateMaturityChargeOff);
@@ -2390,10 +2355,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDateLastInstallment = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillRestFrequencyDateLastInstallment)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDateLastInstallment = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillRestFrequencyDateLastInstallment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_IR_DAILY_TILL_REST_FREQUENCY_DATE_LAST_INSTALLMENT,
responseLoanProductsRequestLP2AdvancedpaymentInterest36030InterestRecalcDailyTillRestFrequencyDateLastInstallment);
@@ -2412,8 +2375,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentCapitalizedIncome).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentCapitalizedIncome);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPaymentCapitalizedIncome);
@@ -2438,9 +2401,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.supportedInterestRefundTypes(Arrays.asList("MERCHANT_ISSUED_REFUND", "PAYOUT_REFUND"))//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculationMultidisb = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundRecalculationMultiDisb)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculationMultidisb = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundRecalculationMultiDisb);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_REFUND_INTEREST_RECALCULATION_MULTIDISB,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculationMultidisb);
@@ -2465,8 +2427,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome);
@@ -2498,8 +2460,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSAL_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome);
@@ -2527,8 +2489,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_FEE,
responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee);
@@ -2557,8 +2519,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestPrgAdvZeroIntChargeOffDelinquentReasonIntRecalcCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestPrgAdvZeroIntChargeOffDelinquentReasonIntRecalcCapitalizedIncome).execute();
+ PostLoanProductsResponse responseLoanProductsRequestPrgAdvZeroIntChargeOffDelinquentReasonIntRecalcCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestPrgAdvZeroIntChargeOffDelinquentReasonIntRecalcCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ZERO_INT_CHARGE_OFF_DELINQUENT_REASON_INT_RECALC_CAPITALIZED_INCOME,
responseLoanProductsRequestPrgAdvZeroIntChargeOffDelinquentReasonIntRecalcCapitalizedIncome);
@@ -2587,9 +2549,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("INTEREST_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "NEXT_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculationAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculationAccrualActivity)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculationAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculationAccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_REFUND_INTEREST_RECALC_ACCRUAL_ACTIVITY,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculationAccrualActivity);
@@ -2625,8 +2586,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundInterestRecalculation = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundInterestRecalculation = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundRecalculation);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_REFUND_INTEREST_RECALC_DOWNPAYMENT_ACCRUAL_ACTIVITY,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRefundInterestRecalculation);
@@ -2642,8 +2603,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")))
.enableAccrualActivityPosting(true)//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_INTEREST_RECALCULATION_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY,
responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity);
@@ -2685,8 +2646,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeAdjCustomAlloc = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeAdjCustomAlloc).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeAdjCustomAlloc = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeAdjCustomAlloc);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC,
@@ -2717,8 +2678,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_CONTRACT_TERMINATION,
responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc);
@@ -2753,10 +2714,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
.overAppliedNumber(50);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_OVER_APPLIED_PERCENTAGE_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome);
@@ -2799,8 +2758,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAutoAdvCustomPaymentAllocation = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAutoAdvCustomPaymentAllocation).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAutoAdvCustomPaymentAllocation = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAutoAdvCustomPaymentAllocation);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_AUTO_ADVANCED_CUSTOM_PAYMENT_ALLOCATION,
responseLoanProductsRequestDownPaymentAutoAdvCustomPaymentAllocation);
@@ -2845,10 +2804,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalCapitalizedIncomeAdjCustomAlloc = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalCapitalizedIncomeAdjCustomAlloc)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalCapitalizedIncomeAdjCustomAlloc = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalCapitalizedIncomeAdjCustomAlloc);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalCapitalizedIncomeAdjCustomAlloc);
@@ -2883,10 +2840,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.FIXED_SIZE.value)//
.overAppliedNumber(1000);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedFlatCapitalizedIncome = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedFlatCapitalizedIncome)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedFlatCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedFlatCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_OVER_APPLIED_FLAT_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedFlatCapitalizedIncome);
@@ -2917,9 +2872,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
.overAppliedNumber(50);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedCapitalizedIncome)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_APPROVED_OVER_APPLIED_PERCENTAGE_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedCapitalizedIncome);
@@ -2950,9 +2904,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.FIXED_SIZE.value)//
.overAppliedNumber(1000);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedFlatCapitalizedIncome = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedFlatCapitalizedIncome)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedFlatCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedFlatCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_APPROVED_OVER_APPLIED_FLAT_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcApprovedOverAppliedFlatCapitalizedIncome);
@@ -2976,8 +2929,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES,
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees);
@@ -2995,9 +2948,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")))
.enableAccrualActivityPosting(true)//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvInterestRecalculationAutoDownpaymentZeroInterestChargeOffBehaviourAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvInterestRecalculationAutoDownpaymentZeroInterestChargeOffBehaviourAccrualActivity)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestAdvInterestRecalculationAutoDownpaymentZeroInterestChargeOffBehaviourAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestAdvInterestRecalculationAutoDownpaymentZeroInterestChargeOffBehaviourAccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_INTEREST_RECALC_AUTO_DOWNPAYMENT_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY,
responseLoanProductsRequestAdvInterestRecalculationAutoDownpaymentZeroInterestChargeOffBehaviourAccrualActivity);
@@ -3017,8 +2969,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyInstallmentFeeFlatCharges = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInterestRecalcDailyInstallmentFeeFlatCharges).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyInstallmentFeeFlatCharges = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInterestRecalcDailyInstallmentFeeFlatCharges);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_DAILY_INSTALLMENT_FEE_FLAT_CHARGES,
responseLoanProductsRequestLP2AdvPaymentInterestRecalcDailyInstallmentFeeFlatCharges);
@@ -3047,8 +2999,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountCharges = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountCharges).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountCharges = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountCharges);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INSTALLMENT_FEE_PERCENT_AMOUNT_CHARGES,
responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountCharges);
@@ -3077,8 +3029,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentInterestCharges = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInstallmentFeePercentInterestCharges).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentInterestCharges = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInstallmentFeePercentInterestCharges);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INSTALLMENT_FEE_PERCENT_INTEREST_CHARGES,
responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentInterestCharges);
@@ -3107,8 +3059,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountPlusInterestCharges = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountPlusInterestCharges).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountPlusInterestCharges = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountPlusInterestCharges);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INSTALLMENT_FEE_PERCENT_AMOUNT_INTEREST_CHARGES,
responseLoanProductsRequestLP2AdvPaymentInstallmentFeePercentAmountPlusInterestCharges);
@@ -3140,8 +3092,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInstallmentFeeAllCharges = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInstallmentFeeAllCharges).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInstallmentFeeAllCharges = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInstallmentFeeAllCharges);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INSTALLMENT_FEE_ALL_CHARGES,
responseLoanProductsRequestLP2AdvPaymentInstallmentFeeAllCharges);
@@ -3161,8 +3113,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPaymentInstallmentFeeFlatPlusInterestChargesMultiDisburse = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPaymentInstallmentFeeFlatPlusInterestChargesMultiDisburse).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPaymentInstallmentFeeFlatPlusInterestChargesMultiDisburse = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPaymentInstallmentFeeFlatPlusInterestChargesMultiDisburse);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INSTALLMENT_FEE_FLAT_INTEREST_CHARGES_TRANCHE,
responseLoanProductsRequestLP2AdvPaymentInstallmentFeeFlatPlusInterestChargesMultiDisburse);
@@ -3192,8 +3144,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvPaymentAllocationInterestFlat36030MultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvPaymentAllocationInterestFlat36030MultiDisbursement).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvPaymentAllocationInterestFlat36030MultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestAdvPaymentAllocationInterestFlat36030MultiDisbursement);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_INTEREST_FLAT_360_30_ADV_PMT_ALLOC_MULTIDISBURSE,
responseLoanProductsRequestAdvPaymentAllocationInterestFlat36030MultiDisbursement);
@@ -3223,8 +3175,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvInterestFlatMultiDisbPartialPeriodInterestCalculationDisabled = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvInterestFlatMultiDisbPartialPeriodInterestCalculationDisabled).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvInterestFlatMultiDisbPartialPeriodInterestCalculationDisabled = createLoanProductIdempotent(
+ loanProductsRequestAdvInterestFlatMultiDisbPartialPeriodInterestCalculationDisabled);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_INTEREST_FLAT_ADV_PMT_ALLOC_MULTIDISBURSE_PART_PERIOD_CALC_DISABLED,
responseLoanProductsRequestAdvInterestFlatMultiDisbPartialPeriodInterestCalculationDisabled);
@@ -3257,8 +3209,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvInterestFlat36030MultiDisbPartialPeriodInterestCalculationDisabled = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvInterestFlat36030MultiDisbPartialPeriodInterestCalculationDisabled).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvInterestFlat36030MultiDisbPartialPeriodInterestCalculationDisabled = createLoanProductIdempotent(
+ loanProductsRequestAdvInterestFlat36030MultiDisbPartialPeriodInterestCalculationDisabled);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_INTEREST_FLAT_360_30_ADV_PMT_ALLOC_MULTIDISBURSE_PART_PERIOD_CALC_DISABLED,
responseLoanProductsRequestAdvInterestFlat36030MultiDisbPartialPeriodInterestCalculationDisabled);
@@ -3286,8 +3238,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvPaymentAllocationInterestFlatMultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvPaymentAllocationInterestFlatMultiDisbursement).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvPaymentAllocationInterestFlatMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestAdvPaymentAllocationInterestFlatMultiDisbursement);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_INTEREST_FLAT_ADV_PMT_ALLOC_MULTIDISBURSE,
responseLoanProductsRequestAdvPaymentAllocationInterestFlatMultiDisbursement);
@@ -3314,8 +3266,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestDownPaymentAdvInterestFlatMultiDisbPartPeriodIntCalcDisabled = loanProductsApi
- .createLoanProduct(loanProductsRequestDownPaymentAdvInterestFlatMultiDisbPartialPeriodInterestCalcDisabled).execute();
+ PostLoanProductsResponse responseLoanProductsRequestDownPaymentAdvInterestFlatMultiDisbPartPeriodIntCalcDisabled = createLoanProductIdempotent(
+ loanProductsRequestDownPaymentAdvInterestFlatMultiDisbPartialPeriodInterestCalcDisabled);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_DOWNPAYMENT_INTEREST_FLAT_ADV_PMT_ALLOC_MULTIDISBURSE_PART_PERIOD_CALC_DISABLED,
responseLoanProductsRequestDownPaymentAdvInterestFlatMultiDisbPartPeriodIntCalcDisabled);
@@ -3347,8 +3299,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE)));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestNoInterestRecalculationAllocationPenaltyFirst = loanProductsApi
- .createLoanProduct(loanProductsRequestNoInterestRecalculationAllocationPenaltyFirst).execute();
+ PostLoanProductsResponse responseLoanProductsRequestNoInterestRecalculationAllocationPenaltyFirst = createLoanProductIdempotent(
+ loanProductsRequestNoInterestRecalculationAllocationPenaltyFirst);
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST_RESPONSE,
responseLoanProductsRequestNoInterestRecalculationAllocationPenaltyFirst);
@@ -3372,8 +3324,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesWithChargeOffReason = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesWithChargeOffReason).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesWithChargeOffReason = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesWithChargeOffReason);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES_CHARGE_OFF_REASON,
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesWithChargeOffReason);
@@ -3408,10 +3360,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedCapitalizedIncome = loanProductsApi
- .createLoanProduct(
- loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedCapitalizedIncome)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedCapitalizedIncome = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedCapitalizedIncome);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedCapitalizedIncome);
@@ -3426,6 +3376,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
// .interestType(INTEREST_TYPE_DECLINING_BALANCE)//
.defaultLoanProductsRequestLP1() //
.interestCalculationPeriodType(0)//
+ .allowPartialPeriodInterestCalcualtion(false)//
// .allowApprovedDisbursedAmountsOverApplied(false)//
.name(name130)//
.transactionProcessingStrategyCode(
@@ -3434,8 +3385,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(false)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductMultidisbursalExpectTranches = loanProductsApi
- .createLoanProduct(loanProductsRequestMultidisbursalExpectTranches).execute();
+ PostLoanProductsResponse responseLoanProductMultidisbursalExpectTranches = createLoanProductIdempotent(
+ loanProductsRequestMultidisbursalExpectTranches);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_MULTIDISBURSAL_EXPECTS_TRANCHES,
responseLoanProductMultidisbursalExpectTranches);
@@ -3471,8 +3422,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630IntRecalcDailyMutiDisbPartial = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630IntRecalcDailyMutiDisbPartial).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630IntRecalcDailyMutiDisbPartial = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630IntRecalcDailyMutiDisbPartial);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DECL_BAL_SARP_EMI_360_30_INT_RECALC_DAILY_MULTIDISB_PARTIAL_PERIOD,
responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630IntRecalcDailyMutiDisbPartial);
@@ -3504,8 +3455,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbPartial = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbPartial).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbPartial = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbPartial);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DECL_BAL_SARP_EMI_360_30_NO_INT_RECALC_MULTIDISB_PARTIAL_PERIOD,
responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbPartial);
@@ -3537,8 +3488,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbNoPartial = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbNoPartial).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbNoPartial = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbNoPartial);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DECL_BAL_SARP_EMI_360_30_NO_INT_RECALC_MULTIDISB_NO_PARTIAL_PERIOD,
responseLoanProductsRequestLP2AdvPmtIntDeclSarpEmi3630NoIntRecalcMutiDisbNoPartial);
@@ -3574,9 +3525,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(false)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedExpectTranches = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedExpectTranches)
- .execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedExpectTranches = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedExpectTranches);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_INTEREST_RECALC_360_30_MULTIDISB_OVER_APPLIED_EXPECTED_TRANCHES,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbApprovedOverAppliedExpectTranches);
@@ -3608,9 +3558,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedPaymentInterest36030InterestRecalcDailyTillPreCloseMinInt3MaxInt20 = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseMinInt3MaxInt20)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedPaymentInterest36030InterestRecalcDailyTillPreCloseMinInt3MaxInt20 = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyTillPrecloseMinInt3MaxInt20);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_TILL_PRECLOSE_MIN_INT_3_MAX_INT_20,
responseLoanProductsRequestLP2AdvancedPaymentInterest36030InterestRecalcDailyTillPreCloseMinInt3MaxInt20);
@@ -3635,8 +3584,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))) //
.merchantBuyDownFee(false).buyDownExpenseAccountId(null);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchant = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchant).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchant = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchant);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES_NON_MERCHANT,
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchant);
@@ -3662,8 +3611,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))) //
.merchantBuyDownFee(false).buyDownExpenseAccountId(null);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchantWithChargeOffReason = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchantWithChargeOffReason).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchantWithChargeOffReason = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchantWithChargeOffReason);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES_NON_MERCHANT_CHARGE_OFF_REASON,
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesNonMerchantWithChargeOffReason);
@@ -3698,8 +3647,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.overAppliedNumber(50)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvEmi36030IntRecalcDailyMultiDisbApprovedOverApplied = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvEmi36030IntRecalcDailyMultiDisbApprovedOverApplied).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvEmi36030IntRecalcDailyMultiDisbApprovedOverApplied = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvEmi36030IntRecalcDailyMultiDisbApprovedOverApplied);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_360_30_INT_RECALC_DAILY_MULTIDISB_EXPECT_TRANCHE_APPROVED_OVER_APPLIED,
responseLoanProductsRequestLP2AdvEmi36030IntRecalcDailyMultiDisbApprovedOverApplied);
@@ -3732,8 +3681,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "LAST_INSTALLMENT"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))) //
.chargeOffBehaviour("ZERO_INTEREST");//
- Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_ZERO_CHARGE_OFF,
responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanScheduleZeroChargeOff);
@@ -3768,8 +3717,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.buydownfeeClassificationToIncomeAccountMappings(buydownfeeClassificationToIncomeAccountMappings);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES_CLASSIFICATION_INCOME_MAP,
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFeesClassificationIncomeMap);
@@ -3820,8 +3769,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.capitalizedIncomeClassificationToIncomeAccountMappings(capitalizedIncomeClassificationToIncomeAccountMappings);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap).execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymAllocCapitaizedIncomeClassificationIncomeMap);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PMNT_ALLOCATION_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC_CLASSIFICATION_INCOME_MAP,
@@ -3872,8 +3821,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.writeOffReasonsToExpenseMappings(writeOffReasonToExpenseAccountMappings);//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap = createLoanProductIdempotent(
+ loanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_WRITE_OFF_REASON_MAP,
responseLoanProductsRequestLP2ProgressiveAdvPaymentWriteOffReasonMap);
@@ -3895,8 +3844,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
.overAppliedNumber(50);//
- Response<PostLoanProductsResponse> responseInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement).execute();
+ PostLoanProductsResponse responseInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_ACTUAL_ACTUAL_MULTIDISB,
responseInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursement);
@@ -3922,8 +3871,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowApprovedDisbursedAmountsOverApplied(true)//
.overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)//
.overAppliedNumber(50);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement).execute();
+ PostLoanProductsResponse responseLoanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_DAILY_360_30_APPROVED_OVER_APPLIED_MULTIDISB,
responseLoanProductsRequestInterestFlatSaRRecalculationDailyMultiDisbursement);
@@ -3946,8 +3895,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement).execute();
+ PostLoanProductsResponse responseLoanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_DAILY_RECALCULATION_DAILY_360_30_MULTIDISB,
responseLoanProductsRequestInterestFlatDailyRecalculationDSameAsRepaymentMultiDisbursement);
@@ -3970,9 +3919,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.allowPartialPeriodInterestCalcualtion(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_INTEREST_FLAT_SAR_RECALCULATION_SAME_AS_REPAYMENT_MULTIDISB_AUTO_DOWNPAYMENT,
responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementAUtoDownPayment);
@@ -4050,10 +3998,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY, //
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE) //
));//
- Response<PostLoanProductsResponse> responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmi36030InterestRecalculationDaily = loanProductsApi
- .createLoanProduct(
- loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmi36030InterestRecalculationDaily)
- .execute();
+ PostLoanProductsResponse responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmi36030InterestRecalculationDaily = createLoanProductIdempotent(
+ loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmi36030InterestRecalculationDaily);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY,
responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmi36030InterestRecalculationDaily);
@@ -4085,8 +4031,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalcRecog = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalcRecog).execute();
+ PostLoanProductsResponse responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalcRecog = createLoanProductIdempotent(
+ loanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalcRecog);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_CONTRACT_TERMINATION_INT_RECOGNITION,
responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalcRecog);
@@ -4111,8 +4057,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.repaymentEvery(true) //
.graceOnPrincipalAndInterestPayment(true) //
.graceOnArrearsAgeing(true));
- final Response<PostLoanProductsResponse> responseWithOverrides = loanProductsApi.createLoanProduct(loanProductsRequestWithOverrides)
- .execute();
+ final PostLoanProductsResponse responseWithOverrides = createLoanProductIdempotent(loanProductsRequestWithOverrides);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_WITH_OVERRIDES, responseWithOverrides);
// (LP1_NO_OVERRIDES) - Loan product with all attribute overrides DISABLED
@@ -4135,8 +4080,7 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.repaymentEvery(false) //
.graceOnPrincipalAndInterestPayment(false) //
.graceOnArrearsAgeing(false));
- final Response<PostLoanProductsResponse> responseNoOverrides = loanProductsApi.createLoanProduct(loanProductsRequestNoOverrides)
- .execute();
+ final PostLoanProductsResponse responseNoOverrides = createLoanProductIdempotent(loanProductsRequestNoOverrides);
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP1_NO_OVERRIDES, responseNoOverrides);
// LP2 advanced custom payment allocation + progressive loan schedule + horizontal + interest recalculation
@@ -4162,10 +4106,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT"))); //
- Response<PostLoanProductsResponse> responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffAccruals = loanProductsApi
- .createLoanProduct(
- loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffAccruals)
- .execute();
+ PostLoanProductsResponse responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffAccruals = createLoanProductIdempotent(
+ loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffAccruals);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_CUSTOM_PMT_ALLOC_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OFF_ACCRUAL,
responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffAccruals);
@@ -4188,10 +4130,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.chargeOffBehaviour(ZERO_INTEREST.value)//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"))); //
- Response<PostLoanProductsResponse> responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals = loanProductsApi
- .createLoanProduct(
- loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals)
- .execute();
+ PostLoanProductsResponse responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals = createLoanProductIdempotent(
+ loanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_RECALC_ZERO_CHARGE_OF_ACCRUAL,
responseLoanProductsResponseAdvCustomPaymentAllocationProgressiveLoanInterestDailyEmiActualInterestRecalcZeroChargeOffChargebackAccruals);
@@ -4211,9 +4151,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(false)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches);
TestContext.INSTANCE.set(TestContextKey.LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES,
responseLoanProductsRequestInterestFlatSaRRecalculationSameAsRepaymentMultiDisbursementExpectsTranches);
@@ -4228,8 +4167,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")))
.enableAccrualActivityPosting(true)//
.chargeOffBehaviour("ZERO_INTEREST");//
- final Response<PostLoanProductsResponse> responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity = loanProductsApi
- .createLoanProduct(loanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity).execute();
+ final PostLoanProductsResponse responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity = createLoanProductIdempotent(
+ loanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY,
responseLoanProductsRequestAdvZeroInterestChargeOffBehaviourAccrualActivity);
@@ -4250,8 +4189,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(false)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches = loanProductsApi
- .createLoanProduct(loanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches).execute();
+ PostLoanProductsResponse responseLoanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches = createLoanProductIdempotent(
+ loanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches);
TestContext.INSTANCE.set(TestContextKey.LP1_INTEREST_FLAT_DAILY_ACTUAL_ACTUAL_MULTIDISB_EXPECT_TRANCHES,
responseLoanProductsRequestInterestFlatActualActualMultiDisbursementExpectsTranches);
@@ -4284,9 +4223,8 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
- Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback = loanProductsApi
- .createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback)
- .execute();
+ PostLoanProductsResponse responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback = createLoanProductIdempotent(
+ loanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback);
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_CHARGEBACK,
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback);
@@ -4388,4 +4326,33 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
return paymentAllocationOrder;
}).toList();
}
+
+ private PostLoanProductsResponse createLoanProductIdempotent(PostLoanProductsRequest loanProductRequest) {
+ String productName = loanProductRequest.getName();
+ log.info("Attempting to create loan product: {}", productName);
+ try {
+ List<GetLoanProductsResponse> existingProducts = fineractClient.loanProducts().retrieveAllLoanProducts(Map.of());
+ GetLoanProductsResponse existingProduct = existingProducts.stream().filter(p -> productName.equals(p.getName())).findFirst()
+ .orElse(null);
+
+ if (existingProduct != null) {
+ log.info("Loan product '{}' already exists with ID: {}", productName, existingProduct.getId());
+ PostLoanProductsResponse response = new PostLoanProductsResponse();
+ response.setResourceId(existingProduct.getId());
+ return response;
+ }
+ } catch (Exception e) {
+ log.warn("Error checking if loan product '{}' exists", productName, e);
+ }
+
+ log.info("Creating new loan product: {}", productName);
+ try {
+ PostLoanProductsResponse response = ok(() -> fineractClient.loanProducts().createLoanProduct(loanProductRequest, Map.of()));
+ log.info("Successfully created loan product '{}' with ID: {}", productName, response.getResourceId());
+ return response;
+ } catch (Exception e) {
+ log.error("FAILED to create loan product '{}'", productName, e);
+ throw e;
+ }
+ }
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java
index adcd3b0014..7428f29d98 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java
@@ -18,17 +18,22 @@
*/
package org.apache.fineract.test.initializer.global;
-import java.io.IOException;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.PaymentTypeData;
import org.apache.fineract.client.models.PaymentTypeRequest;
-import org.apache.fineract.client.services.PaymentTypeApi;
import org.apache.fineract.test.factory.PaymentTypesRequestFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
+@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@@ -43,30 +48,40 @@ public class PaymentTypeGlobalInitializerStep implements FineractGlobalInitializ
public static final String PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_CHARGEBACK = "REPAYMENT_ADJUSTMENT_CHARGEBACK";
public static final String PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND = "REPAYMENT_ADJUSTMENT_REFUND";
- private final PaymentTypeApi paymentTypeApi;
+ private final FineractFeignClient fineractClient;
@Override
- public void initialize() throws Exception {
- List<String> paymentTypes = new ArrayList<>();
- paymentTypes.add(PAYMENT_TYPE_AUTOPAY);
- paymentTypes.add(PAYMENT_TYPE_DOWN_PAYMENT);
- paymentTypes.add(PAYMENT_TYPE_REAL_TIME);
- paymentTypes.add(PAYMENT_TYPE_SCHEDULED);
- paymentTypes.add(PAYMENT_TYPE_CHECK_PAYMENT);
- paymentTypes.add(PAYMENT_TYPE_OCA_PAYMENT);
- paymentTypes.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_CHARGEBACK);
- paymentTypes.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND);
+ public void initialize() {
+ List<PaymentTypeData> existingPaymentTypes = new ArrayList<>();
+ try {
+ existingPaymentTypes = fineractClient.paymentType().getAllPaymentTypesUniversal(Map.of());
+ } catch (Exception e) {
+ log.debug("Could not retrieve existing payment types, will create them", e);
+ }
+
+ final List<PaymentTypeData> paymentTypes = existingPaymentTypes;
- paymentTypes.forEach(paymentType -> {
- Integer position = paymentTypes.indexOf(paymentType) + 2;
- PaymentTypeRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentType, paymentType,
- false, position);
+ List<String> paymentTypeNames = new ArrayList<>();
+ paymentTypeNames.add(PAYMENT_TYPE_AUTOPAY);
+ paymentTypeNames.add(PAYMENT_TYPE_DOWN_PAYMENT);
+ paymentTypeNames.add(PAYMENT_TYPE_REAL_TIME);
+ paymentTypeNames.add(PAYMENT_TYPE_SCHEDULED);
+ paymentTypeNames.add(PAYMENT_TYPE_CHECK_PAYMENT);
+ paymentTypeNames.add(PAYMENT_TYPE_OCA_PAYMENT);
+ paymentTypeNames.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_CHARGEBACK);
+ paymentTypeNames.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND);
- try {
- paymentTypeApi.createPaymentType(postPaymentTypesRequest).execute();
- } catch (IOException e) {
- throw new RuntimeException("Error while creating payment type", e);
+ paymentTypeNames.forEach(paymentTypeName -> {
+ boolean paymentTypeExists = paymentTypes.stream().anyMatch(pt -> paymentTypeName.equals(pt.getName()));
+ if (paymentTypeExists) {
+ return;
}
+
+ Integer position = paymentTypeNames.indexOf(paymentTypeName) + 2;
+ PaymentTypeRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentTypeName,
+ paymentTypeName, false, position);
+
+ executeVoid(() -> fineractClient.paymentType().createPaymentType(postPaymentTypesRequest, Map.of()));
});
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SavingsProductGlobalInitializer.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SavingsProductGlobalInitializer.java
index 8121807963..b76d9136bd 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SavingsProductGlobalInitializer.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SavingsProductGlobalInitializer.java
@@ -26,10 +26,8 @@ import org.springframework.stereotype.Component;
public class SavingsProductGlobalInitializer implements FineractGlobalInitializerStep {
@Override
- public void initialize() throws Exception {
- /**
- * TODO uncomment and check when PS-1088 is done
- */
+ public void initialize() {
+ // TODO uncomment and check when PS-1088 is done
// //EUR
// PostSavingsProductsRequest savingsProductsRequestEUR =
// SavingsProductRequestFactory.defaultSavingsProductRequest();
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SchedulerGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SchedulerGlobalInitializerStep.java
index 3bd290047f..b4c7404a3a 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SchedulerGlobalInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/SchedulerGlobalInitializerStep.java
@@ -18,8 +18,11 @@
*/
package org.apache.fineract.test.initializer.global;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+
+import java.util.Map;
import lombok.RequiredArgsConstructor;
-import org.apache.fineract.client.services.SchedulerApi;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -31,10 +34,10 @@ public class SchedulerGlobalInitializerStep implements FineractGlobalInitializer
private static final String SCHEDULER_STATUS_STOP = "stop";
- private final SchedulerApi schedulerApi;
+ private final FineractFeignClient fineractClient;
@Override
public void initialize() throws Exception {
- schedulerApi.changeSchedulerStatus(SCHEDULER_STATUS_STOP);
+ executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus(Map.of("command", SCHEDULER_STATUS_STOP)));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/scenario/GlobalConfigurationScenarioInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/scenario/GlobalConfigurationScenarioInitializerStep.java
index cc149aebaa..dac648df2e 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/scenario/GlobalConfigurationScenarioInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/scenario/GlobalConfigurationScenarioInitializerStep.java
@@ -34,14 +34,10 @@ public class GlobalConfigurationScenarioInitializerStep implements FineractScena
@Override
public void initializeForScenario() throws Exception {
- /**
- * Enable-address set to false
- */
+ // Enable-address set to false
globalConfigurationHelper.disableGlobalConfiguration(CONFIG_KEY_ENABLE_ADDRESS, 0L);
- /**
- * Enable business date and COB date
- */
+ // Enable business date and COB date
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE, 0L);
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/ExternalEventSuiteInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/ExternalEventSuiteInitializerStep.java
index edde8c6db2..1fd71ce917 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/ExternalEventSuiteInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/ExternalEventSuiteInitializerStep.java
@@ -18,36 +18,52 @@
*/
package org.apache.fineract.test.initializer.suite;
-import static java.lang.System.lineSeparator;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.awaitility.Awaitility.await;
+import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ExternalEventConfigurationItemResponse;
import org.apache.fineract.client.models.ExternalEventConfigurationResponse;
import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest;
-import org.apache.fineract.client.services.ExternalEventConfigurationApi;
+import org.apache.fineract.test.messaging.config.EventProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.config.JmsListenerEndpointRegistry;
+import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
+@Slf4j
@RequiredArgsConstructor
@Component
public class ExternalEventSuiteInitializerStep implements FineractSuiteInitializerStep {
- private final ExternalEventConfigurationApi eventConfigurationApi;
+ private static final Duration JMS_STARTUP_TIMEOUT = Duration.ofSeconds(30);
+
+ private final FineractFeignClient fineractClient;
+
+ @Autowired(required = false)
+ private JmsListenerEndpointRegistry registry;
+
+ @Autowired(required = false)
+ private EventProperties eventProperties;
@Override
- public void initializeForSuite() throws Exception {
+ public void initializeForSuite() throws InterruptedException {
+ log.info("=== ExternalEventSuiteInitializerStep.initializeForSuite() - START ===");
+
+ // Step 1: Enable all external events
Map<String, Boolean> eventConfigMap = new HashMap<>();
- Response<ExternalEventConfigurationResponse> response = eventConfigurationApi.getExternalEventConfigurations().execute();
- if (!response.isSuccessful()) {
- String responseBody = response.errorBody().string();
- throw new RuntimeException("Cannot configure external events due to " + lineSeparator() + responseBody);
- }
+ ExternalEventConfigurationResponse response = ok(
+ () -> fineractClient.externalEventConfiguration().getExternalEventConfigurations(Map.of()));
- List<ExternalEventConfigurationItemResponse> externalEventConfiguration = response.body().getExternalEventConfiguration();
+ List<ExternalEventConfigurationItemResponse> externalEventConfiguration = response.getExternalEventConfiguration();
externalEventConfiguration.forEach(e -> {
eventConfigMap.put(e.getType(), true);
});
@@ -55,6 +71,28 @@ public class ExternalEventSuiteInitializerStep implements FineractSuiteInitializ
ExternalEventConfigurationUpdateRequest request = new ExternalEventConfigurationUpdateRequest()
.externalEventConfigurations(eventConfigMap);
- eventConfigurationApi.updateExternalEventConfigurations("", request).execute();
+ executeVoid(() -> fineractClient.externalEventConfiguration().updateExternalEventConfigurations(null, request, Map.of()));
+ log.info("=== External event configuration updated - all events enabled ===");
+
+ // Step 2: Wait for JMS Listener to be ready before proceeding
+ if (eventProperties != null && eventProperties.isEventVerificationEnabled()) {
+ if (registry == null) {
+ log.warn("=== JmsListenerEndpointRegistry not available - skipping JMS listener readiness check ===");
+ log.warn("=== This is expected in CI environments where JMS may not be fully initialized during suite setup ===");
+ } else {
+ log.info("=== Waiting for JMS Listener to connect to ActiveMQ (max {}s) ===", JMS_STARTUP_TIMEOUT.toSeconds());
+ DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) registry
+ .getListenerContainer("eventStoreListener");
+
+ if (container == null) {
+ log.warn("=== JMS Listener container 'eventStoreListener' not found - event verification may not work ===");
+ } else {
+ await().atMost(JMS_STARTUP_TIMEOUT).pollInterval(Duration.ofMillis(200)).until(container::isRunning);
+ log.info("=== JMS Listener is running and ready to receive events ===");
+ }
+ }
+ }
+
+ log.info("=== ExternalEventSuiteInitializerStep.initializeForSuite() - COMPLETED ===");
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/JobSuiteInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/JobSuiteInitializerStep.java
index db01909a75..3922e44022 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/JobSuiteInitializerStep.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/JobSuiteInitializerStep.java
@@ -18,38 +18,115 @@
*/
package org.apache.fineract.test.initializer.suite;
-import java.io.IOException;
-import lombok.RequiredArgsConstructor;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.ExecuteJobRequest;
import org.apache.fineract.client.models.GetJobsResponse;
import org.apache.fineract.client.models.PutJobsJobIDRequest;
-import org.apache.fineract.client.services.SchedulerJobApi;
import org.springframework.stereotype.Component;
+@Slf4j
@Component
-@RequiredArgsConstructor
public class JobSuiteInitializerStep implements FineractSuiteInitializerStep {
public static final String SEND_ASYNCHRONOUS_EVENTS_JOB_NAME = "Send Asynchronous Events";
public static final String EVERY_1_SECONDS = "0/1 * * * * ?";
public static final String EVERY_60_SECONDS = "0 0/1 * * * ?";
- private final SchedulerJobApi jobApi;
+ private final FineractFeignClient fineractClient;
+
+ public JobSuiteInitializerStep(FineractFeignClient fineractClient) {
+ log.info("=== JobSuiteInitializerStep: Constructor called - bean is being created ===");
+ this.fineractClient = fineractClient;
+ log.info("=== JobSuiteInitializerStep: FineractFeignClient injected successfully ===");
+ }
@Override
- public void initializeForSuite() throws Exception {
- updateExternalEventJobFrequency(EVERY_1_SECONDS);
+ public void initializeForSuite() throws InterruptedException {
+ log.info("=== JobSuiteInitializerStep.initializeForSuite() - START ===");
+ enableAndExecuteEventJob();
+ log.info("=== JobSuiteInitializerStep.initializeForSuite() - COMPLETED successfully ===");
+ }
+
+ private void enableAndExecuteEventJob() throws InterruptedException {
+ log.info("=== Initializing Send Asynchronous Events job ===");
+ Long jobId = updateExternalEventJobFrequency(EVERY_1_SECONDS);
+ log.info("=== Updated cron expression to EVERY_1_SECONDS ===");
+
+ // CRITICAL: SchedulerGlobalInitializerStep stops the scheduler globally
+ // Solution: START the scheduler so the job runs every 1 second automatically
+ log.info("Starting scheduler to enable automatic job execution every 1 second...");
+ executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus("start", Map.of()));
+ log.info("Scheduler started successfully");
+
+ // Manually execute once immediately to publish any queued events from initialization
+ log.info("Manually executing '{}' job once to publish queued events...", SEND_ASYNCHRONOUS_EVENTS_JOB_NAME);
+ executeVoid(() -> fineractClient.schedulerJob().executeJob(jobId, new ExecuteJobRequest(), Map.of("command", "executeJob")));
+
+ // Poll job history to confirm it ran
+ log.info("Polling job history to confirm initial execution...");
+ Long initialRunCount = getJobRunCount(jobId);
+ log.info("Initial job run count: {}", initialRunCount);
+
+ boolean jobRan = false;
+ for (int i = 0; i < 30; i++) {
+ Thread.sleep(200);
+ Long currentRunCount = getJobRunCount(jobId);
+ if (currentRunCount > initialRunCount) {
+ log.info("Job execution confirmed! Run count increased from {} to {}", initialRunCount, currentRunCount);
+ jobRan = true;
+ break;
+ }
+ }
+
+ if (!jobRan) {
+ log.warn("WARNING: Job execution could not be confirmed via history polling");
+ }
+
+ // Wait for events to propagate to ActiveMQ
+ log.info("Waiting 1 second for event propagation to ActiveMQ...");
+ Thread.sleep(1000);
+ log.info("Scheduler is now running - job will execute every 1 second automatically");
+ }
+
+ private Long getJobRunCount(Long jobId) {
+ try {
+ var history = ok(() -> fineractClient.schedulerJob().retrieveHistory(jobId, Map.of()));
+ return (long) history.getTotalFilteredRecords();
+ } catch (Exception e) {
+ log.warn("Failed to retrieve job history: {}", e.getMessage());
+ return 0L;
+ }
}
@Override
- public void resetAfterSuite() throws Exception {
+ public void resetAfterSuite() {
+ log.info("=== JobSuiteInitializerStep.resetAfterSuite() - START ===");
+
+ // Stop the scheduler to prevent jobs from running between test suites
+ log.info("Stopping scheduler...");
+ try {
+ executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus(Map.of("command", "stop")));
+ log.info("Scheduler stopped successfully");
+ } catch (Exception e) {
+ log.warn("Failed to stop scheduler: {}", e.getMessage());
+ }
+
+ // Reset cron expression to default
updateExternalEventJobFrequency(EVERY_60_SECONDS);
+ log.info("=== JobSuiteInitializerStep.resetAfterSuite() - COMPLETED ===");
}
- private void updateExternalEventJobFrequency(String cronExpression) throws IOException {
- GetJobsResponse externalEventJobResponse = jobApi.retrieveAll8().execute().body().stream()
+ private Long updateExternalEventJobFrequency(String cronExpression) {
+ GetJobsResponse externalEventJobResponse = ok(() -> fineractClient.schedulerJob().retrieveAll8()).stream()
.filter(r -> r.getDisplayName().equals(SEND_ASYNCHRONOUS_EVENTS_JOB_NAME)).findAny()
.orElseThrow(() -> new IllegalStateException(SEND_ASYNCHRONOUS_EVENTS_JOB_NAME + " is not found"));
Long jobId = externalEventJobResponse.getJobId();
- jobApi.updateJobDetail(jobId, new PutJobsJobIDRequest().cronExpression(cronExpression)).execute();
+ executeVoid(() -> fineractClient.schedulerJob().updateJobDetail(jobId, new PutJobsJobIDRequest().cronExpression(cronExpression)));
+ return jobId;
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java
index ec1e1fcef8..59406c4ec2 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java
@@ -18,14 +18,15 @@
*/
package org.apache.fineract.test.messaging.event;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.apache.fineract.test.stepdef.loan.LoanRepaymentStepDef.DATE_FORMAT;
import static org.assertj.core.api.Assertions.assertThat;
-import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.time.format.DateTimeFormatter;
import java.util.List;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.avro.client.v1.ClientDataV1;
@@ -36,6 +37,7 @@ import org.apache.fineract.avro.loan.v1.LoanInstallmentDelinquencyBucketDataV1;
import org.apache.fineract.avro.loan.v1.LoanOwnershipTransferDataV1;
import org.apache.fineract.avro.loan.v1.LoanTransactionAdjustmentDataV1;
import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ExternalTransferData;
import org.apache.fineract.client.models.GetClientsClientIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdDelinquencyPausePeriod;
@@ -47,9 +49,6 @@ import org.apache.fineract.client.models.PostClientsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdResponse;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.ClientApi;
-import org.apache.fineract.client.services.ExternalAssetOwnersApi;
-import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.test.data.AssetExternalizationTransferStatus;
import org.apache.fineract.test.data.AssetExternalizationTransferStatusReason;
import org.apache.fineract.test.data.TransactionType;
@@ -83,7 +82,6 @@ import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransaction
import org.apache.fineract.test.messaging.event.loan.transaction.LoanUndoContractTerminationBusinessEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Slf4j
@Component
@@ -91,103 +89,85 @@ import retrofit2.Response;
public class EventCheckHelper {
private static final DateTimeFormatter FORMATTER_EVENTS = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ private static final long TRANSACTION_COMMIT_DELAY_MS = 500L;
@Autowired
- private ClientApi clientApi;
- @Autowired
- private LoansApi loansApi;
+ private FineractFeignClient fineractClient;
@Autowired
private EventAssertion eventAssertion;
@Autowired
- private ExternalAssetOwnersApi externalAssetOwnersApi;
- @Autowired
private GlobalConfigurationHelper configurationHelper;
+ @Autowired
+ private org.apache.fineract.test.messaging.config.EventProperties eventProperties;
+
+ private void waitForTransactionCommit() {
+ if (eventProperties.isEventVerificationEnabled() && TRANSACTION_COMMIT_DELAY_MS > 0) {
+ try {
+ Thread.sleep(TRANSACTION_COMMIT_DELAY_MS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException("Interrupted while waiting for transaction commit", e);
+ }
+ }
+ }
- public void clientEventCheck(Response<PostClientsResponse> clientCreationResponse) throws IOException {
- Response<GetClientsClientIdResponse> clientDetails = clientApi.retrieveOne11(clientCreationResponse.body().getClientId(), false)
- .execute();
+ public void clientEventCheck(PostClientsResponse clientCreationResponse) {
+ waitForTransactionCommit();
+ GetClientsClientIdResponse body = ok(() -> fineractClient.clients().retrieveOne11(clientCreationResponse.getClientId(),
+ Map.of("staffInSelectedOfficeOnly", false)));
- GetClientsClientIdResponse body = clientDetails.body();
Long clientId = Long.valueOf(body.getId());
Integer status = body.getStatus().getId().intValue();
String firstname = body.getFirstname();
String lastname = body.getLastname();
Boolean active = body.getActive();
- eventAssertion.assertEvent(ClientCreatedEvent.class, clientCreationResponse.body().getClientId())//
+ eventAssertion.assertEvent(ClientCreatedEvent.class, clientCreationResponse.getClientId())//
.extractingData(ClientDataV1::getId).isEqualTo(clientId)//
.extractingData(clientDataV1 -> clientDataV1.getStatus().getId()).isEqualTo(status)//
.extractingData(ClientDataV1::getFirstname).isEqualTo(firstname)//
.extractingData(ClientDataV1::getLastname).isEqualTo(lastname)//
.extractingData(ClientDataV1::getActive).isEqualTo(active);//
- eventAssertion.assertEvent(ClientActivatedEvent.class, clientCreationResponse.body().getClientId())//
+ eventAssertion.assertEvent(ClientActivatedEvent.class, clientCreationResponse.getClientId())//
.extractingData(ClientDataV1::getActive).isEqualTo(true)//
.extractingData(clientDataV1 -> clientDataV1.getStatus().getId()).isEqualTo(status);//
}
- public void createLoanEventCheck(Response<PostLoansResponse> createLoanResponse) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(createLoanResponse.body().getLoanId(), false, "all", "", "")
- .execute();
- GetLoansLoanIdResponse body = loanDetails.body();
-
- eventAssertion.assertEvent(LoanCreatedEvent.class, createLoanResponse.body().getLoanId())//
- .extractingData(LoanAccountDataV1::getId).isEqualTo(body.getId())//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
- .extractingData(LoanAccountDataV1::getClientId).isEqualTo(body.getClientId())//
- .extractingBigDecimal(LoanAccountDataV1::getPrincipal).isEqualTo(body.getPrincipal())//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
- .isEqualTo(body.getCurrency().getCode());//
- }
-
- public void approveLoanEventCheck(Response<PostLoansLoanIdResponse> loanApproveResponse) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanApproveResponse.body().getLoanId(), false, "", "", "")
- .execute();
- GetLoansLoanIdResponse body = loanDetails.body();
-
- eventAssertion.assertEvent(LoanApprovedEvent.class, loanApproveResponse.body().getLoanId())//
- .extractingData(LoanAccountDataV1::getId).isEqualTo(body.getId())//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getCode()).isEqualTo(body.getStatus().getCode())//
- .extractingData(LoanAccountDataV1::getClientId).isEqualTo(Long.valueOf(body.getClientId()))//
- .extractingBigDecimal(LoanAccountDataV1::getApprovedPrincipal).isEqualTo(body.getApprovedPrincipal())//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getTimeline().getApprovedOnDate())//
- .isEqualTo(FORMATTER_EVENTS.format(body.getTimeline().getApprovedOnDate()))//
- .extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
- .isEqualTo(body.getCurrency().getCode());//
- }
-
- public void undoApproveLoanEventCheck(Response<PostLoansLoanIdResponse> loanUndoApproveResponse) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanUndoApproveResponse.body().getLoanId(), false, "", "", "")
- .execute();
- GetLoansLoanIdResponse body = loanDetails.body();
+ public void undoApproveLoanEventCheck(PostLoansLoanIdResponse loanUndoApproveResponse) {
+ waitForTransactionCommit();
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanUndoApproveResponse.getLoanId(),
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "", "exclude", "", "fields", "")));
eventAssertion.assertEventRaised(LoanUndoApprovalEvent.class, body.getId());
}
- public void loanRejectedEventCheck(Response<PostLoansLoanIdResponse> loanRejectedResponse) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanRejectedResponse.body().getLoanId(), false, "", "", "")
- .execute();
- GetLoansLoanIdResponse body = loanDetails.body();
+ public void loanRejectedEventCheck(PostLoansLoanIdResponse loanRejectedResponse) {
+ waitForTransactionCommit();
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanRejectedResponse.getLoanId(),
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "", "exclude", "", "fields", "")));
eventAssertion.assertEventRaised(LoanRejectedEvent.class, body.getId());
}
- public void disburseLoanEventCheck(Long loanId) throws IOException {
+ public void disburseLoanEventCheck(Long loanId) {
+ waitForTransactionCommit();
loanAccountDataV1Check(LoanDisbursalEvent.class, loanId);
}
- public void loanBalanceChangedEventCheck(Long loanId) throws IOException {
+ public void loanBalanceChangedEventCheck(Long loanId) {
+ waitForTransactionCommit();
loanAccountDataV1Check(LoanBalanceChangedEvent.class, loanId);
}
- public void loanStatusChangedEventCheck(Long loanId) throws IOException {
+ public void loanStatusChangedEventCheck(Long loanId) {
+ waitForTransactionCommit();
loanAccountDataV1Check(LoanStatusChangedEvent.class, loanId);
}
- private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClazz, Long loanId) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "all", "", "").execute();
- GetLoansLoanIdResponse body = loanDetails.body();
+ private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClazz, Long loanId) {
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanId,
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
eventAssertion.assertEvent(eventClazz, loanId)//
.extractingData(loanAccountDataV1 -> {
@@ -254,10 +234,10 @@ public class EventCheckHelper {
return targetTransaction;
}
- public GetLoansLoanIdTransactions findNthTransaction(String nthItemStr, String transactionType, String transactionDate, long loanId)
- throws IOException {
- List<GetLoansLoanIdTransactions> transactions = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute().body()
- .getTransactions();
+ public GetLoansLoanIdTransactions findNthTransaction(String nthItemStr, String transactionType, String transactionDate, long loanId) {
+ GetLoansLoanIdResponse loanResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "transactions", "exclude", "", "fields", "")));
+ List<GetLoansLoanIdTransactions> transactions = loanResponse.getTransactions();
GetLoansLoanIdTransactions targetTransaction = getNthTransactionType(nthItemStr, transactionType, transactionDate, transactions);
return targetTransaction;
}
@@ -276,6 +256,7 @@ public class EventCheckHelper {
}
public void loanUndoContractTerminationEventCheck(final GetLoansLoanIdTransactions transaction) {
+ waitForTransactionCommit();
eventAssertion.assertEventRaised(LoanUndoContractTerminationBusinessEvent.class, transaction.getId());
}
@@ -286,12 +267,12 @@ public class EventCheckHelper {
return actual.compareTo(expected) == 0;
}
- public void loanDisbursalTransactionEventCheck(Response<PostLoansLoanIdResponse> loanDisburseResponse) throws IOException {
- Long disbursementTransactionId = loanDisburseResponse.body().getSubResourceId();
+ public void loanDisbursalTransactionEventCheck(PostLoansLoanIdResponse loanDisburseResponse) {
+ waitForTransactionCommit();
+ Long disbursementTransactionId = loanDisburseResponse.getSubResourceId();
- Response<GetLoansLoanIdResponse> loanDetails = loansApi
- .retrieveLoan(loanDisburseResponse.body().getLoanId(), false, "transactions", "", "").execute();
- GetLoansLoanIdResponse body = loanDetails.body();
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanDisburseResponse.getLoanId(),
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "transactions", "exclude", "", "fields", "")));
List<GetLoansLoanIdTransactions> transactions = body.getTransactions();
GetLoansLoanIdTransactions disbursementTransaction = transactions//
.stream()//
@@ -306,12 +287,12 @@ public class EventCheckHelper {
}
public EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> transactionEventCheck(
- Response<PostLoansLoanIdTransactionsResponse> transactionResponse, TransactionType transactionType, String externalOwnerId)
- throws IOException {
- Long loanId = transactionResponse.body().getLoanId();
- Long transactionId = transactionResponse.body().getResourceId();
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ PostLoansLoanIdTransactionsResponse transactionResponse, TransactionType transactionType, String externalOwnerId) {
+ Long loanId = transactionResponse.getLoanId();
+ Long transactionId = transactionResponse.getResourceId();
+ GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "transactions", "exclude", "", "fields", "")));
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
GetLoansLoanIdTransactions transactionFound = transactions//
.stream()//
.filter(t -> t.getId().equals(transactionId))//
@@ -330,16 +311,17 @@ public class EventCheckHelper {
};
EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> eventBuilder = eventAssertion.assertEvent(eventClass, transactionId);
- eventBuilder.extractingData(LoanTransactionDataV1::getLoanId).isEqualTo(loanDetailsResponse.body().getId())//
+ eventBuilder.extractingData(LoanTransactionDataV1::getLoanId).isEqualTo(loanDetailsResponse.getId())//
.extractingData(LoanTransactionDataV1::getDate).isEqualTo(FORMATTER_EVENTS.format(transactionFound.getDate()))//
.extractingBigDecimal(LoanTransactionDataV1::getAmount).isEqualTo(transactionFound.getAmount())//
.extractingData(LoanTransactionDataV1::getExternalOwnerId).isEqualTo(externalOwnerId);//
return eventBuilder;
}
- public void loanOwnershipTransferBusinessEventCheck(Long loanId, Long transferId) throws IOException {
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- List<ExternalTransferData> content = response.body().getContent();
+ public void loanOwnershipTransferBusinessEventCheck(Long loanId, Long transferId) {
+ waitForTransactionCommit();
+ PageExternalTransferData response = ok(() -> fineractClient.externalAssetOwners().getTransfers(Map.of("loanId", loanId)));
+ List<ExternalTransferData> content = response.getContent();
ExternalTransferData filtered = content.stream().filter(t -> transferId.equals(t.getTransferId())).reduce((first, second) -> second)
.orElseThrow(() -> new IllegalStateException("No element found"));
@@ -368,9 +350,9 @@ public class EventCheckHelper {
}
public void loanOwnershipTransferBusinessEventWithStatusCheck(Long loanId, Long transferId, String transferStatus,
- String transferStatusReason) throws IOException {
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- List<ExternalTransferData> content = response.body().getContent();
+ String transferStatusReason) {
+ PageExternalTransferData response = ok(() -> fineractClient.externalAssetOwners().getTransfers(Map.of("loanId", loanId)));
+ List<ExternalTransferData> content = response.getContent();
ExternalTransferData filtered = content.stream().filter(t -> transferId.equals(t.getTransferId())).reduce((first, second) -> second)
.orElseThrow(() -> new IllegalStateException("No element found"));
@@ -414,9 +396,9 @@ public class EventCheckHelper {
}
public void loanOwnershipTransferBusinessEventWithTypeCheck(Long loanId, ExternalTransferData transferData, String transferType,
- String previousAssetOwner) throws IOException {
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- List<ExternalTransferData> content = response.body().getContent();
+ String previousAssetOwner) {
+ PageExternalTransferData response = ok(() -> fineractClient.externalAssetOwners().getTransfers(Map.of("loanId", loanId)));
+ List<ExternalTransferData> content = response.getContent();
Long transferId = transferData.getTransferId();
String assetOwner = transferData.getOwner() == null ? null : transferData.getOwner().getExternalId();
@@ -454,9 +436,10 @@ public class EventCheckHelper {
.extractingData(LoanOwnershipTransferDataV1::getPreviousOwnerExternalId).isEqualTo(previousAssetOwner);
}
- public void loanAccountSnapshotBusinessEventCheck(Long loanId, Long transferId) throws IOException {
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- List<ExternalTransferData> content = response.body().getContent();
+ public void loanAccountSnapshotBusinessEventCheck(Long loanId, Long transferId) {
+ waitForTransactionCommit();
+ PageExternalTransferData response = ok(() -> fineractClient.externalAssetOwners().getTransfers(Map.of("loanId", loanId)));
+ List<ExternalTransferData> content = response.getContent();
ExternalTransferData filtered = content.stream().filter(t -> transferId.equals(t.getTransferId())).reduce((first, second) -> second)
.orElseThrow(() -> new IllegalStateException("No element found"));
@@ -467,9 +450,10 @@ public class EventCheckHelper {
GlobalConfigurationPropertyData outstandingInterestStrategy = configurationHelper
.getGlobalConfiguration("outstanding-interest-calculation-strategy-for-external-asset-transfer");
if ("PAYABLE_OUTSTANDING_INTEREST".equals(outstandingInterestStrategy.getStringValue())) {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "all", null, null).execute();
- totalOutstandingBalanceAmountExpected = zeroConversion(loanDetails.body().getSummary().getTotalOutstanding());
- outstandingInterestPortionExpected = zeroConversion(loanDetails.body().getSummary().getInterestOutstanding());
+ GetLoansLoanIdResponse loanDetails = ok(() -> fineractClient.loans().retrieveLoan(loanId,
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
+ totalOutstandingBalanceAmountExpected = zeroConversion(loanDetails.getSummary().getTotalOutstanding());
+ outstandingInterestPortionExpected = zeroConversion(loanDetails.getSummary().getInterestOutstanding());
}
String ownerExternalIdExpected = filtered.getStatus().getValue().equals("BUYBACK") ? null : filtered.getOwner().getExternalId();
@@ -498,10 +482,11 @@ public class EventCheckHelper {
.isEqualTo(overPaymentPortionExpected);
}
- public void loanAccountDelinquencyPauseChangedBusinessEventCheck(Long loanId) throws IOException {
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "all", "", "").execute();
- List<GetLoansLoanIdDelinquencyPausePeriod> delinquencyPausePeriodsActual = loanDetails.body().getDelinquent()
- .getDelinquencyPausePeriods();
+ public void loanAccountDelinquencyPauseChangedBusinessEventCheck(Long loanId) {
+ waitForTransactionCommit();
+ GetLoansLoanIdResponse loanDetails = ok(() -> fineractClient.loans().retrieveLoan(loanId,
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
+ List<GetLoansLoanIdDelinquencyPausePeriod> delinquencyPausePeriodsActual = loanDetails.getDelinquent().getDelinquencyPausePeriods();
eventAssertion.assertEvent(LoanDelinquencyPauseChangedEvent.class, loanId)//
.extractingData(LoanAccountDataV1::getId).isEqualTo(loanId)//
@@ -539,6 +524,7 @@ public class EventCheckHelper {
}
public void installmentLevelDelinquencyRangeChangeEventCheck(Long loanId) {
+ waitForTransactionCommit();
eventAssertion.assertEvent(LoanDelinquencyRangeChangeEvent.class, loanId).extractingData(loanAccountDelinquencyRangeDataV1 -> {
// check if sum of total amounts equal the sum of amount types in installmentDelinquencyBuckets
BigDecimal totalAmountSum = loanAccountDelinquencyRangeDataV1.getInstallmentDelinquencyBuckets().stream()//
@@ -582,4 +568,36 @@ public class EventCheckHelper {
private BigDecimal zeroConversion(BigDecimal input) {
return input.compareTo(new BigDecimal("0.000000")) == 0 ? new BigDecimal(input.toEngineeringString()) : input.setScale(8);
}
+
+ public void createLoanEventCheck(PostLoansResponse createLoanResponse) {
+ waitForTransactionCommit();
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(createLoanResponse.getLoanId(),
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
+
+ eventAssertion.assertEvent(LoanCreatedEvent.class, createLoanResponse.getLoanId())//
+ .extractingData(LoanAccountDataV1::getId).isEqualTo(body.getId())//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
+ .extractingData(LoanAccountDataV1::getClientId).isEqualTo(body.getClientId())//
+ .extractingBigDecimal(LoanAccountDataV1::getPrincipal).isEqualTo(body.getPrincipal())//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
+ .isEqualTo(body.getCurrency().getCode());//
+ }
+
+ public void approveLoanEventCheck(PostLoansLoanIdResponse loanApproveResponse) {
+ waitForTransactionCommit();
+ GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanApproveResponse.getLoanId(),
+ Map.of("staffInSelectedOfficeOnly", false, "associations", "", "exclude", "", "fields", "")));
+
+ eventAssertion.assertEvent(LoanApprovedEvent.class, loanApproveResponse.getLoanId())//
+ .extractingData(LoanAccountDataV1::getId).isEqualTo(body.getId())//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getCode()).isEqualTo(body.getStatus().getCode())//
+ .extractingData(LoanAccountDataV1::getClientId).isEqualTo(Long.valueOf(body.getClientId()))//
+ .extractingBigDecimal(LoanAccountDataV1::getApprovedPrincipal).isEqualTo(body.getApprovedPrincipal())//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getTimeline().getApprovedOnDate())//
+ .isEqualTo(FORMATTER_EVENTS.format(body.getTimeline().getApprovedOnDate()))//
+ .extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
+ .isEqualTo(body.getCurrency().getCode());//
+ }
+
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/store/MessageConsumer.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/store/MessageConsumer.java
index 9f6206a9bf..8f67d43db5 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/store/MessageConsumer.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/store/MessageConsumer.java
@@ -29,7 +29,7 @@ public class MessageConsumer {
private final EventStore eventStore;
- @JmsListener(destination = "${fineract-test.messaging.jms.topic-name}")
+ @JmsListener(id = "eventStoreListener", destination = "${fineract-test.messaging.jms.topic-name}")
public void receiveMessage(ActiveMQBytesMessage message) {
try {
byte[] buffer = new byte[(int) message.getBodyLength()];
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/service/JobService.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/service/JobService.java
index 26c9e27194..e18f660098 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/service/JobService.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/service/JobService.java
@@ -18,23 +18,24 @@
*/
package org.apache.fineract.test.service;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.awaitility.Awaitility.await;
-import java.io.IOException;
import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ExecuteJobRequest;
import org.apache.fineract.client.models.GetJobsResponse;
-import org.apache.fineract.client.services.SchedulerJobApi;
import org.apache.fineract.test.data.job.Job;
import org.apache.fineract.test.data.job.JobResolver;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.messaging.config.JobPollingProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
@Component
@RequiredArgsConstructor
@@ -42,7 +43,7 @@ import retrofit2.Response;
public class JobService {
@Autowired
- private SchedulerJobApi schedulerJobApi;
+ private FineractFeignClient fineractClient;
@Autowired
private JobPollingProperties jobPollingProperties;
@@ -50,13 +51,10 @@ public class JobService {
private final JobResolver jobResolver;
public void execute(Job job) {
- try {
- Long jobId = jobResolver.resolve(job);
- Response<Void> response = schedulerJobApi.executeJob(jobId, "executeJob", new ExecuteJobRequest()).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- } catch (IOException e) {
- throw new RuntimeException("Exception while executing job %s".formatted(job.getName()), e);
- }
+ Long jobId = jobResolver.resolve(job);
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("command", "executeJob");
+ executeVoid(() -> fineractClient.schedulerJob().executeJob(jobId, new ExecuteJobRequest(), queryParams));
}
public void executeAndWait(Job job) {
@@ -73,9 +71,8 @@ public class JobService {
.until(() -> {
log.debug("Waiting for job {} to finish", jobName);
Long jobId = jobResolver.resolve(job);
- Response<GetJobsResponse> getJobsResponse = schedulerJobApi.retrieveOne5(jobId).execute();
- ErrorHelper.checkSuccessfulApiCall(getJobsResponse);
- Boolean currentlyRunning = getJobsResponse.body().getCurrentlyRunning();
+ GetJobsResponse getJobsResponse = ok(() -> fineractClient.schedulerJob().retrieveOne5(jobId));
+ Boolean currentlyRunning = getJobsResponse.getCurrentlyRunning();
return BooleanUtils.isFalse(currentlyRunning);
});
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java
index 42684603cf..868fe05b7d 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java
@@ -36,9 +36,9 @@
*/
package org.apache.fineract.test.stepdef.assetexternalization;
+import static org.apache.fineract.client.feign.util.FeignCalls.fail;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
@@ -46,10 +46,17 @@ import java.io.IOException;
import java.math.RoundingMode;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.client.models.CommandProcessingResult;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.services.ExternalAssetOwnerLoanProductAttributesApi;
+import org.apache.fineract.client.feign.services.ExternalAssetOwnersApi;
+import org.apache.fineract.client.feign.services.ExternalAssetOwnersApiExtension;
+import org.apache.fineract.client.feign.services.LoanProductsApi;
+import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.ExternalAssetOwnerRequest;
import org.apache.fineract.client.models.ExternalOwnerJournalEntryData;
import org.apache.fineract.client.models.ExternalOwnerTransferJournalEntryData;
@@ -63,15 +70,8 @@ import org.apache.fineract.client.models.PostExternalAssetOwnerLoanProductAttrib
import org.apache.fineract.client.models.PostInitiateTransferResponse;
import org.apache.fineract.client.models.PostLoansResponse;
import org.apache.fineract.client.models.PutExternalAssetOwnerLoanProductAttributeRequest;
-import org.apache.fineract.client.services.ExternalAssetOwnerLoanProductAttributesApi;
-import org.apache.fineract.client.services.ExternalAssetOwnersApi;
-import org.apache.fineract.client.services.LoanProductsApi;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.data.AssetExternalizationErrorMessage;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
-import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.helper.Utils;
import org.apache.fineract.test.messaging.EventAssertion;
import org.apache.fineract.test.messaging.event.EventCheckHelper;
@@ -79,7 +79,6 @@ import org.apache.fineract.test.messaging.event.assetexternalization.LoanOwnersh
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class AssetExternalizationStepDef extends AbstractStepDef {
@@ -91,10 +90,9 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
public static final String TRANSACTION_TYPE_BUYBACK = "buyback";
public static final String TRANSACTION_TYPE_INTERMEDIARY_SALE = "intermediarySale";
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT_ASSET_EXT);
- private static final Gson GSON = new JSON().getGson();
@Autowired
- private ExternalAssetOwnersApi externalAssetOwnersApi;
+ private FineractFeignClient fineractFeignClient;
@Autowired
private EventCheckHelper eventCheckHelper;
@@ -102,6 +100,22 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Autowired
private EventAssertion eventAssertion;
+ private ExternalAssetOwnersApi externalAssetOwnersApi() {
+ return fineractFeignClient.externalAssetOwners();
+ }
+
+ private ExternalAssetOwnersApiExtension externalAssetOwnersApiExtension() {
+ return fineractFeignClient.externalAssetOwnersExtension();
+ }
+
+ private LoanProductsApi loanProductsApi() {
+ return fineractFeignClient.loanProducts();
+ }
+
+ private ExternalAssetOwnerLoanProductAttributesApi externalAssetOwnerLoanProductAttributesApi() {
+ return fineractFeignClient.externalAssetOwnerLoanProductAttributes();
+ }
+
@When("Admin makes asset externalization request by Loan ID with unique ownerExternalId, user-generated transferExternalId and the following data:")
public void createAssetExternalizationRequestByLoanIdUserGeneratedExtId(DataTable table) throws IOException {
// if user created transferExternalId previously, it will use that, otherwise create a new one
@@ -128,8 +142,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest();
if (transferData.get(0).equals(TRANSACTION_TYPE_BUYBACK)) {
@@ -138,12 +152,11 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, transferData.get(0)).execute();
+ PostInitiateTransferResponse response = externalAssetOwnersApi().transferRequestWithLoanId(loanId, request, transferData.get(0),
+ Collections.emptyMap());
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE, response);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_BUYBACK_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
- ErrorHelper.checkSuccessfulApiCall(response);
+ response.getResourceExternalId());
} else if ((transferData.get(0).equals(TRANSACTION_TYPE_SALE) || transferData.get(0).equals(TRANSACTION_TYPE_INTERMEDIARY_SALE))) {
String ownerExternalId;
@@ -160,21 +173,18 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, transferData.get(0)).execute();
+ PostInitiateTransferResponse response = externalAssetOwnersApi().transferRequestWithLoanId(loanId, request,
+ Map.of("command", transferData.get(0)));
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE, response);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
+ response.getResourceExternalId());
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID, ownerExternalId);
if (transferData.get(0).equals(TRANSACTION_TYPE_INTERMEDIARY_SALE)) {
assertThat(ownerExternalId).isNotNull();
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_PREVIOUS_OWNER_EXTERNAL_ID, ownerExternalId);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_INTERMEDIARY_SALE_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
+ response.getResourceExternalId());
}
-
- ErrorHelper.checkSuccessfulApiCall(response);
-
} else {
throw new IllegalStateException(String.format("%s is not supported Asset externalization transaction", transferData.get(0)));
}
@@ -182,8 +192,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@When("Admin makes asset externalization BUYBACK request with ownerExternalId = null and settlement date {string} by Loan ID with system-generated transferExternalId")
public void createAssetExternalizationBuybackRequestOwnerNullByLoanIdSystemGeneratedExtId(String settlementDate) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest()//
.settlementDate(settlementDate)//
@@ -192,12 +202,11 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, TRANSACTION_TYPE_BUYBACK).execute();
+ PostInitiateTransferResponse response = externalAssetOwnersApi().transferRequestWithLoanId(loanId, request,
+ Map.of("command", TRANSACTION_TYPE_BUYBACK));
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE, response);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_BUYBACK_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
- ErrorHelper.checkSuccessfulApiCall(response);
+ response.getResourceExternalId());
}
@When("Admin makes asset externalization request by Loan external ID with unique ownerExternalId, user-generated transferExternalId and the following data:")
@@ -221,8 +230,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- String loanExternalId = loanResponse.body().getResourceExternalId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ String loanExternalId = loanResponse.getResourceExternalId();
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest();
if (transferData.get(0).equals(TRANSACTION_TYPE_BUYBACK)) {
@@ -231,13 +240,11 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanExternalId(loanExternalId, request, transferData.get(0)).execute();
+ PostInitiateTransferResponse response = externalAssetOwnersApi().transferRequestWithLoanExternalId(loanExternalId, request,
+ Map.of("command", transferData.get(0)));
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE, response);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_BUYBACK_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
- ErrorHelper.checkSuccessfulApiCall(response);
-
+ response.getResourceExternalId());
} else if (transferData.get(0).equals(TRANSACTION_TYPE_SALE)) {
String ownerExternalId = Utils.randomNameGenerator(OWNER_EXTERNAL_ID_PREFIX, 3);
@@ -248,14 +255,12 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanExternalId(loanExternalId, request, transferData.get(0)).execute();
+ PostInitiateTransferResponse response = externalAssetOwnersApi().transferRequestWithLoanExternalId(loanExternalId, request,
+ Map.of("command", transferData.get(0)));
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE, response);
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
- response.body().getResourceExternalId());
+ response.getResourceExternalId());
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID, ownerExternalId);
- ErrorHelper.checkSuccessfulApiCall(response);
-
} else {
throw new IllegalStateException(String.format("%s is not supported Asset externalization transaction", transferData.get(0)));
}
@@ -267,13 +272,12 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
String transferExternalIdExpected = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostInitiateTransferResponse> response = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
- PostInitiateTransferResponse body = response.body();
- Long loanIdActual = body.getSubResourceId();
- String transferExternalIdActual = body.getResourceExternalId();
+ PostInitiateTransferResponse response = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
+ Long loanIdActual = response.getSubResourceId();
+ String transferExternalIdActual = response.getResourceExternalId();
log.debug("loanId: {}", loanId);
log.debug("ownerExternalIdStored: {}", ownerExternalIdStored);
@@ -281,7 +285,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
log.debug("transferExternalIdActual: {}", transferExternalIdActual);
assertThat(loanIdActual).as(ErrorMessageHelper.wrongDataInAssetExternalizationResponse(loanIdActual, loanId)).isEqualTo(loanId);
- assertThat(body.getResourceId()).isNotNull();
+ assertThat(response.getResourceId()).isNotNull();
if (transferExternalIdExpected != null) {
assertThat(transferExternalIdActual)
.as(ErrorMessageHelper.wrongDataInAssetExternalizationResponse(transferExternalIdActual, transferExternalIdExpected))
@@ -293,23 +297,20 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("Fetching Asset externalization details by loan id gives numberOfElements: {int} with correct ownerExternalId and the following data:")
public void checkAssetExternalizationDetailsByLoanId(int numberOfElements, DataTable table) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PageExternalTransferData response = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
checkExternalAssetDetails(loanId, null, response, numberOfElements, table);
}
@Then("Fetching Asset externalization details by loan external id gives numberOfElements: {int} with correct ownerExternalId and the following data:")
public void checkAssetExternalizationDetailsByLoanExternalId(int numberOfElements, DataTable table) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- String loanExternalId = loanResponse.body().getResourceExternalId();
-
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, null, loanExternalId, null, null).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ String loanExternalId = loanResponse.getResourceExternalId();
+ PageExternalTransferData response = externalAssetOwnersApi().getTransfers(Map.of("loanExternalId", loanExternalId));
checkExternalAssetDetails(null, loanExternalId, response, numberOfElements, table);
}
@@ -317,24 +318,21 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
public void checkAssetExternalizationDetailsByTransferExternalId(int numberOfElements, DataTable table) throws IOException {
String transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(transferExternalId, null, null, null, null)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(response);
-
+ PageExternalTransferData response = externalAssetOwnersApi().getTransfers(Map.of("transferExternalId", transferExternalId),
+ Map.of());
checkExternalAssetDetails(null, null, response, numberOfElements, table);
}
@Then("Asset externalization details has the generated transferExternalId")
public void checkGeneratedTransferExternalId() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostInitiateTransferResponse> assetExtResponse = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
- String transferExternalIdExpected = assetExtResponse.body().getResourceExternalId();
+ PostInitiateTransferResponse assetExtResponse = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
+ String transferExternalIdExpected = assetExtResponse.getResourceExternalId();
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- List<ExternalTransferData> content = response.body().getContent();
+ PageExternalTransferData response = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
+ List<ExternalTransferData> content = response.getContent();
content.forEach(e -> {
assertThat(e.getTransferExternalId()).as(ErrorMessageHelper
@@ -343,11 +341,10 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
});
}
- private void checkExternalAssetDetails(Long loanId, String loanExternalId, Response<PageExternalTransferData> response,
- int numberOfElements, DataTable table) {
- PageExternalTransferData body = response.body();
- Integer numberOfElementsActual = body.getNumberOfElements();
- List<ExternalTransferData> content = body.getContent();
+ private void checkExternalAssetDetails(Long loanId, String loanExternalId, PageExternalTransferData response, int numberOfElements,
+ DataTable table) {
+ Integer numberOfElementsActual = response.getNumberOfElements();
+ List<ExternalTransferData> content = response.getContent();
String transferExternalId;
String ownerExternalIdStored = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
@@ -457,34 +454,32 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
String transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
+ PageExternalTransferData transfers = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
+ String settlementDateOriginal = FORMATTER.format(transfers.getContent().get(0).getSettlementDate());
+ String errorMessageExpected = String.format(
+ "This loan cannot be bought back, settlement date is earlier than effective transfer settlement date: %s",
+ settlementDateOriginal);
+
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest()//
.settlementDate(transferData.get(1))//
.transferExternalId(transferExternalId)//
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, transferData.get(0)).execute();
-
- PageExternalTransferData transfers = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute().body();
- String settlementDateOriginal = FORMATTER.format(transfers.getContent().get(0).getSettlementDate());
- String errorMessageExpected = String.format(
- "This loan cannot be bought back, settlement date is earlier than effective transfer settlement date: %s",
- settlementDateOriginal);
+ CallFailedRuntimeException exception = fail(
+ () -> externalAssetOwnersApi().transferRequestWithLoanId(loanId, request, Map.of("command", transferData.get(0))));
- String errorToString = response.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorToString, ErrorResponse.class);
- String errorMessageActual = errorResponse.getDeveloperMessage();
- int errorCodeActual = response.code();
+ int errorCodeActual = exception.getStatus();
+ String errorMessageActual = exception.getDeveloperMessage();
assertThat(errorCodeActual).as(ErrorMessageHelper.wrongErrorCode(errorCodeActual, errorCodeExpected)).isEqualTo(errorCodeExpected);
assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
- .isEqualTo(errorMessageExpected);
+ .contains(errorMessageExpected);
log.debug("ERROR CODE: {}", errorCodeActual);
log.debug("ERROR MESSAGE: {}", errorMessageActual);
@@ -495,8 +490,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest();
if (transferData.get(0).equals(TRANSACTION_TYPE_BUYBACK)) {
@@ -519,20 +514,23 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("%s is not supported Asset externalization transaction", transferData.get(0)));
}
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, transferData.get(0)).execute();
-
AssetExternalizationErrorMessage errorMsgType = AssetExternalizationErrorMessage.valueOf(errorMessageType);
String errorMessageExpected = errorMsgType.getValue();
- String errorToString = response.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorToString, ErrorResponse.class);
- String errorMessageActual = errorResponse.getDeveloperMessage();
- int errorCodeActual = response.code();
+ CallFailedRuntimeException exception = fail(
+ () -> externalAssetOwnersApi().transferRequestWithLoanId(loanId, request, Map.of("command", transferData.get(0))));
+
+ int errorCodeActual = exception.getStatus();
+ String errorMessageActual = exception.getDeveloperMessage();
assertThat(errorCodeActual).as(ErrorMessageHelper.wrongErrorCode(errorCodeActual, errorCodeExpected)).isEqualTo(errorCodeExpected);
- assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
- .isEqualTo(errorMessageExpected);
+ if (errorMessageType.equals("INVALID_REQUEST")) {
+ assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
+ .containsAnyOf("Validation errors:", errorMessageExpected);
+ } else {
+ assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
+ .contains(errorMessageExpected);
+ }
log.debug("ERROR CODE: {}", errorCodeActual);
log.debug("ERROR MESSAGE: {}", errorMessageActual);
@@ -543,8 +541,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest()//
.settlementDate(transferData.get(0))//
@@ -554,20 +552,23 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.dateFormat(DATE_FORMAT_ASSET_EXT)//
.locale(DEFAULT_LOCALE);//
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi
- .transferRequestWithLoanId(loanId, request, TRANSACTION_TYPE_SALE).execute();
-
AssetExternalizationErrorMessage errorMsgType = AssetExternalizationErrorMessage.valueOf(errorMessageType);
String errorMessageExpected = errorMsgType.getValue();
- String errorToString = response.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorToString, ErrorResponse.class);
- String errorMessageActual = errorResponse.getDeveloperMessage();
- int errorCodeActual = response.code();
+ CallFailedRuntimeException exception = fail(
+ () -> externalAssetOwnersApi().transferRequestWithLoanId(loanId, request, Map.of("command", TRANSACTION_TYPE_SALE)));
+
+ int errorCodeActual = exception.getStatus();
+ String errorMessageActual = exception.getDeveloperMessage();
assertThat(errorCodeActual).as(ErrorMessageHelper.wrongErrorCode(errorCodeActual, errorCodeExpected)).isEqualTo(errorCodeExpected);
- assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
- .isEqualTo(errorMessageExpected);
+ if (errorMessageType.equals("INVALID_REQUEST")) {
+ assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
+ .containsAnyOf("Validation errors:", errorMessageExpected);
+ } else {
+ assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
+ .contains(errorMessageExpected);
+ }
log.debug("ERROR CODE: {}", errorCodeActual);
log.debug("ERROR MESSAGE: {}", errorMessageActual);
@@ -575,14 +576,14 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("The latest asset externalization transaction with {string} status has the following TRANSFER Journal entries:")
public void checkJournalEntriesTransaction(String status, DataTable table) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Long lastTransferIdByStatus = getLastTransferIdByStatus(loanId, status);
- Response<ExternalOwnerTransferJournalEntryData> journalEntriesOfTransfer = externalAssetOwnersApi
- .getJournalEntriesOfTransfer(lastTransferIdByStatus, null, null).execute();
- List<JournalEntryData> content = journalEntriesOfTransfer.body().getJournalEntryData().getContent();
+ ExternalOwnerTransferJournalEntryData journalEntriesOfTransfer = externalAssetOwnersApi()
+ .getJournalEntriesOfTransfer(lastTransferIdByStatus, Map.of());
+ List<JournalEntryData> content = journalEntriesOfTransfer.getJournalEntryData().getContent();
List<List<String>> data = table.asLists();
int linesExpected = data.size() - 1;
@@ -603,22 +604,21 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
assertThat(containsExpectedValues)
.as(ErrorMessageHelper.wrongValueInLineInAssetExternalizationJournalEntry(i, actualValuesList, expectedValues))
.isTrue();
-
- int linesActual = journalEntriesOfTransfer.body().getJournalEntryData().getNumberOfElements();
- assertThat(linesActual).as(ErrorMessageHelper.wrongNumberOfLinesInAssetExternalizationJournalEntry(linesActual, linesExpected))
- .isEqualTo(linesExpected);
}
- log.debug("loanId: {}", journalEntriesOfTransfer.body().getTransferData().getLoan().getLoanId());
- log.debug("ownerExternalId: {}", journalEntriesOfTransfer.body().getTransferData().getOwner().getExternalId());
+ int linesActual = journalEntriesOfTransfer.getJournalEntryData().getNumberOfElements();
+ assertThat(linesActual).as(ErrorMessageHelper.wrongNumberOfLinesInAssetExternalizationJournalEntry(linesActual, linesExpected))
+ .isEqualTo(linesExpected);
+
+ log.debug("loanId: {}", journalEntriesOfTransfer.getTransferData().getLoan().getLoanId());
+ log.debug("ownerExternalId: {}", journalEntriesOfTransfer.getTransferData().getOwner().getExternalId());
log.debug("transferId: {}", lastTransferIdByStatus);
- log.debug("transferExternalId: {}", journalEntriesOfTransfer.body().getTransferData().getTransferExternalId());
+ log.debug("transferExternalId: {}", journalEntriesOfTransfer.getTransferData().getTransferExternalId());
}
private Long getLastTransferIdByStatus(Long loanId, String status) throws IOException {
- Response<PageExternalTransferData> transfersResponse = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null)
- .execute();
- List<ExternalTransferData> content = transfersResponse.body().getContent();
+ PageExternalTransferData transfersResponse = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
+ List<ExternalTransferData> content = transfersResponse.getContent();
ExternalTransferData result = content.stream().filter(t -> status.equals(t.getStatus().getValue()))
.reduce((first, second) -> second)
@@ -628,11 +628,10 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
}
private Long getLastTransferId(Long loanId) throws IOException {
- Response<PageExternalTransferData> transfersResponse = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null)
- .execute();
- List<ExternalTransferData> content = transfersResponse.body().getContent();
+ PageExternalTransferData transfersResponse = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
+ List<ExternalTransferData> content = transfersResponse.getContent();
ExternalTransferData result = content.stream().reduce((first, second) -> second)
- .orElseThrow(() -> new IllegalStateException("transfersResponse.body().getContent() is empty"));
+ .orElseThrow(() -> new IllegalStateException("transfersResponse.getContent() is empty"));
return result.getTransferId();
}
@@ -650,12 +649,11 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
transferExternalId = null;
}
- Response<PageExternalTransferData> transfersResponse = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null)
- .execute();
- List<ExternalTransferData> content = transfersResponse.body().getContent();
+ PageExternalTransferData transfersResponse = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
+ List<ExternalTransferData> content = transfersResponse.getContent();
ExternalTransferData result = content.stream().filter(bizEvent -> bizEvent.getTransferExternalId().equals(transferExternalId))
.toList().stream().reduce((first, second) -> second)
- .orElseThrow(() -> new IllegalStateException("transfersResponse.body().getContent() is empty"));
+ .orElseThrow(() -> new IllegalStateException("transfersResponse.getContent() is empty"));
return result;
}
@@ -664,9 +662,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
public void checkJournalEntriesOwner(DataTable table) throws IOException {
String ownerExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
- Response<ExternalOwnerJournalEntryData> journalEntriesOfOwner = externalAssetOwnersApi
- .getJournalEntriesOfOwner(ownerExternalId, null, null).execute();
- List<JournalEntryData> content = journalEntriesOfOwner.body().getJournalEntryData().getContent();
+ ExternalOwnerJournalEntryData journalEntriesOfOwner = externalAssetOwnersApi().getJournalEntriesOfOwner(ownerExternalId, Map.of());
+ List<JournalEntryData> content = journalEntriesOfOwner.getJournalEntryData().getContent();
List<List<String>> data = table.asLists();
int linesExpected = data.size() - 1;
@@ -687,19 +684,19 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
assertThat(containsExpectedValues)
.as(ErrorMessageHelper.wrongValueInLineInAssetExternalizationJournalEntry(i, actualValuesList, expectedValues))
.isTrue();
-
- int linesActual = journalEntriesOfOwner.body().getJournalEntryData().getNumberOfElements();
- assertThat(linesActual).as(ErrorMessageHelper.wrongNumberOfLinesInAssetExternalizationJournalEntry(linesActual, linesExpected))
- .isEqualTo(linesExpected);
}
- log.debug("ownerExternalId: {}", journalEntriesOfOwner.body().getOwnerData().getExternalId());
+ int linesActual = journalEntriesOfOwner.getJournalEntryData().getNumberOfElements();
+ assertThat(linesActual).as(ErrorMessageHelper.wrongNumberOfLinesInAssetExternalizationJournalEntry(linesActual, linesExpected))
+ .isEqualTo(linesExpected);
+
+ log.debug("ownerExternalId: {}", journalEntriesOfOwner.getOwnerData().getExternalId());
}
@Then("LoanOwnershipTransferBusinessEvent is created")
public void loanOwnershipTransferBusinessEventCheck() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Long transferId = getLastTransferId(loanId);
eventCheckHelper.loanOwnershipTransferBusinessEventCheck(loanId, transferId);
@@ -707,8 +704,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("LoanOwnershipTransferBusinessEvent with transfer status: {string} and transfer status reason {string} is created")
public void loanOwnershipTransferBusinessEventCheck(String transferStatus, String transferStatusReason) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Long transferId = getLastTransferId(loanId);
eventCheckHelper.loanOwnershipTransferBusinessEventWithStatusCheck(loanId, transferId, transferStatus, transferStatusReason);
@@ -733,8 +730,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("LoanOwnershipTransferBusinessEvent with transfer type: {string} and transfer asset owner is created")
public void loanOwnershipTransferBusinessEventCheck(String transferType) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalTransferData transferData = getLastTransferByTransferType(loanId, transferType);
String previousAssetOwner = getPreviousAssetOwner(transferData, transferType, false);
@@ -743,8 +740,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("LoanOwnershipTransferBusinessEvent with transfer type: {string} and transfer asset owner based on intermediarySale is created")
public void loanOwnershipTransferBusinessEventCheckBasedOnIntermediarySale(String transferType) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ExternalTransferData transferData = getLastTransferByTransferType(loanId, transferType);
String previousAssetOwner = getPreviousAssetOwner(transferData, transferType, true);
@@ -758,8 +755,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
@Then("LoanAccountSnapshotBusinessEvent is created")
public void loanAccountSnapshotBusinessEventCheck() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Long transferId = getLastTransferId(loanId);
eventCheckHelper.loanAccountSnapshotBusinessEventCheck(loanId, transferId);
@@ -771,13 +768,12 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
String transferExternalIdExpected = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_BUYBACK_TRANSFER_PREFIX + "_" + type);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostInitiateTransferResponse> response = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
- PostInitiateTransferResponse body = response.body();
- Long loanIdActual = body.getSubResourceId();
- String transferExternalIdActual = body.getResourceExternalId();
+ PostInitiateTransferResponse response = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_RESPONSE);
+ Long loanIdActual = response.getSubResourceId();
+ String transferExternalIdActual = response.getResourceExternalId();
log.debug("loanId: {}", loanId);
log.debug("ownerExternalIdStored: {}", ownerExternalIdStored);
@@ -785,7 +781,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
log.debug("transferExternalIdActual: {}", transferExternalIdActual);
assertThat(loanIdActual).as(ErrorMessageHelper.wrongDataInAssetExternalizationResponse(loanIdActual, loanId)).isEqualTo(loanId);
- assertThat(body.getResourceId()).isNotNull();
+ assertThat(response.getResourceId()).isNotNull();
if (transferExternalIdExpected != null) {
assertThat(transferExternalIdActual)
.as(ErrorMessageHelper.wrongDataInAssetExternalizationResponse(transferExternalIdActual, transferExternalIdExpected))
@@ -812,37 +808,39 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
public void adminTransactionCommandTheWithType(String command, String type) throws IOException {
String transferExternalId = testContext()
.get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED + "_" + type);
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi.transferRequestWithId1(transferExternalId, command)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+
+ ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest().dateFormat(DATE_FORMAT_ASSET_EXT).locale(DEFAULT_LOCALE);
+
+ externalAssetOwnersApiExtension().transferRequestWithId1WithBody(transferExternalId, request, Map.of("command", command));
}
@When("Admin send {string} command to the transaction type {string} will throw error")
public void adminTransactionCommandTheWithTypeThrowError(String command, String type) throws IOException {
String transferExternalId = testContext()
.get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED + "_" + type);
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi.transferRequestWithId1(transferExternalId, command)
- .execute();
- ErrorHelper.checkFailedApiCall(response, 403);
+
+ ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest().dateFormat(DATE_FORMAT_ASSET_EXT).locale(DEFAULT_LOCALE);
+
+ CallFailedRuntimeException exception = fail(() -> externalAssetOwnersApiExtension()
+ .transferRequestWithId1WithBody(transferExternalId, request, Map.of("command", command)));
+
+ assertThat(exception.getStatus()).as("Expected status code: 403").isEqualTo(403);
}
@Then("Fetching Asset externalization details by loan id gives numberOfElements: {int} with correct ownerExternalId, ignore transactionExternalId and contain the following data:")
public void checkAssetExternalizationDetailsByLoanIdIgnoreTransactionExternalId(int numberOfElements, DataTable table)
throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<PageExternalTransferData> response = externalAssetOwnersApi.getTransfers(null, loanId, null, null, null).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+ PageExternalTransferData response = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
checkExternalAssetDetailsIgnoreTransferExternalId(loanId, null, response, numberOfElements, table);
}
- private void checkExternalAssetDetailsIgnoreTransferExternalId(Long loanId, String loanExternalId,
- Response<PageExternalTransferData> response, int numberOfElements, DataTable table) {
- PageExternalTransferData body = response.body();
- Integer numberOfElementsActual = body.getNumberOfElements();
- List<ExternalTransferData> content = body.getContent();
+ private void checkExternalAssetDetailsIgnoreTransferExternalId(Long loanId, String loanExternalId, PageExternalTransferData response,
+ int numberOfElements, DataTable table) {
+ Integer numberOfElementsActual = response.getNumberOfElements();
+ List<ExternalTransferData> content = response.getContent();
String ownerExternalIdStored = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
@@ -885,9 +883,12 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
}
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi.transferRequestWithId1(transferExternalId, command)
- .execute();
- ErrorHelper.checkFailedApiCall(response, 403);
+ ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest().dateFormat(DATE_FORMAT_ASSET_EXT).locale(DEFAULT_LOCALE);
+
+ CallFailedRuntimeException exception = fail(() -> externalAssetOwnersApiExtension()
+ .transferRequestWithId1WithBody(transferExternalId, request, Map.of("command", command)));
+
+ assertThat(exception.getStatus()).as("Expected status code: 403").isEqualTo(403);
}
@When("Admin send {string} command on {string} transaction")
@@ -899,40 +900,29 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
}
- Response<PostInitiateTransferResponse> response = externalAssetOwnersApi.transferRequestWithId1(transferExternalId, command)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- }
+ ExternalAssetOwnerRequest request = new ExternalAssetOwnerRequest().dateFormat(DATE_FORMAT_ASSET_EXT).locale(DEFAULT_LOCALE);
- @Autowired
- private LoansApi loansApi;
-
- @Autowired
- private LoanProductsApi loanProductsApi;
-
- @Autowired
- private ExternalAssetOwnerLoanProductAttributesApi externalAssetOwnerLoanProductAttributesApi;
+ externalAssetOwnersApiExtension().transferRequestWithId1WithBody(transferExternalId, request, Map.of("command", command));
+ }
@When("Admin set external asset owner loan product attribute {string} value {string} for loan product {string}")
public void setAExternalAssetOwnerLoanProductAttribute(String externalAssetOwnerLoanProductAttributeKey,
String externalAssetOwnerLoanProductAttributeValue, String loanProductName) throws IOException {
- Response<List<GetLoanProductsResponse>> loanProducts = loanProductsApi.retrieveAllLoanProducts().execute();
- long loanProductId = loanProducts.body().stream().filter(loanProduct -> loanProduct.getName().equals(loanProductName)).findFirst()
+ List<GetLoanProductsResponse> loanProducts = loanProductsApi().retrieveAllLoanProducts(Map.of());
+ long loanProductId = loanProducts.stream().filter(loanProduct -> loanProduct.getName().equals(loanProductName)).findFirst()
.orElseThrow(() -> new RuntimeException("No loan product is found!")).getId();
- Response<PageExternalTransferLoanProductAttributesData> getExternalAssetOwnerLoanProductAttribute = externalAssetOwnerLoanProductAttributesApi
- .getExternalAssetOwnerLoanProductAttributes(loanProductId, externalAssetOwnerLoanProductAttributeKey).execute();
- PageExternalTransferLoanProductAttributesData getExternalAssetOwnerLoanProductAttributeBody = getExternalAssetOwnerLoanProductAttribute
- .body();
+ PageExternalTransferLoanProductAttributesData getExternalAssetOwnerLoanProductAttribute = externalAssetOwnerLoanProductAttributesApi()
+ .getExternalAssetOwnerLoanProductAttributes(loanProductId,
+ Map.of("attributeKey", externalAssetOwnerLoanProductAttributeKey));
- if (getExternalAssetOwnerLoanProductAttributeBody.getTotalFilteredRecords() == 0) {
+ if (getExternalAssetOwnerLoanProductAttribute.getTotalFilteredRecords() == 0) {
PostExternalAssetOwnerLoanProductAttributeRequest setLoanProductAttributeRequest = new PostExternalAssetOwnerLoanProductAttributeRequest()
.attributeKey(externalAssetOwnerLoanProductAttributeKey).attributeValue(externalAssetOwnerLoanProductAttributeValue);
- Response<CommandProcessingResult> updateLoanProductAttributerEsponse = externalAssetOwnerLoanProductAttributesApi
- .postExternalAssetOwnerLoanProductAttribute(loanProductId, setLoanProductAttributeRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(updateLoanProductAttributerEsponse);
+ externalAssetOwnerLoanProductAttributesApi().postExternalAssetOwnerLoanProductAttribute(loanProductId,
+ setLoanProductAttributeRequest);
} else {
- List<ExternalTransferLoanProductAttributesData> attributes = getExternalAssetOwnerLoanProductAttributeBody.getPageItems();
+ List<ExternalTransferLoanProductAttributesData> attributes = getExternalAssetOwnerLoanProductAttribute.getPageItems();
assert attributes != null;
long attributeId = attributes.stream()
.filter(attribute -> attribute.getAttributeKey().equals(externalAssetOwnerLoanProductAttributeKey)).findFirst()
@@ -941,9 +931,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
.getAttributeId();
PutExternalAssetOwnerLoanProductAttributeRequest setLoanProductAttributeRequest = new PutExternalAssetOwnerLoanProductAttributeRequest()
.attributeKey(externalAssetOwnerLoanProductAttributeKey).attributeValue(externalAssetOwnerLoanProductAttributeValue);
- Response<CommandProcessingResult> updateLoanProductAttributerEsponse = externalAssetOwnerLoanProductAttributesApi
- .updateLoanProductAttribute(loanProductId, attributeId, setLoanProductAttributeRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(updateLoanProductAttributerEsponse);
+ externalAssetOwnerLoanProductAttributesApi().updateLoanProductAttribute(loanProductId, attributeId,
+ setLoanProductAttributeRequest);
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BatchApiStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BatchApiStepDef.java
index 2e6864373a..72345ceec9 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BatchApiStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BatchApiStepDef.java
@@ -18,16 +18,15 @@
*/
package org.apache.fineract.test.stepdef.common;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.apache.fineract.test.stepdef.datatable.DatatablesStepDef.DATATABLE_NAME;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.io.IOException;
import java.math.BigDecimal;
-import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -40,16 +39,19 @@ import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.codec.binary.Base64;
import org.apache.fineract.avro.loan.v1.LoanSchedulePeriodDataV1;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.services.BatchApiApi;
+import org.apache.fineract.client.feign.services.ClientApi;
+import org.apache.fineract.client.feign.services.LoansApi;
import org.apache.fineract.client.models.BatchRequest;
import org.apache.fineract.client.models.BatchResponse;
import org.apache.fineract.client.models.GetClientsClientIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdStatus;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
-import org.apache.fineract.client.models.GetUsersUserIdResponse;
import org.apache.fineract.client.models.Header;
+import org.apache.fineract.client.models.InlineJobRequest;
import org.apache.fineract.client.models.PostClientsRequest;
import org.apache.fineract.client.models.PostCreateRescheduleLoansRequest;
import org.apache.fineract.client.models.PostLoansLoanIdChargesRequest;
@@ -59,19 +61,12 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
import org.apache.fineract.client.models.PostLoansRequest;
import org.apache.fineract.client.models.PostLoansResponse;
import org.apache.fineract.client.models.PostUpdateRescheduleLoansRequest;
-import org.apache.fineract.client.models.PostUsersResponse;
-import org.apache.fineract.client.services.BatchApiApi;
-import org.apache.fineract.client.services.ClientApi;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.client.services.UsersApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.data.LoanRescheduleErrorMessage;
import org.apache.fineract.test.data.LoanStatus;
import org.apache.fineract.test.data.TransactionType;
import org.apache.fineract.test.factory.ClientRequestFactory;
import org.apache.fineract.test.factory.LoanRequestFactory;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.helper.Utils;
@@ -80,12 +75,12 @@ import org.apache.fineract.test.messaging.event.loan.LoanRescheduledDueAdjustSch
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class BatchApiStepDef extends AbstractStepDef {
- private static final Gson GSON = new JSON().getGson();
+ private static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER = org.apache.fineract.client.feign.ObjectMapperFactory
+ .getShared();
private static final String DATE_FORMAT = "dd MMMM yyyy";
private static final String DEFAULT_LOCALE = "en";
private static final Long BATCH_API_SAMPLE_REQUEST_ID_1 = 1L;
@@ -121,13 +116,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";
@Autowired
- private BatchApiApi batchApiApi;
-
- @Autowired
- private LoansApi loansApi;
-
- @Autowired
- private ClientApi clientApi;
+ private FineractFeignClient fineractFeignClient;
@Autowired
private ClientRequestFactory clientRequestFactory;
@@ -138,8 +127,17 @@ public class BatchApiStepDef extends AbstractStepDef {
@Autowired
private LoanRequestFactory loanRequestFactory;
- @Autowired
- private UsersApi usersApi;
+ private BatchApiApi batchApiApi() {
+ return fineractFeignClient.batch();
+ }
+
+ private LoansApi loansApi() {
+ return fineractFeignClient.loans();
+ }
+
+ private ClientApi clientApi() {
+ return fineractFeignClient.clients();
+ }
@When("Batch API sample call ran")
public void runSampleBatchApiCall() throws IOException {
@@ -149,7 +147,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 1 - create client
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest();
- String bodyClientsRequest = GSON.toJson(clientsRequest);
+ String bodyClientsRequest = toJson(clientsRequest);
BatchRequest batchRequest1 = new BatchRequest();
batchRequest1.requestId(BATCH_API_SAMPLE_REQUEST_ID_1);
@@ -160,7 +158,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 2 - create Loan
PostLoansRequest loansRequest = loanRequestFactory.defaultLoansRequest(1L);
- String bodyLoansRequest = GSON.toJson(loansRequest);
+ String bodyLoansRequest = toJson(loansRequest);
String bodyLoansRequestMod = bodyLoansRequest.replace("\"clientId\":1", "\"clientId\":\"$.clientId\"");
BatchRequest batchRequest2 = new BatchRequest();
@@ -181,7 +179,7 @@ public class BatchApiStepDef extends AbstractStepDef {
loanIdChargesRequest.dueDate(dateOfCharge);
loanIdChargesRequest.dateFormat(DATE_FORMAT);
loanIdChargesRequest.locale(DEFAULT_LOCALE);
- String bodyLoanIdChargesRequest = GSON.toJson(loanIdChargesRequest);
+ String bodyLoanIdChargesRequest = toJson(loanIdChargesRequest);
BatchRequest batchRequest3 = new BatchRequest();
batchRequest3.requestId(BATCH_API_SAMPLE_REQUEST_ID_3);
@@ -205,7 +203,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(batchRequest2);
requestList.add(batchRequest3);
requestList.add(batchRequest4);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, false).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", false);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
}
@@ -217,7 +217,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 1 - create client
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest();
- String bodyClientsRequest = GSON.toJson(clientsRequest);
+ String bodyClientsRequest = toJson(clientsRequest);
BatchRequest batchRequest1 = new BatchRequest();
batchRequest1.requestId(BATCH_API_SAMPLE_REQUEST_ID_1);
@@ -228,7 +228,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 2 - create Loan
PostLoansRequest loansRequest = loanRequestFactory.defaultLoansRequest(1L);
- String bodyLoansRequest = GSON.toJson(loansRequest);
+ String bodyLoansRequest = toJson(loansRequest);
String bodyLoansRequestMod = bodyLoansRequest.replace("\"clientId\":1", "\"clientId\":\"$.clientId\"");
BatchRequest batchRequest2 = new BatchRequest();
@@ -241,7 +241,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 3 - approve Loan
PostLoansLoanIdRequest loanApproveRequest = LoanRequestFactory.defaultLoanApproveRequest();
- String bodyLoanApproveRequest = GSON.toJson(loanApproveRequest);
+ String bodyLoanApproveRequest = toJson(loanApproveRequest);
BatchRequest batchRequest3 = new BatchRequest();
batchRequest3.requestId(BATCH_API_SAMPLE_REQUEST_ID_3);
@@ -253,7 +253,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 4 - disburse Loan
PostLoansLoanIdRequest loanDisburseRequest = LoanRequestFactory.defaultLoanDisburseRequest();
- String bodyLoanDisburseRequest = GSON.toJson(loanDisburseRequest);
+ String bodyLoanDisburseRequest = toJson(loanDisburseRequest);
BatchRequest batchRequest4 = new BatchRequest();
batchRequest4.requestId(BATCH_API_SAMPLE_REQUEST_ID_4);
@@ -265,7 +265,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 5 - repayment with idempotency key
PostLoansLoanIdTransactionsRequest loanRepaymentRequest1 = LoanRequestFactory.defaultRepaymentRequest();
- String bodyLoanRepaymentRequest1 = GSON.toJson(loanRepaymentRequest1);
+ String bodyLoanRepaymentRequest1 = toJson(loanRepaymentRequest1);
String idempotencyKey = UUID.randomUUID().toString();
headers.add(new Header().name("Idempotency-Key").value(idempotencyKey));
@@ -280,7 +280,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// request 6 - repayment with same idempotency key
PostLoansLoanIdTransactionsRequest loanRepaymentRequest2 = LoanRequestFactory.defaultRepaymentRequest();
- String bodyLoanRepaymentRequest2 = GSON.toJson(loanRepaymentRequest2);
+ String bodyLoanRepaymentRequest2 = toJson(loanRepaymentRequest2);
BatchRequest batchRequest6 = new BatchRequest();
batchRequest6.requestId(BATCH_API_SAMPLE_REQUEST_ID_6);
@@ -297,7 +297,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(batchRequest4);
requestList.add(batchRequest5);
requestList.add(batchRequest6);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, false).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", false);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
}
@@ -315,7 +317,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(getLoanDetailsByExternalId(4L, 2L, idempotencyKey));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
@@ -336,7 +340,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(getLoanDetailsByExternalId(4L, 2L, idempotencyKey));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
@@ -364,7 +370,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(getLoanDetailsByExternalId(8L, 6L, idempotencyKey2));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
@@ -395,7 +403,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(getLoanDetailsByExternalId(8L, 6L, idempotencyKey2));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
@@ -421,7 +431,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(getLoanDetailsByExternalId(5L, 2L, idempotencyKey));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
@@ -433,8 +445,8 @@ public class BatchApiStepDef extends AbstractStepDef {
String approvedOnDate, String enclosingTransaction) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
String idempotencyKey = UUID.randomUUID().toString();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- Long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ Long loanId = loanResponse.getLoanId();
List<BatchRequest> requestList = new ArrayList<>();
@@ -442,7 +454,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(approveLoanReschedule(2L, idempotencyKey, approvedOnDate, 1L));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
eventAssertion.assertEvent(LoanRescheduledDueAdjustScheduleEvent.class, loanId).extractingData(loanAccountDataV1 -> {
@@ -462,19 +476,8 @@ public class BatchApiStepDef extends AbstractStepDef {
String approvedOnDate, String enclosingTransaction) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
String idempotencyKey = UUID.randomUUID().toString();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- Long loanId = loanResponse.body().getLoanId();
-
- Map<String, String> headerMap = new HashMap<>();
-
- Response<PostUsersResponse> createUserResponse = testContext().get(TestContextKey.CREATED_SIMPLE_USER_RESPONSE);
- Long createdUserId = createUserResponse.body().getResourceId();
- Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
- ErrorHelper.checkSuccessfulApiCall(user);
- String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
- Base64 base64 = new Base64();
- headerMap.put("Authorization",
- "Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ Long loanId = loanResponse.getLoanId();
List<BatchRequest> requestList = new ArrayList<>();
@@ -482,19 +485,24 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(approveLoanReschedule(2L, idempotencyKey, approvedOnDate, 1L));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction, headerMap)
- .execute();
-
- if (batchResponseList.errorBody() != null) {
- log.debug("ERROR: {}", batchResponseList.errorBody().string());
-
- }
- if (batchResponseList.body() != null) {
- log.debug("Body: {}", batchResponseList.body());
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ // TODO: Feign doesn't support per-request headers via API signature - need to use RequestInterceptor
+ // List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams,
+ // headerMap);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
+
+ // Feign throws exceptions on errors, no errorBody()
+ if (batchResponseList != null) {
+ log.debug("Body: {}", batchResponseList);
}
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
+ if (Boolean.TRUE.equals(isEnclosingTransaction)) {
+ InlineJobRequest inlineJobRequest = new InlineJobRequest().addLoanIdsItem(loanId);
+ ok(() -> fineractFeignClient.inlineJob().executeInlineJob("LOAN_COB", inlineJobRequest));
+ }
eventAssertion.assertEvent(LoanRescheduledDueAdjustScheduleEvent.class, loanId).extractingData(loanAccountDataV1 -> {
Optional<LoanSchedulePeriodDataV1> period = loanAccountDataV1.getRepaymentSchedule().getPeriods().stream()
.filter(p -> formatter.format(LocalDate.parse(p.getDueDate())).equals(toDateStr)).findFirst();
@@ -511,8 +519,8 @@ public class BatchApiStepDef extends AbstractStepDef {
public void runBatchApiCreateAndApproveLoanRescheduleWithGivenUserLockedByCobError(int errorCodeExpected, String errorMessageType,
DataTable table) throws IOException {
String idempotencyKey = UUID.randomUUID().toString();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- Long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ Long loanId = loanResponse.getLoanId();
LoanRescheduleErrorMessage loanRescheduleErrorMessage = LoanRescheduleErrorMessage.valueOf(errorMessageType);
String errorMessageExpected = loanRescheduleErrorMessage.getValue(loanId);
@@ -525,26 +533,24 @@ public class BatchApiStepDef extends AbstractStepDef {
String approvedOnDate = transferData.get(3);
String enclosingTransaction = transferData.get(4);
- Map<String, String> headerMap = new HashMap<>();
-
- Response<PostUsersResponse> createUserResponse = testContext().get(TestContextKey.CREATED_SIMPLE_USER_RESPONSE);
- Long createdUserId = createUserResponse.body().getResourceId();
- Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
- ErrorHelper.checkSuccessfulApiCall(user);
- String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
- Base64 base64 = new Base64();
- headerMap.put("Authorization",
- "Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
-
List<BatchRequest> requestList = new ArrayList<>();
requestList.add(createLoanReschedule(1L, loanId, fromDateStr, toDateStr, submittedOnDate, idempotencyKey, null));
requestList.add(approveLoanReschedule(2L, idempotencyKey, approvedOnDate, 1L));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction, headerMap)
- .execute();
- String errorToString = batchResponseList.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorToString, ErrorResponse.class);
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+
+ // Feign throws exceptions on errors instead of returning error in response body
+ ErrorResponse errorResponse = null;
+ try {
+ // TODO: Feign doesn't support per-request headers - need to use RequestInterceptor
+ batchApiApi().handleBatchRequests(requestList, queryParams);
+ throw new IllegalStateException("Expected Feign exception but call succeeded");
+ } catch (org.apache.fineract.client.feign.FeignException e) {
+ errorResponse = fromJson(e.responseBodyAsString(), ErrorResponse.class);
+ }
+
String errorMessageActual = errorResponse.getDeveloperMessage();
Integer errorCodeActual = errorResponse.getHttpStatusCode();
@@ -560,8 +566,8 @@ public class BatchApiStepDef extends AbstractStepDef {
public void runBatchApiCreateAndApproveLoanRescheduleWithGivenUserLockedByCobWithoutError(int httpCodeExpected, DataTable table)
throws IOException {
String idempotencyKey = UUID.randomUUID().toString();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- Long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ Long loanId = loanResponse.getLoanId();
List<List<String>> data = table.asLists();
List<String> transferData = data.get(1);
@@ -571,27 +577,18 @@ public class BatchApiStepDef extends AbstractStepDef {
String approvedOnDate = transferData.get(3);
String enclosingTransaction = transferData.get(4);
- Map<String, String> headerMap = new HashMap<>();
-
- Response<PostUsersResponse> createUserResponse = testContext().get(TestContextKey.CREATED_SIMPLE_USER_RESPONSE);
- Long createdUserId = createUserResponse.body().getResourceId();
- Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
- ErrorHelper.checkSuccessfulApiCall(user);
- String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
- Base64 base64 = new Base64();
- headerMap.put("Authorization",
- "Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
List<BatchRequest> requestList = new ArrayList<>();
requestList.add(createLoanReschedule(1L, loanId, fromDateStr, toDateStr, submittedOnDate, idempotencyKey, null));
requestList.add(approveLoanReschedule(2L, idempotencyKey, approvedOnDate, 1L));
Boolean isEnclosingTransaction = Boolean.valueOf(enclosingTransaction);
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, isEnclosingTransaction, headerMap)
- .execute();
- BatchResponse lastBatchResponse = batchResponseList.body().get(batchResponseList.body().size() - 1);
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", isEnclosingTransaction);
+ // TODO: Feign doesn't support per-request headers - need to use RequestInterceptor
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
+ BatchResponse lastBatchResponse = batchResponseList.get(batchResponseList.size() - 1);
assertThat(httpCodeExpected).isEqualTo(lastBatchResponse.getStatusCode());
- // No error
- assertThat(batchResponseList.errorBody()).isEqualTo(null);
+ // Feign throws exceptions on errors, no errorBody()
}
@When("Batch API call with steps: queryDatatable, updateDatatable runs, with empty queryDatatable response")
@@ -602,7 +599,9 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(queryDatatable(1L));
requestList.add(updateDatatable(2L, 1L));
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, false).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", false);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
}
@@ -612,7 +611,7 @@ public class BatchApiStepDef extends AbstractStepDef {
PostCreateRescheduleLoansRequest rescheduleLoansRequest = LoanRequestFactory.defaultLoanRescheduleCreateRequest(loanId, fromDateStr,
toDateStr);
rescheduleLoansRequest.setSubmittedOnDate(submittedOnDate);
- String bodyLoanRescheduleRequest = GSON.toJson(rescheduleLoansRequest);
+ String bodyLoanRescheduleRequest = toJson(rescheduleLoansRequest);
Set<Header> headers = new HashSet<>();
headers.add(HEADER);
@@ -633,7 +632,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private BatchRequest approveLoanReschedule(Long requestId, String idempotencyKey, String approvedOnDate, Long referenceId) {
PostUpdateRescheduleLoansRequest rescheduleLoansRequest = LoanRequestFactory.defaultLoanRescheduleUpdateRequest();
rescheduleLoansRequest.setApprovedOnDate(approvedOnDate);
- String bodyLoanRescheduleRequest = GSON.toJson(rescheduleLoansRequest);
+ String bodyLoanRescheduleRequest = toJson(rescheduleLoansRequest);
Set<Header> headers = new HashSet<>();
headers.add(HEADER);
@@ -653,14 +652,17 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Admin checks that all steps result 200OK")
public void adminChecksThatAllStepsResultOK() {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- ErrorHelper.checkSuccessfulBatchApiCall(batchResponseList);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ // Feign doesn't use Response wrappers, check status codes directly
+ batchResponseList.forEach(response -> {
+ assertThat(response.getStatusCode()).as(ErrorMessageHelper.batchRequestFailedWithCode(response)).isEqualTo(200);
+ });
}
@Then("Verify that step Nr. {int} results {int}")
public void checkGivenStepResult(int nr, int resultStatusCode) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse stepResponse = batchResponseList.body().stream().filter(r -> r.getRequestId() == nr).findAny()
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse stepResponse = batchResponseList.stream().filter(r -> r.getRequestId() == nr).findAny()
.orElseThrow(() -> new IllegalStateException(String.format("Request id %s not found", nr)));
assertThat(stepResponse.getStatusCode()).as(ErrorMessageHelper.wrongStatusCode(stepResponse.getStatusCode(), resultStatusCode))
@@ -669,10 +671,10 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Verify that step {int} throws an error with error code {int}")
public void errorCodeInStep(int step, int errorCode) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse response = batchResponseList.body().stream().filter(r -> r.getRequestId() == step).findAny()
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse response = batchResponseList.stream().filter(r -> r.getRequestId() == step).findAny()
.orElseThrow(() -> new IllegalStateException(String.format("Step %s is not found", step)));
- ErrorResponse errorResponse = GSON.fromJson(response.getBody(), ErrorResponse.class);
+ ErrorResponse errorResponse = fromJson(response.getBody(), ErrorResponse.class);
String developerMessageActual = errorResponse.getDeveloperMessage();
Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
@@ -690,14 +692,17 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Admin checks that all steps result 200OK for Batch API idempotency request")
public void adminChecksThatAllStepsResultOKIdempotency() {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- ErrorHelper.checkSuccessfulBatchApiCall(batchResponseList);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ // Feign doesn't use Response wrappers, check status codes directly
+ batchResponseList.forEach(response -> {
+ assertThat(response.getStatusCode()).as(ErrorMessageHelper.batchRequestFailedWithCode(response)).isEqualTo(200);
+ });
}
@Then("Batch API response has boolean value in header {string}: {string} in segment with requestId {int}")
public void batchAPITransactionHeaderCheckBoolean(String headerKeyExpected, String headerValueExpected, int requestId) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse batchResponse = batchResponseList.body().get(requestId - 1);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse batchResponse = batchResponseList.get(requestId - 1);
Set<Header> headers = batchResponse.getHeaders();
List<Header> headersList = new ArrayList<>(Objects.requireNonNull(headers));
@@ -710,8 +715,8 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Batch API response has no {string} field in segment with requestId {int}")
public void batchAPITransactionHeaderCheckNoField(String headerKeyExpected, int requestId) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse batchResponse = batchResponseList.body().get(requestId - 1);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse batchResponse = batchResponseList.get(requestId - 1);
Set<Header> headers = batchResponse.getHeaders();
List<Header> headersList = new ArrayList<>(Objects.requireNonNull(headers));
@@ -727,10 +732,10 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Batch API response has {double} EUR value for transaction amount in segment with requestId {int}")
public void batchAPITransactionAmountCheck(double transactionAmountExpected, int requestId) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse batchResponse = batchResponseList.body().get(requestId - 1);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse batchResponse = batchResponseList.get(requestId - 1);
- PostLoansLoanIdTransactionsResponse loanTransactionResponse = GSON.fromJson(batchResponse.getBody(),
+ PostLoansLoanIdTransactionsResponse loanTransactionResponse = fromJson(batchResponse.getBody(),
PostLoansLoanIdTransactionsResponse.class);
Double transactionAmountActual = Double
.valueOf(Objects.requireNonNull(Objects.requireNonNull(loanTransactionResponse.getChanges()).getTransactionAmount()));
@@ -742,13 +747,13 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Batch API response has the same clientId and loanId in segment with requestId {int} as in segment with requestId {int}")
public void batchAPIClientIdLoanIdCheck(int requestIdSecondTransaction, int requestIdFirstTransaction) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse batchResponseFirstTransaction = batchResponseList.body().get(requestIdFirstTransaction - 1);
- BatchResponse batchResponseSecondTransaction = batchResponseList.body().get(requestIdSecondTransaction - 1);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse batchResponseFirstTransaction = batchResponseList.get(requestIdFirstTransaction - 1);
+ BatchResponse batchResponseSecondTransaction = batchResponseList.get(requestIdSecondTransaction - 1);
- PostLoansLoanIdTransactionsResponse loanTransactionResponseFirst = GSON.fromJson(batchResponseFirstTransaction.getBody(),
+ PostLoansLoanIdTransactionsResponse loanTransactionResponseFirst = fromJson(batchResponseFirstTransaction.getBody(),
PostLoansLoanIdTransactionsResponse.class);
- PostLoansLoanIdTransactionsResponse loanTransactionResponseSecond = GSON.fromJson(batchResponseSecondTransaction.getBody(),
+ PostLoansLoanIdTransactionsResponse loanTransactionResponseSecond = fromJson(batchResponseSecondTransaction.getBody(),
PostLoansLoanIdTransactionsResponse.class);
Long clientIdFirstTransaction = loanTransactionResponseFirst.getClientId();
@@ -767,9 +772,9 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Batch API response has the same idempotency key in segment with requestId {int} as in segment with requestId {int}")
public void batchAPIIdempotencyKeyCheck(int requestIdSecondTransaction, int requestIdFirstTransaction) {
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse batchResponseFirstTransaction = batchResponseList.body().get(requestIdFirstTransaction - 1);
- BatchResponse batchResponseSecondTransaction = batchResponseList.body().get(requestIdSecondTransaction - 1);
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse batchResponseFirstTransaction = batchResponseList.get(requestIdFirstTransaction - 1);
+ BatchResponse batchResponseSecondTransaction = batchResponseList.get(requestIdSecondTransaction - 1);
Set<Header> headersFirstTransaction = batchResponseFirstTransaction.getHeaders();
List<Header> headersListFirstTransaction = new ArrayList<>(Objects.requireNonNull(headersFirstTransaction));
@@ -790,15 +795,18 @@ public class BatchApiStepDef extends AbstractStepDef {
TransactionType transactionType = TransactionType.valueOf(transactionTypeInput);
String transactionTypeValue = transactionType.getValue();
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- BatchResponse lastBatchResponse = batchResponseList.body().get(batchResponseList.body().size() - 1);
- PostLoansLoanIdTransactionsResponse loanTransactionResponse = GSON.fromJson(lastBatchResponse.getBody(),
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ BatchResponse lastBatchResponse = batchResponseList.get(batchResponseList.size() - 1);
+ PostLoansLoanIdTransactionsResponse loanTransactionResponse = fromJson(lastBatchResponse.getBody(),
PostLoansLoanIdTransactionsResponse.class);
Long loanId = loanTransactionResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
+ loanQueryParams.put("associations", "transactions");
+ GetLoansLoanIdResponse loanDetails = loansApi().retrieveLoan(loanId, loanQueryParams);
- List<GetLoansLoanIdTransactions> transactions = loanDetails.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetails.getTransactions();
List<String> transactionsMatched = new ArrayList<>();
transactions.forEach(t -> {
@@ -827,9 +835,10 @@ public class BatchApiStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("Nr. %s client external ID not found", nr));
}
- Response<GetClientsClientIdResponse> response = clientApi.retrieveOne12(clientExternalId, false).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- assertThat(response.body().getId()).as(ErrorMessageHelper.idNull()).isNotNull();
+ Map<String, Object> clientQueryParams = new HashMap<>();
+ clientQueryParams.put("staffInSelectedOfficeOnly", false);
+ GetClientsClientIdResponse response = clientApi().retrieveOne12(clientExternalId, clientQueryParams);
+ assertThat(response.getId()).as(ErrorMessageHelper.idNull()).isNotNull();
}
@Then("Nr. {int} Loan was created")
@@ -843,9 +852,10 @@ public class BatchApiStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("Nr. %s loan external ID not found", nr));
}
- Response<GetLoansLoanIdResponse> response = loansApi.retrieveLoan1(loanExternalId, false, "", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(response);
- assertThat(response.body().getId()).as(ErrorMessageHelper.idNull()).isNotNull();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
+ GetLoansLoanIdResponse response = loansApi().retrieveLoan1(loanExternalId, loanQueryParams);
+ assertThat(response.getId()).as(ErrorMessageHelper.idNull()).isNotNull();
}
@Then("Nr. {int} Loan was approved")
@@ -859,14 +869,14 @@ public class BatchApiStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("Nr. %s loan external ID not found", nr));
}
- Response<GetLoansLoanIdResponse> response = loansApi.retrieveLoan1(loanExternalId, false, "", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(response);
-
- GetLoansLoanIdStatus status = response.body().getStatus();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
+ GetLoansLoanIdResponse response = loansApi().retrieveLoan1(loanExternalId, loanQueryParams);
+ GetLoansLoanIdStatus status = response.getStatus();
Integer statusIdActual = status.getId();
Integer statusIdExpected = LoanStatus.APPROVED.value;
- String resourceId = String.valueOf(response.body().getId());
+ String resourceId = String.valueOf(response.getId());
assertThat(statusIdActual).as(ErrorMessageHelper.wrongLoanStatus(resourceId, statusIdActual, statusIdExpected))
.isEqualTo(statusIdExpected);
}
@@ -882,8 +892,16 @@ public class BatchApiStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("Nr. %s client external id mot found", nr));
}
- Response<GetClientsClientIdResponse> response = clientApi.retrieveOne12(clientExternalId, false).execute();
- ErrorResponse errorResponse = GSON.fromJson(response.errorBody().string(), ErrorResponse.class);
+ // Feign throws exceptions on errors instead of returning error in response body
+ ErrorResponse errorResponse = null;
+ try {
+ Map<String, Object> clientQueryParams = new HashMap<>();
+ clientQueryParams.put("staffInSelectedOfficeOnly", false);
+ clientApi().retrieveOne12(clientExternalId, clientQueryParams);
+ throw new IllegalStateException("Expected Feign exception but call succeeded");
+ } catch (org.apache.fineract.client.feign.FeignException e) {
+ errorResponse = fromJson(e.responseBodyAsString(), ErrorResponse.class);
+ }
String developerMessageActual = errorResponse.getDeveloperMessage();
Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
String errorsDeveloperMessageActual = errorResponse.getErrors().get(0).getDeveloperMessage();
@@ -912,9 +930,17 @@ public class BatchApiStepDef extends AbstractStepDef {
throw new IllegalStateException(String.format("Nr. %s loan external id mot found", nr));
}
- Response<GetLoansLoanIdResponse> response = loansApi.retrieveLoan1(loanExternalId, false, "", "", "").execute();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
- ErrorResponse errorResponse = GSON.fromJson(response.errorBody().string(), ErrorResponse.class);
+ // Feign throws exceptions on errors instead of returning error in response body
+ ErrorResponse errorResponse = null;
+ try {
+ loansApi().retrieveLoan1(loanExternalId, loanQueryParams);
+ throw new IllegalStateException("Expected Feign exception but call succeeded");
+ } catch (org.apache.fineract.client.feign.FeignException e) {
+ errorResponse = fromJson(e.responseBodyAsString(), ErrorResponse.class);
+ }
String developerMessageActual = errorResponse.getDeveloperMessage();
Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
String errorsDeveloperMessageActual = errorResponse.getErrors().get(0).getDeveloperMessage();
@@ -934,20 +960,22 @@ public class BatchApiStepDef extends AbstractStepDef {
@When("Admin runs Batch API call with chargeOff command on {string}")
public void runBatchApiCallWithChargeOffCommand(String chargeOffDate) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
String idempotencyKey = UUID.randomUUID().toString();
List<BatchRequest> requestList = new ArrayList<>();
requestList.add(createChargeOffRequest(1L, loanId, idempotencyKey, chargeOffDate));
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, false).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", false);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
- if (batchResponseList.isSuccessful() && batchResponseList.body() != null && !batchResponseList.body().isEmpty()) {
- BatchResponse response = batchResponseList.body().get(0);
+ if (batchResponseList != null && !batchResponseList.isEmpty()) {
+ BatchResponse response = batchResponseList.get(0);
log.debug("Batch charge-off API status code: {}", response.getStatusCode());
log.debug("Batch charge-off API response body: {}", response.getBody());
} else {
@@ -974,7 +1002,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// Disburse loan
PostLoansLoanIdRequest loanDisburseRequest = LoanRequestFactory.defaultLoanDisburseRequest();
- String bodyLoanDisburseRequest = GSON.toJson(loanDisburseRequest);
+ String bodyLoanDisburseRequest = toJson(loanDisburseRequest);
BatchRequest disburseRequest = new BatchRequest();
disburseRequest.requestId(4L);
disburseRequest.relativeUrl("loans/external-id/$.resourceExternalId?command=disburse");
@@ -990,16 +1018,18 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(applyInterestPauseByExternalId(5L, 2L, idempotencyKey, startDate, endDate));
// Execute batch request
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, true).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", true);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
testContext().set(TestContextKey.BATCH_API_CALL_LOAN_EXTERNAL_ID, loanExternalId);
// Log response for debugging
- if (batchResponseList.isSuccessful() && batchResponseList.body() != null && !batchResponseList.body().isEmpty()) {
- for (int i = 0; i < batchResponseList.body().size(); i++) {
- BatchResponse response = batchResponseList.body().get(i);
+ if (batchResponseList != null && !batchResponseList.isEmpty()) {
+ for (int i = 0; i < batchResponseList.size(); i++) {
+ BatchResponse response = batchResponseList.get(i);
log.debug("Batch step {} status code: {}", i + 1, response.getStatusCode());
log.debug("Batch step {} response body: {}", i + 1, response.getBody());
}
@@ -1027,7 +1057,7 @@ public class BatchApiStepDef extends AbstractStepDef {
// Disburse loan
PostLoansLoanIdRequest loanDisburseRequest = LoanRequestFactory.defaultLoanDisburseRequest();
- String bodyLoanDisburseRequest = GSON.toJson(loanDisburseRequest);
+ String bodyLoanDisburseRequest = toJson(loanDisburseRequest);
BatchRequest disburseRequest = new BatchRequest();
disburseRequest.requestId(4L);
disburseRequest.relativeUrl("loans/$.loanId?command=disburse");
@@ -1043,16 +1073,18 @@ public class BatchApiStepDef extends AbstractStepDef {
requestList.add(applyInterestPause(5L, 2L, idempotencyKey, startDate, endDate));
// Execute batch request
- Response<List<BatchResponse>> batchResponseList = batchApiApi.handleBatchRequests(requestList, true).execute();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("enclosingTransaction", true);
+ List<BatchResponse> batchResponseList = batchApiApi().handleBatchRequests(requestList, queryParams);
testContext().set(TestContextKey.BATCH_API_CALL_RESPONSE, batchResponseList);
testContext().set(TestContextKey.BATCH_API_CALL_IDEMPOTENCY_KEY, idempotencyKey);
testContext().set(TestContextKey.BATCH_API_CALL_CLIENT_EXTERNAL_ID, clientExternalId);
testContext().set(TestContextKey.BATCH_API_CALL_LOAN_EXTERNAL_ID, loanExternalId);
// Log response for debugging
- if (batchResponseList.isSuccessful() && batchResponseList.body() != null && !batchResponseList.body().isEmpty()) {
- for (int i = 0; i < batchResponseList.body().size(); i++) {
- BatchResponse response = batchResponseList.body().get(i);
+ if (batchResponseList != null && !batchResponseList.isEmpty()) {
+ for (int i = 0; i < batchResponseList.size(); i++) {
+ BatchResponse response = batchResponseList.get(i);
log.debug("Batch step {} status code: {}", i + 1, response.getStatusCode());
log.debug("Batch step {} response body: {}", i + 1, response.getBody());
}
@@ -1069,7 +1101,7 @@ public class BatchApiStepDef extends AbstractStepDef {
requestMap.put("locale", DEFAULT_LOCALE);
requestMap.put("note", "Charge-off due to delinquency");
- String bodyChargeOffRequest = GSON.toJson(requestMap);
+ String bodyChargeOffRequest = toJson(requestMap);
Set<Header> headers = new HashSet<>();
headers.add(HEADER);
@@ -1089,15 +1121,16 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Admin checks the loan has been charged-off on {string}")
public void checkLoanChargedOff(String chargeOffDate) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "all", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetails);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
+ loanQueryParams.put("associations", "all");
+ GetLoansLoanIdResponse loanDetails = loansApi().retrieveLoan(loanId, loanQueryParams);
// Check loan has a CHARGE_OFF transaction on the specified date
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
- boolean hasChargeOffTransaction = loanDetails.body().getTransactions().stream().anyMatch(
+ boolean hasChargeOffTransaction = loanDetails.getTransactions().stream().anyMatch(
t -> t.getType().getCode().equals("loanTransactionType.chargeOff") && formatter.format(t.getDate()).equals(chargeOffDate));
assertThat(hasChargeOffTransaction).as("Loan should have a CHARGE_OFF transaction on " + chargeOffDate).isTrue();
@@ -1115,7 +1148,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private BatchRequest createClient(Long requestId, String idempotencyKey, String clientExternalId) {
PostClientsRequest clientsRequest = clientExternalId == null ? clientRequestFactory.defaultClientCreationRequest()
: clientRequestFactory.defaultClientCreationRequest().externalId(clientExternalId);
- String bodyClientsRequest = GSON.toJson(clientsRequest);
+ String bodyClientsRequest = toJson(clientsRequest);
Set<Header> headers = new HashSet<>();
headers.add(HEADER);
@@ -1136,7 +1169,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private BatchRequest createLoan(Long requestId, Long referenceId, String idempotencyKey, String loanExternalId) {
PostLoansRequest loansRequest = loanExternalId == null ? loanRequestFactory.defaultLoansRequest(1L)
: loanRequestFactory.defaultLoansRequest(1L).externalId(loanExternalId);
- String bodyLoansRequest = GSON.toJson(loansRequest);
+ String bodyLoansRequest = toJson(loansRequest);
String bodyLoansRequestMod = bodyLoansRequest.replace("\"clientId\":1", "\"clientId\":\"$.clientId\"");
BatchRequest batchRequest = new BatchRequest();
@@ -1154,7 +1187,7 @@ public class BatchApiStepDef extends AbstractStepDef {
PostLoansRequest loansRequest = loanExternalId == null ? loanRequestFactory.defaultProgressiveLoansRequest(1L)
: loanRequestFactory.defaultProgressiveLoansRequest(1L).externalId(loanExternalId);
loansRequest.setInterestRatePerPeriod(BigDecimal.ONE);
- String bodyLoansRequest = GSON.toJson(loansRequest);
+ String bodyLoansRequest = toJson(loansRequest);
String bodyLoansRequestMod = bodyLoansRequest.replace("\"clientId\":1", "\"clientId\":\"$.clientId\"");
BatchRequest batchRequest = new BatchRequest();
@@ -1198,7 +1231,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private BatchRequest approveLoanByExternalId(Long requestId, Long referenceId, String idempotencyKey) {
PostLoansLoanIdRequest loanApproveRequest = LoanRequestFactory.defaultLoanApproveRequest();
- String bodyLoanApproveRequest = GSON.toJson(loanApproveRequest);
+ String bodyLoanApproveRequest = toJson(loanApproveRequest);
BatchRequest batchRequest = new BatchRequest();
batchRequest.requestId(requestId);
@@ -1213,7 +1246,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private BatchRequest approveLoanByExternalIdFail(Long requestId, Long referenceId, String idempotencyKey, String loanExternalId) {
PostLoansLoanIdRequest loanApproveRequest = LoanRequestFactory.defaultLoanApproveRequest();
- String bodyLoanApproveRequest = GSON.toJson(loanApproveRequest);
+ String bodyLoanApproveRequest = toJson(loanApproveRequest);
BatchRequest batchRequest = new BatchRequest();
batchRequest.requestId(requestId);
@@ -1282,26 +1315,29 @@ public class BatchApiStepDef extends AbstractStepDef {
@Then("Loan should have an active interest pause period starting on {int}st day and ending on {int}nd day")
public void verifyInterestPausePeriod(int startDay, int endDay) throws IOException {
// Get the loan ID from the batch response
- Response<List<BatchResponse>> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
- assertThat(batchResponseList.isSuccessful()).isTrue();
- assertThat(batchResponseList.body()).isNotNull();
+ List<BatchResponse> batchResponseList = testContext().get(TestContextKey.BATCH_API_CALL_RESPONSE);
+ assertThat(batchResponseList != null).isTrue();
+ assertThat(batchResponseList).isNotNull();
// The loan creation response is the second response in the batch (index 1)
- BatchResponse loanCreateResponse = batchResponseList.body().get(1);
+ BatchResponse loanCreateResponse = batchResponseList.get(1);
assertThat(loanCreateResponse.getStatusCode()).isEqualTo(200);
// Parse the loan ID from the response
String loanCreateResponseBody = loanCreateResponse.getBody();
- com.google.gson.JsonObject loanCreateJson = com.google.gson.JsonParser.parseString(loanCreateResponseBody).getAsJsonObject();
- long loanId = loanCreateJson.get("loanId").getAsLong();
+ com.fasterxml.jackson.databind.JsonNode loanCreateJson = readTree(loanCreateResponseBody);
+ long loanId = loanCreateJson.get("loanId").asLong();
// Get the loan details
- Response<GetLoansLoanIdResponse> loanResponse = loansApi.retrieveLoan(loanId, false, "all", "", "").execute();
- assertThat(loanResponse.isSuccessful()).isTrue();
- assertThat(loanResponse.body()).isNotNull();
+ Map<String, Object> loanQueryParams = new HashMap<>();
+ loanQueryParams.put("staffInSelectedOfficeOnly", false);
+ loanQueryParams.put("associations", "all");
+ GetLoansLoanIdResponse loanResponse = loansApi().retrieveLoan(loanId, loanQueryParams);
+ assertThat(loanResponse != null).isTrue();
+ assertThat(loanResponse).isNotNull();
// Verify the interest pause period
- GetLoansLoanIdResponse loan = loanResponse.body();
+ GetLoansLoanIdResponse loan = loanResponse;
assertThat(loan.getLoanTermVariations().get(0).getTermType().getValue().equals("interestPause")).isTrue();
// Verify the start date is the specified day of the previous month
@@ -1317,4 +1353,28 @@ public class BatchApiStepDef extends AbstractStepDef {
log.debug("Verified interest pause period from {} to {}", actualStartDate, actualEndDate);
}
+
+ private static String toJson(Object obj) {
+ try {
+ return OBJECT_MAPPER.writeValueAsString(obj);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {
+ throw new RuntimeException("Error serializing object to JSON", e);
+ }
+ }
+
+ private static <T> T fromJson(String json, Class<T> clazz) {
+ try {
+ return OBJECT_MAPPER.readValue(json, clazz);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {
+ throw new RuntimeException("Error deserializing JSON to object", e);
+ }
+ }
+
+ private static com.fasterxml.jackson.databind.JsonNode readTree(String json) {
+ try {
+ return OBJECT_MAPPER.readTree(json);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException e) {
+ throw new RuntimeException("Error parsing JSON tree", e);
+ }
+ }
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessDateStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessDateStepDef.java
index c58079f14c..1a3881792a 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessDateStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/BusinessDateStepDef.java
@@ -19,27 +19,24 @@
package org.apache.fineract.test.stepdef.common;
import static java.util.Arrays.asList;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
-import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
+import java.util.Map;
+import org.apache.fineract.client.feign.FeignException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.BusinessDateResponse;
import org.apache.fineract.client.models.BusinessDateUpdateRequest;
-import org.apache.fineract.client.models.BusinessDateUpdateResponse;
-import org.apache.fineract.client.services.BusinessDateManagementApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.helper.BusinessDateHelper;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class BusinessDateStepDef extends AbstractStepDef {
@@ -47,68 +44,72 @@ public class BusinessDateStepDef extends AbstractStepDef {
private BusinessDateHelper businessDateHelper;
@Autowired
- private BusinessDateManagementApi businessDateManagementApi;
-
- private static final Gson GSON = new JSON().getGson();
+ private FineractFeignClient fineractClient;
@When("Admin sets the business date to {string}")
- public void setBusinessDate(String businessDate) throws IOException {
+ public void setBusinessDate(String businessDate) {
businessDateHelper.setBusinessDate(businessDate);
}
@When("Admin sets the business date to the actual date")
- public void setBusinessDateToday() throws IOException {
+ public void setBusinessDateToday() {
businessDateHelper.setBusinessDateToday();
}
@Then("Admin checks that the business date is correctly set to {string}")
- public void checkBusinessDate(String businessDate) throws IOException {
- Response<BusinessDateResponse> businessDateResponse = businessDateManagementApi.getBusinessDate(BusinessDateHelper.BUSINESS_DATE)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(businessDateResponse);
+ public void checkBusinessDate(String businessDate) {
+ BusinessDateResponse businessDateResponse = ok(
+ () -> fineractClient.businessDateManagement().getBusinessDate(BusinessDateHelper.BUSINESS_DATE, Map.of()));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy");
LocalDate localDate = LocalDate.parse(businessDate, formatter);
- assertThat(businessDateResponse.body().getDate()).isEqualTo(localDate);
+ assertThat(businessDateResponse.getDate()).isEqualTo(localDate);
}
@Then("Set incorrect business date value {string} outcomes with an error")
- public void setIncorrectBusinessDateFailure(String businessDate) throws IOException {
+ public void setIncorrectBusinessDateFailure(String businessDate) {
BusinessDateUpdateRequest businessDateRequest = businessDateHelper.defaultBusinessDateRequest().date(businessDate);
- Response<BusinessDateUpdateResponse> businessDateRequestResponse = businessDateManagementApi
- .updateBusinessDate(null, businessDateRequest).execute();
- final ErrorResponse errorDetails = ErrorResponse.from(businessDateRequestResponse);
- assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setIncorrectBusinessDateFailure()).isEqualTo(400);
- assertThat(errorDetails.getSingleError().getDeveloperMessage()).isEqualTo(ErrorMessageHelper.setIncorrectBusinessDateFailure());
+ try {
+ fineractClient.businessDateManagement().updateBusinessDate(null, businessDateRequest, Map.of());
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ final ErrorResponse errorDetails = ErrorResponse.fromFeignException(e);
+ assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setIncorrectBusinessDateFailure()).isEqualTo(400);
+ assertThat(errorDetails.getSingleError().getDeveloperMessageWithoutPrefix())
+ .isEqualTo(ErrorMessageHelper.setIncorrectBusinessDateFailure());
+ }
}
@Then("Set incorrect business date with empty value {string} outcomes with an error")
- public void setNullOrEmptyBusinessDateFailure(String businessDate) throws IOException {
+ public void setNullOrEmptyBusinessDateFailure(String businessDate) {
BusinessDateUpdateRequest businessDateRequest = businessDateHelper.defaultBusinessDateRequest();
if (businessDate.equals("null")) {
businessDateRequest.date(null);
} else {
businessDateRequest.date(businessDate);
}
- Response<BusinessDateUpdateResponse> businessDateRequestResponse = businessDateManagementApi
- .updateBusinessDate(null, businessDateRequest).execute();
Integer httpStatusCodeExpected = 400;
- String errorBody = businessDateRequestResponse.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorBody, ErrorResponse.class);
- Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
- List<String> developerMessagesActual = errorResponse.getErrors().stream().map(ErrorResponse.Error::getDeveloperMessage).toList();
-
- List<String> developerMessagesExpected = asList(ErrorMessageHelper.setIncorrectBusinessDateMandatoryFailure(),
- ErrorMessageHelper.setIncorrectBusinessDateFailure());
-
- assertThat(httpStatusCodeActual)
- .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
- .isEqualTo(httpStatusCodeExpected);
- assertThat(developerMessagesActual)
- .as(ErrorMessageHelper.wrongErrorMessage(developerMessagesActual.toString(), developerMessagesExpected.toString()))
- .containsAll(developerMessagesExpected);
+ try {
+ fineractClient.businessDateManagement().updateBusinessDate(null, businessDateRequest, Map.of());
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ ErrorResponse errorResponse = ErrorResponse.fromFeignException(e);
+ Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
+ List<String> developerMessagesActual = errorResponse.getErrors().stream().map(ErrorResponse.ErrorDetail::getDeveloperMessage)
+ .toList();
+
+ List<String> developerMessagesExpected = asList(ErrorMessageHelper.setIncorrectBusinessDateMandatoryFailure(),
+ ErrorMessageHelper.setIncorrectBusinessDateFailure());
+
+ assertThat(httpStatusCodeActual)
+ .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
+ .isEqualTo(httpStatusCodeExpected);
+ assertThat(developerMessagesActual)
+ .as(ErrorMessageHelper.wrongErrorMessage(developerMessagesActual.toString(), developerMessagesExpected.toString()))
+ .containsAll(developerMessagesExpected);
+ }
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/ClientStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/ClientStepDef.java
index 622d43e69f..1ed2001391 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/ClientStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/ClientStepDef.java
@@ -18,34 +18,26 @@
*/
package org.apache.fineract.test.stepdef.common;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
-import java.io.IOException;
import java.util.Collections;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ClientAddressRequest;
import org.apache.fineract.client.models.PostClientsRequest;
import org.apache.fineract.client.models.PostClientsResponse;
-import org.apache.fineract.client.services.ClientApi;
import org.apache.fineract.test.factory.ClientRequestFactory;
-import org.apache.fineract.test.helper.CodeHelper;
-import org.apache.fineract.test.helper.ErrorHelper;
-import org.apache.fineract.test.helper.ErrorMessageHelper;
-import org.apache.fineract.test.helper.Utils;
import org.apache.fineract.test.messaging.event.EventCheckHelper;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class ClientStepDef extends AbstractStepDef {
@Autowired
- private ClientApi clientApi;
-
- @Autowired
- private CodeHelper codeHelper;
+ private FineractFeignClient fineractClient;
@Autowired
private ClientRequestFactory clientRequestFactory;
@@ -54,42 +46,38 @@ public class ClientStepDef extends AbstractStepDef {
private EventCheckHelper eventCheckHelper;
@When("Admin creates a client with random data")
- public void createClientRandomFirstNameLastName() throws IOException {
+ public void createClientRandomFirstNameLastName() {
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest();
- Response<PostClientsResponse> response = clientApi.create6(clientsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostClientsResponse response = ok(() -> fineractClient.clients().create6(clientsRequest));
testContext().set(TestContextKey.CLIENT_CREATE_RESPONSE, response);
eventCheckHelper.clientEventCheck(response);
}
@When("Admin creates a second client with random data")
- public void createSecondClientRandomFirstNameLastName() throws IOException {
+ public void createSecondClientRandomFirstNameLastName() {
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest();
- Response<PostClientsResponse> response = clientApi.create6(clientsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostClientsResponse response = ok(() -> fineractClient.clients().create6(clientsRequest));
testContext().set(TestContextKey.CLIENT_CREATE_SECOND_CLIENT_RESPONSE, response);
eventCheckHelper.clientEventCheck(response);
}
@When("Admin creates a client with Firstname {string} and Lastname {string}")
- public void createClient(String firstName, String lastName) throws IOException {
+ public void createClient(String firstName, String lastName) {
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest().firstname(firstName).lastname(lastName);
- Response<PostClientsResponse> response = clientApi.create6(clientsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostClientsResponse response = ok(() -> fineractClient.clients().create6(clientsRequest));
testContext().set(TestContextKey.CLIENT_CREATE_RESPONSE, response);
}
@When("Admin creates a client with Firstname {string} and Lastname {string} with address")
- public void createClientWithAddress(String firstName, String lastName) throws IOException {
- Long addressTypeId = codeHelper.createAddressTypeCodeValue(Utils.randomNameGenerator("Residential address", 4)).body()
- .getResourceId();
- Long countryId = codeHelper.createCountryCodeValue(Utils.randomNameGenerator("Hungary", 4)).body().getResourceId();
- Long stateId = codeHelper.createStateCodeValue(Utils.randomNameGenerator("Budapest", 4)).body().getResourceId();
+ public void createClientWithAddress(String firstName, String lastName) {
+ Long addressTypeId = 15L;
+ Long countryId = 17L;
+ Long stateId = 18L;
String city = "Budapest";
boolean addressIsActive = true;
String postalCode = "1000";
@@ -100,28 +88,26 @@ public class ClientStepDef extends AbstractStepDef {
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest().firstname(firstName).lastname(lastName)
.address(Collections.singletonList(addressRequest));
- Response<PostClientsResponse> response = clientApi.create6(clientsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostClientsResponse response = ok(() -> fineractClient.clients().create6(clientsRequest));
testContext().set(TestContextKey.CLIENT_CREATE_RESPONSE, response);
}
@When("Admin creates a client with Firstname {string} and Lastname {string} with {string} activation date")
- public void createClientWithSpecifiedDates(String firstName, String lastName, String activationDate) throws IOException {
+ public void createClientWithSpecifiedDates(String firstName, String lastName, String activationDate) {
PostClientsRequest clientsRequest = clientRequestFactory.defaultClientCreationRequest().firstname(firstName).lastname(lastName)
.activationDate(activationDate);
- Response<PostClientsResponse> response = clientApi.create6(clientsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ PostClientsResponse response = ok(() -> fineractClient.clients().create6(clientsRequest));
testContext().set(TestContextKey.CLIENT_CREATE_RESPONSE, response);
}
@Then("Client is created successfully")
- public void checkClientCreatedSuccessfully() throws IOException {
- Response<PostClientsResponse> response = testContext().get(TestContextKey.CLIENT_CREATE_RESPONSE);
+ public void checkClientCreatedSuccessfully() {
+ PostClientsResponse response = testContext().get(TestContextKey.CLIENT_CREATE_RESPONSE);
- assertThat(response.isSuccessful()).as(ErrorMessageHelper.requestFailed(response)).isTrue();
+ assertThat(response.getClientId()).isNotNull();
eventCheckHelper.clientEventCheck(response);
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/EventStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/EventStepDef.java
index 7fdd597426..98d721c475 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/EventStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/EventStepDef.java
@@ -28,7 +28,6 @@ import org.apache.fineract.test.messaging.event.Event;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class EventStepDef extends AbstractStepDef {
@@ -38,16 +37,16 @@ public class EventStepDef extends AbstractStepDef {
@Then("{string} event has been raised for the loan")
public void assertEventRaisedForLoan(String eventType) {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Class<? extends Event> eventTypeClazz = resolveEventType(eventType);
eventAssertion.assertEventRaised(eventTypeClazz, loanId);
}
@Then("No new event with type {string} has been raised for the loan")
public void assertEventNotRaisedForLoan(String eventType) {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
Class<? extends Event> eventTypeClazz = resolveEventType(eventType);
eventAssertion.assertEventNotRaised(eventTypeClazz, loanId);
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/GlobalConfigurationStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/GlobalConfigurationStepDef.java
index 7ae6f52f6f..88ea76f992 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/GlobalConfigurationStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/GlobalConfigurationStepDef.java
@@ -21,16 +21,14 @@ package org.apache.fineract.test.stepdef.common;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
-import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import org.apache.fineract.client.feign.FeignException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.CurrencyUpdateRequest;
-import org.apache.fineract.client.services.CurrencyApi;
-import org.apache.fineract.client.services.DefaultApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.helper.GlobalConfigurationHelper;
@@ -40,73 +38,90 @@ public class GlobalConfigurationStepDef {
@Autowired
private GlobalConfigurationHelper globalConfigurationHelper;
- @Autowired
- private DefaultApi defaultApi;
@Autowired
- private CurrencyApi currencyApi;
-
- private static final Gson GSON = new JSON().getGson();
+ private FineractFeignClient fineractClient;
@Given("Global configuration {string} is disabled")
- public void disableGlobalConfiguration(String configKey) throws IOException {
+ public void disableGlobalConfiguration(String configKey) {
globalConfigurationHelper.disableGlobalConfiguration(configKey, 0L);
}
@Given("Global configuration {string} is enabled")
- public void enableGlobalConfiguration(String configKey) throws IOException {
+ public void enableGlobalConfiguration(String configKey) {
globalConfigurationHelper.enableGlobalConfiguration(configKey, 0L);
}
@When("Global config {string} value set to {string}")
- public void setGlobalConfigValueString(String configKey, String configValue) throws IOException {
+ public void setGlobalConfigValueString(String configKey, String configValue) {
globalConfigurationHelper.setGlobalConfigValueString(configKey, configValue);
}
@When("Global config {string} value set to {string} through DefaultApi")
- public void setGlobalConfigValueStringDefaultApi(String configKey, String configValue) throws IOException {
+ public void setGlobalConfigValueStringDefaultApi(String configKey, String configValue) {
Long configValueLong = Long.valueOf(configValue);
- defaultApi.updateGlobalConfiguration(configKey, configValueLong);
+ fineractClient.defaultApi().updateGlobalConfiguration(configKey, configValueLong);
}
@When("Update currency with incorrect empty value outcomes with an error")
- public void updateCurrencyEmptyValueFailure() throws IOException {
+ public void updateCurrencyEmptyValueFailure() {
var request = new CurrencyUpdateRequest();
- var currencyResponse = currencyApi.updateCurrencies(request.currencies(Collections.emptyList())).execute();
- final ErrorResponse errorDetails = ErrorResponse.from(currencyResponse);
- assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setCurrencyEmptyValueFailure()).isEqualTo(400);
- assertThat(errorDetails.getSingleError().getDeveloperMessage()).isEqualTo(ErrorMessageHelper.setCurrencyEmptyValueFailure());
+ try {
+ fineractClient.currency().updateCurrencies(request.currencies(Collections.emptyList()), Map.of());
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ final ErrorResponse errorDetails = ErrorResponse.fromFeignException(e);
+ assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setCurrencyEmptyValueFailure()).isEqualTo(400);
+
+ if (errorDetails.getErrors() != null && !errorDetails.getErrors().isEmpty()) {
+ boolean hasExpectedError = errorDetails.getErrors().stream().anyMatch(
+ error -> ErrorMessageHelper.setCurrencyEmptyValueFailure().equals(error.getDeveloperMessageWithoutPrefix()));
+ assertThat(hasExpectedError).as("Expected error message: " + ErrorMessageHelper.setCurrencyEmptyValueFailure()
+ + " in errors: " + errorDetails.getErrors()).isTrue();
+ } else {
+ assertThat(errorDetails.getSingleError().getDeveloperMessageWithoutPrefix())
+ .isEqualTo(ErrorMessageHelper.setCurrencyEmptyValueFailure());
+ }
+ }
}
@When("Update currency as NULL value outcomes with an error")
- public void updateCurrencyNullValueFailure() throws IOException {
+ public void updateCurrencyNullValueFailure() {
var request = new CurrencyUpdateRequest();
- var currencyResponse = currencyApi.updateCurrencies(request.currencies(null)).execute();
Integer httpStatusCodeExpected = 400;
- String errorBody = currencyResponse.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorBody, ErrorResponse.class);
- Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
- List<String> developerMessagesActual = errorResponse.getErrors().stream().map(ErrorResponse.Error::getDeveloperMessage).toList();
-
- List<String> developerMessagesExpected = asList(ErrorMessageHelper.setCurrencyEmptyValueFailure(),
- ErrorMessageHelper.setCurrencyNullValueMandatoryFailure());
-
- assertThat(httpStatusCodeActual)
- .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
- .isEqualTo(httpStatusCodeExpected);
- assertThat(developerMessagesActual)
- .as(ErrorMessageHelper.wrongErrorMessage(developerMessagesActual.toString(), developerMessagesExpected.toString()))
- .containsAll(developerMessagesExpected);
+ try {
+ fineractClient.currency().updateCurrencies(request.currencies(null));
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ ErrorResponse errorResponse = ErrorResponse.fromFeignException(e);
+ Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
+ List<String> developerMessagesActual = errorResponse.getErrors().stream()
+ .map(ErrorResponse.ErrorDetail::getDeveloperMessageWithoutPrefix).toList();
+
+ List<String> developerMessagesExpected = asList(ErrorMessageHelper.setCurrencyEmptyValueFailure(),
+ ErrorMessageHelper.setCurrencyNullValueMandatoryFailure());
+
+ assertThat(httpStatusCodeActual)
+ .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
+ .isEqualTo(httpStatusCodeExpected);
+ assertThat(developerMessagesActual)
+ .as(ErrorMessageHelper.wrongErrorMessage(developerMessagesActual.toString(), developerMessagesExpected.toString()))
+ .containsAll(developerMessagesExpected);
+ }
}
@When("Update currency as {string} value outcomes with an error")
- public void updateCurrencyIncorrectValueFailure(String currency) throws IOException {
+ public void updateCurrencyIncorrectValueFailure(String currency) {
var request = new CurrencyUpdateRequest();
- var currencyResponse = currencyApi.updateCurrencies(request.currencies(Collections.singletonList(currency))).execute();
- final ErrorResponse errorDetails = ErrorResponse.from(currencyResponse);
- assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setCurrencyIncorrectValueFailure(currency)).isEqualTo(404);
- assertThat(errorDetails.getSingleError().getDeveloperMessage())
- .isEqualTo(ErrorMessageHelper.setCurrencyIncorrectValueFailure(currency));
+ try {
+ fineractClient.currency().updateCurrencies(request.currencies(Collections.singletonList(currency)));
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ final ErrorResponse errorDetails = ErrorResponse.fromFeignException(e);
+ assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.setCurrencyIncorrectValueFailure(currency)).isEqualTo(404);
+ assertThat(errorDetails.getSingleError().getDeveloperMessageWithoutPrefix())
+ .isEqualTo(ErrorMessageHelper.setCurrencyIncorrectValueFailure(currency));
+ }
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/JournalEntriesStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/JournalEntriesStepDef.java
index 8ec36b0923..d302c86afc 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/JournalEntriesStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/JournalEntriesStepDef.java
@@ -28,10 +28,16 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
+import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.feign.services.JournalEntriesApi;
+import org.apache.fineract.client.feign.services.LoansApi;
import org.apache.fineract.client.models.GetJournalEntriesTransactionIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
@@ -39,16 +45,12 @@ import org.apache.fineract.client.models.JournalEntryCommand;
import org.apache.fineract.client.models.JournalEntryTransactionItem;
import org.apache.fineract.client.models.PostJournalEntriesResponse;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.JournalEntriesApi;
-import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.test.data.TransactionType;
import org.apache.fineract.test.factory.LoanRequestFactory;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class JournalEntriesStepDef extends AbstractStepDef {
@@ -56,27 +58,33 @@ public class JournalEntriesStepDef extends AbstractStepDef {
public static final String DATE_FORMAT = "dd MMMM yyyy";
@Autowired
- private LoansApi loansApi;
-
- @Autowired
- private JournalEntriesApi journalEntriesApi;
+ private FineractFeignClient fineractFeignClient;
@Autowired
private LoanRequestFactory loanRequestFactory;
+ private LoansApi loansApi() {
+ return fineractFeignClient.loans();
+ }
+
+ private JournalEntriesApi journalEntriesApi() {
+ return fineractFeignClient.journalEntries();
+ }
+
@Then("Loan Transactions tab has a {string} transaction with date {string} which has the following Journal entries:")
public void journalEntryDataCheck(String transactionType, String transactionDate, DataTable table) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("staffInSelectedOfficeOnly", false);
+ queryParams.put("associations", "transactions");
+ GetLoansLoanIdResponse loanDetailsResponse = loansApi().retrieveLoan(loanId, queryParams);
TransactionType transactionType1 = TransactionType.valueOf(transactionType);
String transactionTypeExpected = transactionType1.getValue();
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
List<GetLoansLoanIdTransactions> transactionsMatch = transactions.stream()
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))
&& transactionTypeExpected.equals(t.getType().getCode().substring(20)))
@@ -114,7 +122,8 @@ public class JournalEntriesStepDef extends AbstractStepDef {
}).collect(Collectors.toList());
possibleActualValuesList.add(actualValuesList);
- boolean containsExpectedValues = actualValuesList.stream().anyMatch(actualValues -> actualValues.equals(expectedValues));
+ boolean containsExpectedValues = actualValuesList.stream()
+ .anyMatch(actualValues -> matchesWithBigDecimalComparison(actualValues, expectedValues));
if (containsExpectedValues) {
containsAnyExpected = true;
}
@@ -125,38 +134,50 @@ public class JournalEntriesStepDef extends AbstractStepDef {
}
}
+ private boolean matchesWithBigDecimalComparison(List<String> actualValues, List<String> expectedValues) {
+ if (actualValues.size() != expectedValues.size()) {
+ return false;
+ }
+ for (int i = 0; i < actualValues.size(); i++) {
+ String actual = actualValues.get(i);
+ String expected = expectedValues.get(i);
+ if (!valuesMatch(actual, expected)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean valuesMatch(String actual, String expected) {
+ if (Objects.equals(actual, expected)) {
+ return true;
+ }
+ if (actual == null || expected == null) {
+ return false;
+ }
+ try {
+ BigDecimal actualDecimal = new BigDecimal(actual);
+ BigDecimal expectedDecimal = new BigDecimal(expected);
+ return actualDecimal.compareTo(expectedDecimal) == 0;
+ } catch (NumberFormatException e) {
+ return actual.equals(expected);
+ }
+ }
+
public List<List<JournalEntryTransactionItem>> getJournalLinesActualList(List<GetLoansLoanIdTransactions> transactionsMatch) {
List<List<JournalEntryTransactionItem>> journalLinesActualList = transactionsMatch.stream().map(t -> {
String transactionId = "L" + t.getId();
- Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
+ GetJournalEntriesTransactionIdResponse journalEntryDataResponse = null;
try {
- journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- transactionId, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- true//
- ).execute();
- ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
- } catch (IOException e) {
+ Map<String, Object> journalQueryParams = new HashMap<>();
+ journalQueryParams.put("transactionId", transactionId);
+ journalQueryParams.put("runningBalance", true);
+ journalEntryDataResponse = journalEntriesApi().retrieveAll1(journalQueryParams);
+ } catch (Exception e) {
log.error("Exception", e);
}
- return journalEntryDataResponse.body().getPageItems();
+ return journalEntryDataResponse.getPageItems();
}).collect(Collectors.toList());
return journalLinesActualList;
@@ -165,16 +186,17 @@ public class JournalEntriesStepDef extends AbstractStepDef {
@Then("Loan Transactions tab has {int} a {string} transactions with date {string} which has the following Journal entries:")
public void journalEntryDataCheck(int numberTrns, String transactionType, String transactionDate, DataTable table) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("staffInSelectedOfficeOnly", false);
+ queryParams.put("associations", "transactions");
+ GetLoansLoanIdResponse loanDetailsResponse = loansApi().retrieveLoan(loanId, queryParams);
TransactionType transactionType1 = TransactionType.valueOf(transactionType);
String transactionTypeExpected = transactionType1.getValue();
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
List<GetLoansLoanIdTransactions> transactionsMatch = transactions.stream()
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))
&& transactionTypeExpected.equals(t.getType().getCode().substring(20)))
@@ -191,43 +213,25 @@ public class JournalEntriesStepDef extends AbstractStepDef {
@Then("Reversed loan capitalized income amortization transaction has the following Journal entries:")
public void capitalizedIncomeAmortizationJournalEntryDataCheck(final DataTable table) {
final long capitalizedIncomeAmortizationId = testContext().get(TestContextKey.LOAN_CAPITALIZED_INCOME_AMORTIZATION_ID);
- final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- assert loanResponse.body() != null;
- final long loanId = loanResponse.body().getLoanId();
+ final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ final long loanId = loanResponse.getLoanId();
final String resourceId = String.valueOf(loanId);
- List<JournalEntryTransactionItem> journalLinesActualList;
final String transactionId = "L" + capitalizedIncomeAmortizationId;
- Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
+ GetJournalEntriesTransactionIdResponse journalEntryDataResponse = null;
try {
- journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- transactionId, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- loanId, //
- null, //
- null, //
- true//
- ).execute();
- ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
- } catch (IOException e) {
+ Map<String, Object> journalQueryParams = new HashMap<>();
+ journalQueryParams.put("transactionId", transactionId);
+ journalQueryParams.put("loanId", loanId);
+ journalQueryParams.put("runningBalance", true);
+ journalEntryDataResponse = journalEntriesApi().retrieveAll1(journalQueryParams);
+ } catch (Exception e) {
log.error("Exception", e);
}
- assert journalEntryDataResponse != null;
- assert journalEntryDataResponse.body() != null;
- journalLinesActualList = journalEntryDataResponse.body().getPageItems();
+ List<JournalEntryTransactionItem> journalLinesActualList = new ArrayList<>();
+ if (journalEntryDataResponse != null) {
+ journalLinesActualList = journalEntryDataResponse.getPageItems();
+ }
final List<List<String>> data = table.asLists();
for (int i = 1; i < data.size(); i++) {
@@ -253,7 +257,7 @@ public class JournalEntriesStepDef extends AbstractStepDef {
possibleActualValuesList.add(actualValues);
final boolean containsExpectedValues = possibleActualValuesList.stream()
- .anyMatch(actualValue -> actualValue.equals(expectedValues));
+ .anyMatch(actualValue -> matchesWithBigDecimalComparison(actualValue, expectedValues));
if (containsExpectedValues) {
containsAnyExpected = true;
}
@@ -267,17 +271,18 @@ public class JournalEntriesStepDef extends AbstractStepDef {
@Then("In Loan transactions the replayed {string} transaction with date {string} has a reverted transaction pair with the following Journal entries:")
public void revertedJournalEntryDataCheck(String transactionType, String transactionDate, DataTable table) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
String resourceId = String.valueOf(loanId);
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
-
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("staffInSelectedOfficeOnly", false);
+ queryParams.put("associations", "transactions");
+ GetLoansLoanIdResponse loanDetailsResponse = loansApi().retrieveLoan(loanId, queryParams);
TransactionType transactionType1 = TransactionType.valueOf(transactionType);
String transactionTypeExpected = transactionType1.getValue();
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
List<GetLoansLoanIdTransactions> transactionsMatch = transactions.stream()
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))
@@ -289,35 +294,17 @@ public class JournalEntriesStepDef extends AbstractStepDef {
.collect(Collectors.toList());
List<List<JournalEntryTransactionItem>> journalLinesActualList = transactionIdList.stream().map(t -> {
- Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
+ GetJournalEntriesTransactionIdResponse journalEntryDataResponse = null;
try {
- journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- t, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- true//
- ).execute();
- ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
- } catch (IOException e) {
+ Map<String, Object> journalQueryParams = new HashMap<>();
+ journalQueryParams.put("transactionId", t);
+ journalQueryParams.put("runningBalance", true);
+ journalEntryDataResponse = journalEntriesApi().retrieveAll1(journalQueryParams);
+ } catch (Exception e) {
log.error("Exception", e);
}
- return journalEntryDataResponse.body().getPageItems();
+ return journalEntryDataResponse.getPageItems();
}).collect(Collectors.toList());
List<List<String>> data = table.asLists();
@@ -341,7 +328,8 @@ public class JournalEntriesStepDef extends AbstractStepDef {
}).collect(Collectors.toList());
possibleActualValuesList.add(actualValuesList);
- boolean containsExpectedValues = actualValuesList.stream().anyMatch(actualValues -> actualValues.equals(expectedValues));
+ boolean containsExpectedValues = actualValuesList.stream()
+ .anyMatch(actualValues -> matchesWithBigDecimalComparison(actualValues, expectedValues));
if (containsExpectedValues) {
containsAnyExpected = true;
}
@@ -355,16 +343,17 @@ public class JournalEntriesStepDef extends AbstractStepDef {
@Then("Loan Transactions tab has a {string} transaction with date {string} has no the Journal entries")
public void journalEntryNoDataCheck(String transactionType, String transactionDate) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("staffInSelectedOfficeOnly", false);
+ queryParams.put("associations", "transactions");
+ GetLoansLoanIdResponse loanDetailsResponse = loansApi().retrieveLoan(loanId, queryParams);
TransactionType transactionType1 = TransactionType.valueOf(transactionType);
String transactionTypeExpected = transactionType1.getValue();
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
List<GetLoansLoanIdTransactions> transactionsMatch = transactions.stream()
.filter(t -> transactionDate.equals(formatter.format(t.getDate()))
&& transactionTypeExpected.equals(t.getType().getCode().substring(20)))
@@ -372,58 +361,43 @@ public class JournalEntriesStepDef extends AbstractStepDef {
List<List<JournalEntryTransactionItem>> journalLinesActualList = transactionsMatch.stream().map(t -> {
String transactionId = "L" + t.getId();
- Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
+ GetJournalEntriesTransactionIdResponse journalEntryDataResponse = null;
try {
- journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- transactionId, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- true//
- ).execute();
- ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
- } catch (IOException e) {
+ Map<String, Object> journalQueryParams = new HashMap<>();
+ journalQueryParams.put("transactionId", transactionId);
+ journalQueryParams.put("runningBalance", true);
+ journalEntryDataResponse = journalEntriesApi().retrieveAll1(journalQueryParams);
+ } catch (Exception e) {
log.error("Exception", e);
}
- return journalEntryDataResponse.body().getPageItems();
+ return journalEntryDataResponse.getPageItems();
}).collect(Collectors.toList());
assertThat(journalLinesActualList.stream().findFirst().get().size()).isZero();
}
- public Response<PostJournalEntriesResponse> addManualJournalEntryWithoutExternalAssetOwner(String amount, String date)
- throws IOException {
+ public PostJournalEntriesResponse addManualJournalEntryWithoutExternalAssetOwner(String amount, String date) throws IOException {
LocalDate transactionDate = LocalDate.parse(date, FORMATTER_EN);
JournalEntryCommand journalEntriesRequest = loanRequestFactory.defaultManualJournalEntryRequest(new BigDecimal(amount))
.transactionDate(transactionDate);
- Response<PostJournalEntriesResponse> journalEntriesResponse = journalEntriesApi.createGLJournalEntry("", journalEntriesRequest)
- .execute();
+ Map<String, Object> createJournalQueryParams = new HashMap<>();
+ createJournalQueryParams.put("command", "");
+ PostJournalEntriesResponse journalEntriesResponse = journalEntriesApi().createGLJournalEntry(journalEntriesRequest,
+ createJournalQueryParams);
testContext().set(TestContextKey.MANUAL_JOURNAL_ENTRIES_REQUEST, journalEntriesRequest);
return journalEntriesResponse;
}
- public Response<PostJournalEntriesResponse> addManualJournalEntryWithExternalAssetOwner(String amount, String date,
- String externalAssetOwner) throws IOException {
+ public PostJournalEntriesResponse addManualJournalEntryWithExternalAssetOwner(String amount, String date, String externalAssetOwner)
+ throws IOException {
LocalDate transactionDate = LocalDate.parse(date, FORMATTER_EN);
JournalEntryCommand journalEntriesRequest = loanRequestFactory
.defaultManualJournalEntryRequest(new BigDecimal(amount), externalAssetOwner).transactionDate(transactionDate);
- Response<PostJournalEntriesResponse> journalEntriesResponse = journalEntriesApi.createGLJournalEntry("", journalEntriesRequest)
- .execute();
+ Map<String, Object> createJournalQueryParams = new HashMap<>();
+ createJournalQueryParams.put("command", "");
+ PostJournalEntriesResponse journalEntriesResponse = journalEntriesApi().createGLJournalEntry(journalEntriesRequest,
+ createJournalQueryParams);
testContext().set(TestContextKey.MANUAL_JOURNAL_ENTRIES_REQUEST, journalEntriesRequest);
return journalEntriesResponse;
}
@@ -431,62 +405,41 @@ public class JournalEntriesStepDef extends AbstractStepDef {
@Then("Admin creates manual Journal entry with {string} amount and {string} date and unique External Asset Owner")
public void createManualJournalEntryWithExternalAssetOwner(String amount, String date) throws IOException {
String ownerExternalIdStored = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
- Response<PostJournalEntriesResponse> journalEntriesResponse = addManualJournalEntryWithExternalAssetOwner(amount, date,
+ PostJournalEntriesResponse journalEntriesResponse = addManualJournalEntryWithExternalAssetOwner(amount, date,
ownerExternalIdStored);
testContext().set(TestContextKey.MANUAL_JOURNAL_ENTRIES_RESPONSE, journalEntriesResponse);
- ErrorHelper.checkSuccessfulApiCall(journalEntriesResponse);
}
@Then("Admin creates manual Journal entry with {string} amount and {string} date and empty External Asset Owner")
public void createManualJournalEntryWithEmptyExternalAssetOwner(String amount, String date) throws IOException {
- Response<PostJournalEntriesResponse> journalEntriesResponse = addManualJournalEntryWithExternalAssetOwner(amount, date, "");
+ PostJournalEntriesResponse journalEntriesResponse = addManualJournalEntryWithExternalAssetOwner(amount, date, "");
testContext().set(TestContextKey.MANUAL_JOURNAL_ENTRIES_RESPONSE, journalEntriesResponse);
- ErrorHelper.checkSuccessfulApiCall(journalEntriesResponse);
}
@Then("Admin creates manual Journal entry with {string} amount and {string} date and without External Asset Owner")
public void createManualJournalEntryWithoutExternalAssetOwner(String amount, String date) throws IOException {
- Response<PostJournalEntriesResponse> journalEntriesResponse = addManualJournalEntryWithoutExternalAssetOwner(amount, date);
+ PostJournalEntriesResponse journalEntriesResponse = addManualJournalEntryWithoutExternalAssetOwner(amount, date);
testContext().set(TestContextKey.MANUAL_JOURNAL_ENTRIES_RESPONSE, journalEntriesResponse);
- ErrorHelper.checkSuccessfulApiCall(journalEntriesResponse);
}
@Then("Verify manual Journal entry with External Asset Owner {string} and with the following Journal entries:")
public void checkManualJournalEntry(String externalAssetOwnerEnabled, DataTable table) {
- Response<PostJournalEntriesResponse> journalEnriesResponse = testContext().get(TestContextKey.MANUAL_JOURNAL_ENTRIES_RESPONSE);
- PostJournalEntriesResponse journalEntriesResponseBody = journalEnriesResponse.body();
+ PostJournalEntriesResponse journalEnriesResponse = testContext().get(TestContextKey.MANUAL_JOURNAL_ENTRIES_RESPONSE);
+ PostJournalEntriesResponse journalEntriesResponseBody = journalEnriesResponse;
String transactionId = journalEntriesResponseBody.getTransactionId();
JournalEntryCommand journalEntriesRequest = testContext().get(TestContextKey.MANUAL_JOURNAL_ENTRIES_REQUEST);
- Response<GetJournalEntriesTransactionIdResponse> journalEntryDataResponse = null;
+ GetJournalEntriesTransactionIdResponse journalEntryDataResponse = null;
try {
- journalEntryDataResponse = journalEntriesApi.retrieveAll1(//
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- transactionId, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- null, //
- true//
- ).execute();
- ErrorHelper.checkSuccessfulApiCall(journalEntryDataResponse);
- } catch (IOException e) {
+ Map<String, Object> journalQueryParams = new HashMap<>();
+ journalQueryParams.put("transactionId", transactionId);
+ journalQueryParams.put("runningBalance", true);
+ journalEntryDataResponse = journalEntriesApi().retrieveAll1(journalQueryParams);
+ } catch (Exception e) {
log.error("Exception", e);
}
@@ -500,7 +453,7 @@ public class JournalEntriesStepDef extends AbstractStepDef {
}
boolean containsAnyExpected = false;
- GetJournalEntriesTransactionIdResponse journalEntryData = journalEntryDataResponse.body();
+ GetJournalEntriesTransactionIdResponse journalEntryData = journalEntryDataResponse;
List<JournalEntryTransactionItem> journalLinesActual = journalEntryData.getPageItems();
@@ -511,7 +464,7 @@ public class JournalEntriesStepDef extends AbstractStepDef {
actualValues.add(t.getGlAccountName() == null ? null : t.getGlAccountName());
actualValues.add("DEBIT".equals(t.getEntryType().getValue()) ? String.valueOf(t.getAmount()) : null);
actualValues.add("CREDIT".equals(t.getEntryType().getValue()) ? String.valueOf(t.getAmount()) : null);
- actualValues.add(String.valueOf(t.getManualEntry()).toLowerCase());
+ actualValues.add(String.valueOf(t.getManualEntry()).toLowerCase(Locale.ROOT));
if (Boolean.parseBoolean(externalAssetOwnerEnabled)) {
actualValues.add(t.getExternalAssetOwner() == null ? null : t.getExternalAssetOwner());
}
@@ -521,7 +474,8 @@ public class JournalEntriesStepDef extends AbstractStepDef {
possibleActualValuesList.add(actualValuesList);
- boolean containsExpectedValues = actualValuesList.stream().anyMatch(actualValues -> actualValues.equals(expectedValues));
+ boolean containsExpectedValues = actualValuesList.stream()
+ .anyMatch(actualValues -> matchesWithBigDecimalComparison(actualValues, expectedValues));
if (containsExpectedValues) {
containsAnyExpected = true;
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/UserStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/UserStepDef.java
index 2c424b2372..534f624e4c 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/UserStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/UserStepDef.java
@@ -18,57 +18,47 @@
*/
package org.apache.fineract.test.stepdef.common;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import io.cucumber.java.en.When;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.fineract.client.models.GetRolesResponse;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.PostRolesRequest;
import org.apache.fineract.client.models.PostRolesResponse;
import org.apache.fineract.client.models.PostUsersRequest;
import org.apache.fineract.client.models.PostUsersResponse;
import org.apache.fineract.client.models.PutRolesRoleIdPermissionsRequest;
-import org.apache.fineract.client.models.PutRolesRoleIdPermissionsResponse;
-import org.apache.fineract.client.services.RolesApi;
-import org.apache.fineract.client.services.UsersApi;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.Utils;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class UserStepDef extends AbstractStepDef {
private static final String EMAIL = "test@test.com";
@Autowired
- private RolesApi rolesApi;
-
- @Autowired
- private UsersApi usersApi;
+ private FineractFeignClient fineractClient;
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";
@When("Admin creates new user with {string} username, {string} role name and given permissions:")
- public void createUserWithUsernameAndRoles(String username, String roleName, List<String> permissions) throws IOException {
- Response<List<GetRolesResponse>> retrieveAllRolesResponse = rolesApi.retrieveAllRoles().execute();
- ErrorHelper.checkSuccessfulApiCall(retrieveAllRolesResponse);
+ public void createUserWithUsernameAndRoles(String username, String roleName, List<String> permissions) {
+ ok(() -> fineractClient.roles().retrieveAllRoles());
PostRolesRequest newRoleRequest = new PostRolesRequest().name(Utils.randomNameGenerator(roleName, 8)).description(roleName);
- Response<PostRolesResponse> createNewRole = rolesApi.createRole(newRoleRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(createNewRole);
- Long roleId = createNewRole.body().getResourceId();
+ PostRolesResponse createNewRole = ok(() -> fineractClient.roles().createRole(newRoleRequest));
+ Long roleId = createNewRole.getResourceId();
Map<String, Boolean> permissionMap = new HashMap<>();
permissions.forEach(role -> permissionMap.put(role, true));
PutRolesRoleIdPermissionsRequest putRolesRoleIdPermissionsRequest = new PutRolesRoleIdPermissionsRequest()
.permissions(permissionMap);
- Response<PutRolesRoleIdPermissionsResponse> updateRolePermissionResponse = rolesApi
- .updateRolePermissions(roleId, putRolesRoleIdPermissionsRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(updateRolePermissionResponse);
+ ok(() -> fineractClient.roles().updateRolePermissions(roleId, putRolesRoleIdPermissionsRequest));
+ String generatedUsername = Utils.randomNameGenerator(username, 8);
PostUsersRequest postUsersRequest = new PostUsersRequest() //
- .username(Utils.randomNameGenerator(username, 8)) //
+ .username(generatedUsername) //
.email(EMAIL) //
.firstname(username) //
.lastname(username) //
@@ -78,8 +68,9 @@ public class UserStepDef extends AbstractStepDef {
.repeatPassword(PWD_USER_WITH_ROLE) //
.roles(List.of(roleId));
- Response<PostUsersResponse> createUserResponse = usersApi.create15(postUsersRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(createUserResponse);
+ PostUsersResponse createUserResponse = ok(() -> fineractClient.users().create15(postUsersRequest));
testContext().set(TestContextKey.CREATED_SIMPLE_USER_RESPONSE, createUserResponse);
+ testContext().set(TestContextKey.CREATED_SIMPLE_USER_USERNAME, generatedUsername);
+ testContext().set(TestContextKey.CREATED_SIMPLE_USER_PASSWORD, PWD_USER_WITH_ROLE);
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/datatable/DatatablesStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/datatable/DatatablesStepDef.java
index 68409ffa21..e329f2294a 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/datatable/DatatablesStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/datatable/DatatablesStepDef.java
@@ -19,29 +19,28 @@
package org.apache.fineract.test.stepdef.datatable;
import static java.util.function.Function.identity;
-import static org.apache.fineract.test.helper.ErrorHelper.checkSuccessfulApiCall;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.fineract.client.feign.FeignException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetDataTablesResponse;
import org.apache.fineract.client.models.PostColumnHeaderData;
import org.apache.fineract.client.models.PostDataTablesRequest;
import org.apache.fineract.client.models.PostDataTablesResponse;
import org.apache.fineract.client.models.ResultsetColumnHeaderData;
-import org.apache.fineract.client.services.DataTablesApi;
import org.apache.fineract.test.data.datatable.DatatableColumnType;
import org.apache.fineract.test.data.datatable.DatatableEntityType;
import org.apache.fineract.test.data.datatable.DatatableNameGenerator;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class DatatablesStepDef extends AbstractStepDef {
@@ -50,39 +49,35 @@ public class DatatablesStepDef extends AbstractStepDef {
public static final String DATATABLE_QUERY_RESPONSE = "DatatableQueryResponse";
@Autowired
- private DataTablesApi dataTablesApi;
+ private FineractFeignClient fineractClient;
@Autowired
private DatatableNameGenerator datatableNameGenerator;
@When("A datatable for {string} is created")
- public void whenDatatableCreated(String entityTypeStr) throws IOException {
+ public void whenDatatableCreated(String entityTypeStr) {
DatatableEntityType entityType = DatatableEntityType.fromString(entityTypeStr);
List<PostColumnHeaderData> columns = createRandomDatatableColumnsRequest();
PostDataTablesRequest request = createDatatableRequest(entityType, columns);
- Response<PostDataTablesResponse> response = dataTablesApi.createDatatable(request).execute();
- checkSuccessfulApiCall(response);
+ PostDataTablesResponse response = ok(() -> fineractClient.dataTables().createDatatable(request, Map.of()));
- PostDataTablesResponse responseBody = response.body();
- testContext().set(CREATE_DATATABLE_RESULT_KEY, responseBody);
- testContext().set(DATATABLE_NAME, responseBody.getResourceIdentifier());
+ testContext().set(CREATE_DATATABLE_RESULT_KEY, response);
+ testContext().set(DATATABLE_NAME, response.getResourceIdentifier());
}
@When("A datatable for {string} is created with the following extra columns:")
- public void whenDatatableCreatedWithFollowingExtraColumns(String entityTypeStr, DataTable dataTable) throws IOException {
+ public void whenDatatableCreatedWithFollowingExtraColumns(String entityTypeStr, DataTable dataTable) {
DatatableEntityType entityType = DatatableEntityType.fromString(entityTypeStr);
List<List<String>> rows = dataTable.asLists();
List<List<String>> rowsWithoutHeader = rows.subList(1, rows.size());
List<PostColumnHeaderData> columns = createDatatableColumnsRequest(rowsWithoutHeader);
PostDataTablesRequest request = createDatatableRequest(entityType, columns);
- Response<PostDataTablesResponse> response = dataTablesApi.createDatatable(request).execute();
- checkSuccessfulApiCall(response);
+ PostDataTablesResponse response = ok(() -> fineractClient.dataTables().createDatatable(request, Map.of()));
- PostDataTablesResponse responseBody = response.body();
- testContext().set(CREATE_DATATABLE_RESULT_KEY, responseBody);
- testContext().set(DATATABLE_NAME, responseBody.getResourceIdentifier());
+ testContext().set(CREATE_DATATABLE_RESULT_KEY, response);
+ testContext().set(DATATABLE_NAME, response.getResourceIdentifier());
}
private List<PostColumnHeaderData> createDatatableColumnsRequest(List<List<String>> rowsWithoutHeader) {
@@ -104,17 +99,15 @@ public class DatatablesStepDef extends AbstractStepDef {
}
@When("A multirow datatable for {string} is created")
- public void whenMultirowDatatableCreated(String entityTypeStr) throws IOException {
+ public void whenMultirowDatatableCreated(String entityTypeStr) {
DatatableEntityType entityType = DatatableEntityType.fromString(entityTypeStr);
List<PostColumnHeaderData> columns = createRandomDatatableColumnsRequest();
PostDataTablesRequest request = createDatatableRequest(entityType, columns, true);
- Response<PostDataTablesResponse> response = dataTablesApi.createDatatable(request).execute();
- checkSuccessfulApiCall(response);
+ PostDataTablesResponse response = ok(() -> fineractClient.dataTables().createDatatable(request, Map.of()));
- PostDataTablesResponse responseBody = response.body();
- testContext().set(CREATE_DATATABLE_RESULT_KEY, responseBody);
- testContext().set(DATATABLE_NAME, responseBody.getResourceIdentifier());
+ testContext().set(CREATE_DATATABLE_RESULT_KEY, response);
+ testContext().set(DATATABLE_NAME, response.getResourceIdentifier());
}
private List<PostColumnHeaderData> createRandomDatatableColumnsRequest() {
@@ -145,12 +138,10 @@ public class DatatablesStepDef extends AbstractStepDef {
}
@Then("The following column definitions match:")
- public void thenColumnsMatch(DataTable dataTable) throws IOException {
+ public void thenColumnsMatch(DataTable dataTable) {
String datatableName = testContext().get(DATATABLE_NAME);
- Response<GetDataTablesResponse> httpResponse = dataTablesApi.getDatatable(datatableName).execute();
- checkSuccessfulApiCall(httpResponse);
+ GetDataTablesResponse response = ok(() -> fineractClient.dataTables().getDatatable(datatableName, Map.of()));
- GetDataTablesResponse response = httpResponse.body();
Map<String, ResultsetColumnHeaderData> columnMap = response.getColumnHeaderData().stream()
.collect(Collectors.toMap(ResultsetColumnHeaderData::getColumnName, identity()));
@@ -176,22 +167,25 @@ public class DatatablesStepDef extends AbstractStepDef {
}
@When("The client calls the query endpoint for the created datatable with {string} column filter, and {string} value filter")
- public void thenColum23nsMatch(String columnFilter, String valueFilter) throws IOException {
- Response<String> response = dataTablesApi.queryValues(testContext().get(DATATABLE_NAME), columnFilter, valueFilter, columnFilter)
- .execute();
- testContext().set(DATATABLE_QUERY_RESPONSE, response);
+ public void thenColum23nsMatch(String columnFilter, String valueFilter) {
+ try {
+ fineractClient.dataTables().queryValues(testContext().get(DATATABLE_NAME),
+ Map.of("columnFilter", columnFilter, "valueFilter", valueFilter, "resultColumns", columnFilter));
+ } catch (FeignException e) {
+ testContext().set(DATATABLE_QUERY_RESPONSE, e);
+ }
}
@Then("The status of the HTTP response should be {int}")
public void thenStatusCodeMatch(int statusCode) {
- Response<String> response = testContext().get(DATATABLE_QUERY_RESPONSE);
- assertThat(response.code()).isEqualTo(statusCode);
+ FeignException exception = testContext().get(DATATABLE_QUERY_RESPONSE);
+ assertThat(exception.status()).isEqualTo(statusCode);
}
@Then("The response body should contain the following message: {string}")
- public void thenColumnsMatch(String json) throws IOException {
- Response<String> response = testContext().get(DATATABLE_QUERY_RESPONSE);
- String jsonResponse = response.errorBody().string();
+ public void thenColumnsMatch(String json) {
+ FeignException exception = testContext().get(DATATABLE_QUERY_RESPONSE);
+ String jsonResponse = exception.responseBodyAsString();
assertThat(jsonResponse).contains(json);
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/hook/MessagingHook.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/hook/MessagingHook.java
index 4004c0f5c5..7bd1c0aa05 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/hook/MessagingHook.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/hook/MessagingHook.java
@@ -18,16 +18,50 @@
*/
package org.apache.fineract.test.stepdef.hook;
+import static org.awaitility.Awaitility.await;
+
import io.cucumber.java.Before;
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicBoolean;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.test.messaging.config.EventProperties;
import org.apache.fineract.test.messaging.store.EventStore;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.config.JmsListenerEndpointRegistry;
+import org.springframework.jms.listener.DefaultMessageListenerContainer;
+@Slf4j
public class MessagingHook {
@Autowired
private EventStore eventStore;
- @Before
+ @Autowired(required = false)
+ private JmsListenerEndpointRegistry registry;
+
+ @Autowired(required = false)
+ private EventProperties eventProperties;
+
+ private static final AtomicBoolean jmsStartupDelayCompleted = new AtomicBoolean(false);
+ private static final Duration STARTUP_TIMEOUT = Duration.ofSeconds(20);
+
+ @Before(order = 0)
+ public void waitForJmsListenerStartup() {
+ if (jmsStartupDelayCompleted.compareAndSet(false, true) && eventProperties != null
+ && eventProperties.isEventVerificationEnabled()) {
+ if (registry == null) {
+ log.warn("=== JmsListenerEndpointRegistry not available - skipping JMS listener readiness check ===");
+ return;
+ }
+ log.info("=== FIRST SCENARIO - Waiting for JMS Listener to connect to ActiveMQ (max {}s) ===", STARTUP_TIMEOUT.toSeconds());
+ DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) registry
+ .getListenerContainer("eventStoreListener");
+ await().atMost(STARTUP_TIMEOUT).pollInterval(Duration.ofMillis(200)).until(container::isRunning);
+ log.info("=== JMS Listener is running - tests can proceed ===");
+ }
+ }
+
+ @Before(order = 1)
public void emptyEventStore() {
eventStore.reset();
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java
index c2e588a4fb..ef494a4b0e 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java
@@ -18,25 +18,23 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import io.cucumber.java.en.When;
-import java.io.IOException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ChargeRequest;
-import org.apache.fineract.client.models.PutChargesChargeIdResponse;
-import org.apache.fineract.client.services.ChargesApi;
import org.apache.fineract.test.data.ChargeCalculationType;
import org.apache.fineract.test.data.ChargeProductType;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class ChargeStepDef extends AbstractStepDef {
@Autowired
- private ChargesApi chargesApi;
+ private FineractFeignClient fineractClient;
@When("Admin updates charge {string} with {string} calculation type and {double} % of transaction amount")
- public void updateCharge(String chargeType, String chargeCalculationType, double amount) throws IOException {
+ public void updateCharge(String chargeType, String chargeCalculationType, double amount) {
ChargeRequest disbursementChargeUpdateRequest = new ChargeRequest();
ChargeCalculationType chargeProductTypeValue = ChargeCalculationType.valueOf(chargeCalculationType);
disbursementChargeUpdateRequest.chargeCalculationType(chargeProductTypeValue.value).amount(amount).locale("en");
@@ -44,13 +42,11 @@ public class ChargeStepDef extends AbstractStepDef {
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeId = chargeProductType.getValue();
- Response<PutChargesChargeIdResponse> responseDisbursementCharge = chargesApi.updateCharge(chargeId, disbursementChargeUpdateRequest)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge);
+ ok(() -> fineractClient.charges().updateCharge(chargeId, disbursementChargeUpdateRequest));
}
@When("Admin updates charge {string} with {string} calculation type and {double} EUR amount")
- public void updateChargeWithFlatAmount(String chargeType, String chargeCalculationType, double flatAmount) throws IOException {
+ public void updateChargeWithFlatAmount(String chargeType, String chargeCalculationType, double flatAmount) {
ChargeRequest disbursementChargeUpdateRequest = new ChargeRequest();
ChargeCalculationType chargeProductTypeValue = ChargeCalculationType.valueOf(chargeCalculationType);
disbursementChargeUpdateRequest.chargeCalculationType(chargeProductTypeValue.value).amount(flatAmount).locale("en");
@@ -58,8 +54,6 @@ public class ChargeStepDef extends AbstractStepDef {
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeId = chargeProductType.getValue();
- Response<PutChargesChargeIdResponse> responseDisbursementCharge = chargesApi.updateCharge(chargeId, disbursementChargeUpdateRequest)
- .execute();
- ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge);
+ ok(() -> fineractClient.charges().updateCharge(chargeId, disbursementChargeUpdateRequest));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/InlineCOBStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/InlineCOBStepDef.java
index 31dd25a0ef..82f82e8a26 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/InlineCOBStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/InlineCOBStepDef.java
@@ -18,17 +18,16 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.InlineJobRequest;
-import org.apache.fineract.client.models.InlineJobResponse;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.ExternalEventConfigurationApi;
-import org.apache.fineract.client.services.InlineJobApi;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.messaging.EventAssertion;
import org.apache.fineract.test.messaging.event.assetexternalization.LoanAccountCustomSnapshotEvent;
import org.apache.fineract.test.messaging.event.loan.repayment.LoanRepaymentDueEvent;
@@ -36,52 +35,47 @@ import org.apache.fineract.test.messaging.event.loan.repayment.LoanRepaymentOver
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class InlineCOBStepDef extends AbstractStepDef {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd MMMM yyyy");
@Autowired
- private InlineJobApi inlineJobApi;
+ private FineractFeignClient fineractClient;
@Autowired
private EventAssertion eventAssertion;
- @Autowired
- ExternalEventConfigurationApi eventConfigurationApi;
-
@When("Admin runs inline COB job for Loan")
public void runInlineCOB() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
InlineJobRequest inlineJobRequest = new InlineJobRequest().addLoanIdsItem(loanId);
- Response<InlineJobResponse> inlineJobResponse = inlineJobApi.executeInlineJob("LOAN_COB", inlineJobRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(inlineJobResponse);
+ ok(() -> fineractClient.inlineJob().executeInlineJob("LOAN_COB", inlineJobRequest));
}
@Then("Loan Repayment Due Business Event is created")
public void checkLoanRepaymentDueBusinessEventCreated() {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
eventAssertion.assertEventRaised(LoanRepaymentDueEvent.class, loanId);
}
@Then("Loan Repayment Overdue Business Event is created")
public void checkLoanRepaymentOverdueBusinessEventCreated() {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
eventAssertion.assertEventRaised(LoanRepaymentOverdueEvent.class, loanId);
}
@Then("LoanAccountCustomSnapshotBusinessEvent is created with business date {string}")
public void checkLoanRepaymentDueBusinessEventCreatedWithBusinessDate(String expectedBusinessDate) {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
LocalDate expectedBusinessDateParsed = LocalDate.parse(expectedBusinessDate, FORMATTER);
eventAssertion.assertEvent(LoanAccountCustomSnapshotEvent.class, loanId).isRaisedOnBusinessDate(expectedBusinessDateParsed);
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCOBStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCOBStepDef.java
index 77db58d6f2..4dccbf69f0 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCOBStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCOBStepDef.java
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
import io.cucumber.java.en.Then;
@@ -25,41 +27,31 @@ import io.cucumber.java.en.When;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.LoanAccountLock;
import org.apache.fineract.client.models.LoanAccountLockResponseDTO;
import org.apache.fineract.client.models.OldestCOBProcessedLoanDTO;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.DefaultApi;
-import org.apache.fineract.client.services.LoanAccountLockApi;
-import org.apache.fineract.client.services.LoanCobCatchUpApi;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class LoanCOBStepDef extends AbstractStepDef {
@Autowired
- private LoanCobCatchUpApi loanCobCatchUpApi;
-
- @Autowired
- private LoanAccountLockApi loanAccountLockApi;
-
- @Autowired
- private DefaultApi defaultApi;
+ private FineractFeignClient fineractClient;
@Then("The cobProcessedDate of the oldest loan processed by COB is more than 1 day earlier than cobBusinessDate")
public void checkOldestCOBProcessed() throws IOException {
- Response<OldestCOBProcessedLoanDTO> response = loanCobCatchUpApi.getOldestCOBProcessedLoan().execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ OldestCOBProcessedLoanDTO response = ok(() -> fineractClient.loanCobCatchUp().getOldestCOBProcessedLoan());
- LocalDate cobDate = response.body().getCobBusinessDate();
+ LocalDate cobDate = response.getCobBusinessDate();
LocalDate cobDateMinusOne = cobDate.minusDays(1);
- LocalDate cobProcessedDate = response.body().getCobProcessedDate();
+ LocalDate cobProcessedDate = response.getCobProcessedDate();
log.debug("cobDateMinusOne: {}", cobDateMinusOne);
log.debug("cobProcessedDate: {}", cobProcessedDate);
@@ -69,23 +61,23 @@ public class LoanCOBStepDef extends AbstractStepDef {
@Then("There are no locked loan accounts")
public void listOfLockedLoansEmpty() throws IOException {
- Response<LoanAccountLockResponseDTO> response = loanAccountLockApi.retrieveLockedAccounts(0, 1000).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ LoanAccountLockResponseDTO response = ok(
+ () -> fineractClient.loanAccountLock().retrieveLockedAccounts(Map.<String, Object>of("page", 0, "size", 1000)));
- int size = response.body().getContent().size();
+ int size = response.getContent().size();
assertThat(size).as(ErrorMessageHelper.listOfLockedLoansNotEmpty(response)).isEqualTo(0);
log.debug("Size of List of the locked loans: {}", size);
}
@Then("The loan account is not locked")
public void loanIsNotInListOfLockedLoans() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- Long targetLoanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ Long targetLoanId = loanResponse.getLoanId();
- Response<LoanAccountLockResponseDTO> response = loanAccountLockApi.retrieveLockedAccounts(0, 1000).execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ LoanAccountLockResponseDTO response = ok(
+ () -> fineractClient.loanAccountLock().retrieveLockedAccounts(Map.<String, Object>of("page", 0, "size", 1000)));
- List<LoanAccountLock> content = response.body().getContent();
+ List<LoanAccountLock> content = response.getContent();
boolean contains = content.stream()//
.map(LoanAccountLock::getLoanId)//
.anyMatch(targetLoanId::equals);//
@@ -95,19 +87,17 @@ public class LoanCOBStepDef extends AbstractStepDef {
@When("Admin places a lock on loan account with an error message")
public void placeLockOnLoanAccountWithErrorMessage() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<Void> response = defaultApi.placeLockOnLoanAccount(loanId, "LOAN_COB_CHUNK_PROCESSING", "TestError").execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ executeVoid(() -> fineractClient.defaultApi().placeLockOnLoanAccount(loanId, "LOAN_COB_CHUNK_PROCESSING", "TestError"));
}
@When("Admin places a lock on loan account WITHOUT an error message")
public void placeLockOnLoanAccountNoErrorMessage() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<Void> response = defaultApi.placeLockOnLoanAccount(loanId, "LOAN_COB_CHUNK_PROCESSING").execute();
- ErrorHelper.checkSuccessfulApiCall(response);
+ executeVoid(() -> fineractClient.defaultApi().placeLockOnLoanAccount(loanId, "LOAN_COB_CHUNK_PROCESSING", ""));
}
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCapitalizedIncomeStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCapitalizedIncomeStepDef.java
index 86b5719727..5be9091993 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCapitalizedIncomeStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanCapitalizedIncomeStepDef.java
@@ -18,22 +18,27 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
-import java.io.IOException;
+import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.List;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.CapitalizedIncomeDetails;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.test.helper.ErrorHelper;
+import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.messaging.EventAssertion;
import org.apache.fineract.test.messaging.event.loan.transaction.LoanCapitalizedIncomeAmortizationTransactionCreatedEvent;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class LoanCapitalizedIncomeStepDef extends AbstractStepDef {
@@ -42,20 +47,20 @@ public class LoanCapitalizedIncomeStepDef extends AbstractStepDef {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
@Autowired
- LoansApi loansApi;
+ FineractFeignClient fineractClient;
@Autowired
EventAssertion eventAssertion;
@Then("Loan Capitalized Income Amortization Transaction Created Business Event is created on {string}")
- public void checkLoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEventCreated(String date) throws IOException {
- Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanCreateResponse.body().getLoanId();
+ public void checkLoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEventCreated(String date) {
+ PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanCreateResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ GetLoansLoanIdResponse loanDetailsResponse = ok(
+ () -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "transactions")));
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
GetLoansLoanIdTransactions capitalizedIncomeAmortizationTransaction = transactions.stream()
.filter(t -> date.equals(FORMATTER.format(t.getDate())) && "Capitalized Income Amortization".equals(t.getType().getValue()))
.reduce((first, second) -> second).orElseThrow(
@@ -66,4 +71,90 @@ public class LoanCapitalizedIncomeStepDef extends AbstractStepDef {
capitalizedIncomeAmortizationTransactionId);
}
+ @Then("Deferred Capitalized Income contains the following data:")
+ public void verifyDeferredCapitalizedIncome(DataTable dataTable) {
+ PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanCreateResponse.getLoanId();
+
+ List<CapitalizedIncomeDetails> capitalizedIncomeDetails = ok(
+ () -> fineractClient.loanCapitalizedIncome().fetchCapitalizedIncomeDetails(loanId));
+
+ List<Map<String, String>> data = dataTable.asMaps();
+ Map<String, String> expectedData = data.get(0);
+
+ assertThat(capitalizedIncomeDetails).isNotNull().isNotEmpty();
+ CapitalizedIncomeDetails actualData = capitalizedIncomeDetails.get(0);
+
+ BigDecimal expectedAmount = new BigDecimal(expectedData.get("Amount"));
+ BigDecimal expectedAmortizedAmount = new BigDecimal(expectedData.get("Amortized Amount"));
+ BigDecimal expectedUnrecognizedAmount = new BigDecimal(expectedData.get("Unrecognized Amount"));
+ BigDecimal expectedAdjustedAmount = new BigDecimal(expectedData.get("Adjusted Amount"));
+ BigDecimal expectedChargedOffAmount = new BigDecimal(expectedData.get("Charged Off Amount"));
+
+ BigDecimal actualAmount = actualData.getAmount() != null ? actualData.getAmount() : BigDecimal.ZERO;
+ BigDecimal actualAmortizedAmount = actualData.getAmortizedAmount() != null ? actualData.getAmortizedAmount() : BigDecimal.ZERO;
+ BigDecimal actualUnrecognizedAmount = actualData.getUnrecognizedAmount() != null ? actualData.getUnrecognizedAmount()
+ : BigDecimal.ZERO;
+ BigDecimal actualAdjustedAmount = actualData.getAmountAdjustment() != null ? actualData.getAmountAdjustment() : BigDecimal.ZERO;
+ BigDecimal actualChargedOffAmount = actualData.getChargedOffAmount() != null ? actualData.getChargedOffAmount() : BigDecimal.ZERO;
+
+ assertThat(actualAmount).as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAmount, expectedAmount))
+ .isEqualByComparingTo(expectedAmount);
+ assertThat(actualAmortizedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAmortizedAmount, expectedAmortizedAmount))
+ .isEqualByComparingTo(expectedAmortizedAmount);
+ assertThat(actualUnrecognizedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualUnrecognizedAmount, expectedUnrecognizedAmount))
+ .isEqualByComparingTo(expectedUnrecognizedAmount);
+ assertThat(actualAdjustedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAdjustedAmount, expectedAdjustedAmount))
+ .isEqualByComparingTo(expectedAdjustedAmount);
+ assertThat(actualChargedOffAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualChargedOffAmount, expectedChargedOffAmount))
+ .isEqualByComparingTo(expectedChargedOffAmount);
+ }
+
+ @Then("Deferred Capitalized Income by external-id contains the following data:")
+ public void verifyDeferredCapitalizedIncomeByExternalId(DataTable dataTable) {
+ PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ String loanExternalId = loanCreateResponse.getResourceExternalId();
+
+ List<CapitalizedIncomeDetails> capitalizedIncomeDetails = ok(
+ () -> fineractClient.loanCapitalizedIncome().fetchCapitalizedIncomeDetailsByExternalId(loanExternalId));
+
+ List<Map<String, String>> data = dataTable.asMaps();
+ Map<String, String> expectedData = data.get(0);
+
+ assertThat(capitalizedIncomeDetails).isNotNull().isNotEmpty();
+ CapitalizedIncomeDetails actualData = capitalizedIncomeDetails.get(0);
+
+ BigDecimal expectedAmount = new BigDecimal(expectedData.get("Amount"));
+ BigDecimal expectedAmortizedAmount = new BigDecimal(expectedData.get("Amortized Amount"));
+ BigDecimal expectedUnrecognizedAmount = new BigDecimal(expectedData.get("Unrecognized Amount"));
+ BigDecimal expectedAdjustedAmount = new BigDecimal(expectedData.get("Adjusted Amount"));
+ BigDecimal expectedChargedOffAmount = new BigDecimal(expectedData.get("Charged Off Amount"));
+
+ BigDecimal actualAmount = actualData.getAmount() != null ? actualData.getAmount() : BigDecimal.ZERO;
+ BigDecimal actualAmortizedAmount = actualData.getAmortizedAmount() != null ? actualData.getAmortizedAmount() : BigDecimal.ZERO;
+ BigDecimal actualUnrecognizedAmount = actualData.getUnrecognizedAmount() != null ? actualData.getUnrecognizedAmount()
+ : BigDecimal.ZERO;
+ BigDecimal actualAdjustedAmount = actualData.getAmountAdjustment() != null ? actualData.getAmountAdjustment() : BigDecimal.ZERO;
+ BigDecimal actualChargedOffAmount = actualData.getChargedOffAmount() != null ? actualData.getChargedOffAmount() : BigDecimal.ZERO;
+
+ assertThat(actualAmount).as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAmount, expectedAmount))
+ .isEqualByComparingTo(expectedAmount);
+ assertThat(actualAmortizedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAmortizedAmount, expectedAmortizedAmount))
+ .isEqualByComparingTo(expectedAmortizedAmount);
+ assertThat(actualUnrecognizedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualUnrecognizedAmount, expectedUnrecognizedAmount))
+ .isEqualByComparingTo(expectedUnrecognizedAmount);
+ assertThat(actualAdjustedAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualAdjustedAmount, expectedAdjustedAmount))
+ .isEqualByComparingTo(expectedAdjustedAmount);
+ assertThat(actualChargedOffAmount)
+ .as(ErrorMessageHelper.wrongAmountInDeferredCapitalizedIncome(actualChargedOffAmount, expectedChargedOffAmount))
+ .isEqualByComparingTo(expectedChargedOffAmount);
+ }
+
}
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeAdjustmentStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeAdjustmentStepDef.java
index 652a6c4ff3..6d5d4035f0 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeAdjustmentStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeAdjustmentStepDef.java
@@ -18,9 +18,9 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.io.IOException;
@@ -28,24 +28,20 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FeignException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.BusinessDateResponse;
import org.apache.fineract.client.models.GetLoansLoanIdLoanChargeData;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdRequest;
import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdResponse;
-import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.BusinessDateManagementApi;
-import org.apache.fineract.client.services.LoanChargesApi;
-import org.apache.fineract.client.services.LoanTransactionsApi;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.factory.LoanRequestFactory;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.messaging.event.EventCheckHelper;
@@ -53,23 +49,15 @@ import org.apache.fineract.test.messaging.store.EventStore;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class LoanChargeAdjustmentStepDef extends AbstractStepDef {
public static final String DATE_FORMAT = "dd MMMM yyyy";
- private static final Gson GSON = new JSON().getGson();
-
- @Autowired
- private LoanChargesApi loanChargesApi;
- @Autowired
- private LoansApi loansApi;
@Autowired
- private LoanTransactionsApi loanTransactionsApi;
- @Autowired
- private BusinessDateManagementApi businessDateManagementApi;
+ private FineractFeignClient fineractClient;
+
@Autowired
private EventCheckHelper eventCheckHelper;
@Autowired
@@ -78,11 +66,11 @@ public class LoanChargeAdjustmentStepDef extends AbstractStepDef {
@When("Admin makes a charge adjustment for the last {string} type charge which is due on {string} with {double} EUR transaction amount and externalId {string}")
public void makeLoanChargeAdjustment(String chargeTypeEnum, String date, Double transactionAmount, String externalId)
throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "charges", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ GetLoansLoanIdResponse loanDetailsResponse = ok(
+ () -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "charges")));
Long transactionId = getTransactionIdForLastChargeMetConditions(chargeTypeEnum, date, loanDetailsResponse);
makeChargeAdjustmentCall(loanId, transactionId, externalId, transactionAmount);
@@ -90,71 +78,72 @@ public class LoanChargeAdjustmentStepDef extends AbstractStepDef {
@Then("Charge adjustment for the last {string} type charge which is due on {string} with transaction amount {double} which is higher than the available charge amount results an ERROR")
public void loanChargeAdjustmentFailedOnWrongAmount(String chargeTypeEnum, String date, double amount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "charges", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ GetLoansLoanIdResponse loanDetailsResponse = ok(
+ () -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "charges")));
Long transactionId = getTransactionIdForLastChargeMetConditions(chargeTypeEnum, date, loanDetailsResponse);
PostLoansLoanIdChargesChargeIdRequest chargeAdjustmentRequest = LoanRequestFactory.defaultChargeAdjustmentRequest().amount(amount)
.externalId("");
- Response<PostLoansLoanIdChargesChargeIdResponse> chargeAdjustmentResponseFail = loanChargesApi
- .executeLoanCharge2(loanId, transactionId, chargeAdjustmentRequest, "adjustment").execute();
-
- String string = chargeAdjustmentResponseFail.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(string, ErrorResponse.class);
- Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
- String developerMessageActual = errorResponse.getErrors().get(0).getDeveloperMessage();
-
Integer httpStatusCodeExpected = 403;
String developerMessageExpected = "Transaction amount cannot be higher than the available charge amount for adjustment: 7.000000";
- assertThat(httpStatusCodeActual)
- .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
- .isEqualTo(httpStatusCodeExpected);
- assertThat(developerMessageActual)
- .as(ErrorMessageHelper.wrongErrorMessageInFailedChargeAdjustment(developerMessageActual, developerMessageExpected))
- .isEqualTo(developerMessageExpected);
-
- log.debug("Error code: {}", httpStatusCodeActual);
- log.debug("Error message: {}", developerMessageActual);
+ try {
+ fineractClient.loanCharges().executeLoanCharge2(loanId, transactionId, chargeAdjustmentRequest,
+ Map.<String, Object>of("command", "adjustment"));
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ ErrorResponse errorResponse = ErrorResponse.fromFeignException(e);
+ Integer httpStatusCodeActual = errorResponse.getHttpStatusCode();
+ String developerMessageActual = errorResponse.getErrors().get(0).getDeveloperMessage();
+
+ assertThat(httpStatusCodeActual)
+ .as(ErrorMessageHelper.wrongErrorCodeInFailedChargeAdjustment(httpStatusCodeActual, httpStatusCodeExpected))
+ .isEqualTo(httpStatusCodeExpected);
+ assertThat(developerMessageActual)
+ .as(ErrorMessageHelper.wrongErrorMessageInFailedChargeAdjustment(developerMessageActual, developerMessageExpected))
+ .isEqualTo(developerMessageExpected);
+
+ log.debug("Error code: {}", httpStatusCodeActual);
+ log.debug("Error message: {}", developerMessageActual);
+ }
}
@When("Admin reverts the charge adjustment which was raised on {string} with {double} EUR transaction amount")
public void loanChargeAdjustmentUndo(String transactionDate, double transactionAmount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+ GetLoansLoanIdResponse loanDetailsResponse = ok(
+ () -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "transactions")));
Long transactionId = getTransactionIdForTransactionMetConditions(transactionDate, transactionAmount, loanDetailsResponse);
- Response<List<BusinessDateResponse>> businessDateResponse = businessDateManagementApi.getBusinessDates().execute();
- LocalDate businessDate = businessDateResponse.body().get(0).getDate();
+ BusinessDateResponse businessDateResponse = ok(
+ () -> fineractClient.businessDateManagement().getBusinessDate("BUSINESS_DATE", Map.of()));
+ LocalDate businessDate = businessDateResponse.getDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
String businessDateActual = formatter.format(businessDate);
PostLoansLoanIdTransactionsTransactionIdRequest chargeAdjustmentUndoRequest = LoanRequestFactory
.defaultChargeAdjustmentTransactionUndoRequest().transactionDate(businessDateActual);
- Response<PostLoansLoanIdTransactionsResponse> chargeAdjustmentUndoResponse = loanTransactionsApi
- .adjustLoanTransaction(loanId, transactionId, chargeAdjustmentUndoRequest, "").execute();
- ErrorHelper.checkSuccessfulApiCall(chargeAdjustmentUndoResponse);
+ ok(() -> fineractClient.loanTransactions().adjustLoanTransaction(loanId, transactionId, chargeAdjustmentUndoRequest,
+ Map.<String, Object>of()));
}
@Then("Charge adjustment response has the subResourceExternalId")
public void checkChargeAdjustmentResponse() {
- final Response<PostLoansLoanIdChargesChargeIdResponse> response = testContext().get(TestContextKey.LOAN_CHARGE_ADJUSTMENT_RESPONSE);
- final PostLoansLoanIdChargesChargeIdResponse body = response.body();
- assertThat(body.getSubResourceExternalId()).isNotNull();
+ final PostLoansLoanIdChargesChargeIdResponse response = testContext().get(TestContextKey.LOAN_CHARGE_ADJUSTMENT_RESPONSE);
+ assertThat(response.getSubResourceExternalId()).isNotNull();
}
private Long getTransactionIdForTransactionMetConditions(String transactionDate, double transactionAmount,
- Response<GetLoansLoanIdResponse> loanDetailsResponse) {
- List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
+ GetLoansLoanIdResponse loanDetailsResponse) {
+ List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
GetLoansLoanIdTransactions transactionMetConditions = new GetLoansLoanIdTransactions();
for (int i = 0; i < transactions.size(); i++) {
LocalDate date = transactions.get(i).getDate();
@@ -176,16 +165,15 @@ public class LoanChargeAdjustmentStepDef extends AbstractStepDef {
PostLoansLoanIdChargesChargeIdRequest chargeAdjustmentRequest = LoanRequestFactory.defaultChargeAdjustmentRequest()
.amount(transactionAmount).externalId(externalId);
- Response<PostLoansLoanIdChargesChargeIdResponse> chargeAdjustmentResponse = loanChargesApi
- .executeLoanCharge2(loanId, transactionId, chargeAdjustmentRequest, "adjustment").execute();
+ PostLoansLoanIdChargesChargeIdResponse chargeAdjustmentResponse = ok(() -> fineractClient.loanCharges().executeLoanCharge2(loanId,
+ transactionId, chargeAdjustmentRequest, Map.<String, Object>of("command", "adjustment")));
testContext().set(TestContextKey.LOAN_CHARGE_ADJUSTMENT_RESPONSE, chargeAdjustmentResponse);
- ErrorHelper.checkSuccessfulApiCall(chargeAdjustmentResponse);
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}
private Long getTransactionIdForLastChargeMetConditions(String chargeTypeEnum, String date,
- Response<GetLoansLoanIdResponse> loanDetailsResponse) {
- List<GetLoansLoanIdLoanChargeData> charges = loanDetailsResponse.body().getCharges();
+ GetLoansLoanIdResponse loanDetailsResponse) {
+ List<GetLoansLoanIdLoanChargeData> charges = loanDetailsResponse.getCharges();
ChargeProductType chargeType = ChargeProductType.valueOf(chargeTypeEnum);
Long chargeProductId = chargeType.getValue();
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeBackStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeBackStepDef.java
index a601e3fff3..a036d275c6 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeBackStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeBackStepDef.java
@@ -18,14 +18,18 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
import io.cucumber.java.en.When;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
import org.apache.fineract.avro.loan.v1.LoanTransactionEnumDataV1;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse;
@@ -33,12 +37,9 @@ import org.apache.fineract.client.models.GetLoansType;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest;
import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.services.LoanTransactionsApi;
-import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.test.data.paymenttype.DefaultPaymentType;
import org.apache.fineract.test.data.paymenttype.PaymentTypeResolver;
import org.apache.fineract.test.factory.LoanRequestFactory;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.messaging.EventAssertion;
import org.apache.fineract.test.messaging.event.EventCheckHelper;
import org.apache.fineract.test.messaging.event.loan.transaction.LoanChargebackTransactionEvent;
@@ -46,15 +47,11 @@ import org.apache.fineract.test.messaging.store.EventStore;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
public class LoanChargeBackStepDef extends AbstractStepDef {
@Autowired
- private LoanTransactionsApi loanTransactionsApi;
-
- @Autowired
- private LoansApi loansApi;
+ private FineractFeignClient fineractClient;
@Autowired
private EventAssertion eventAssertion;
@@ -70,22 +67,22 @@ public class LoanChargeBackStepDef extends AbstractStepDef {
@When("Admin makes {string} chargeback with {double} EUR transaction amount")
public void makeLoanChargeback(String repaymentType, double transactionAmount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostLoansLoanIdTransactionsResponse> repaymentResponse = testContext().get(TestContextKey.LOAN_REPAYMENT_RESPONSE);
- Long transactionId = Long.valueOf(repaymentResponse.body().getResourceId());
+ PostLoansLoanIdTransactionsResponse repaymentResponse = testContext().get(TestContextKey.LOAN_REPAYMENT_RESPONSE);
+ Long transactionId = Long.valueOf(repaymentResponse.getResourceId());
makeChargebackCall(loanId, transactionId, repaymentType, transactionAmount);
}
@When("Admin makes {string} chargeback with {double} EUR transaction amount for Payment nr. {double}")
public void makeLoanChargebackForPayment(String repaymentType, double transactionAmount, double paymentNr) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- List<GetLoansLoanIdTransactions> transactions = loanDetails.body().getTransactions();
+ GetLoansLoanIdResponse loanDetails = ok(() -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "transactions")));
+ List<GetLoansLoanIdTransactions> transactions = loanDetails.getTransactions();
List<Long> transactionIdList = new ArrayList<>();
for (GetLoansLoanIdTransactions f : transactions) {
@@ -103,11 +100,11 @@ public class LoanChargeBackStepDef extends AbstractStepDef {
@When("Admin makes {string} chargeback with {double} EUR transaction amount for Downpayment nr. {double}")
public void makeLoanChargebackForDownpaymentayment(String repaymentType, double transactionAmount, double paymentNr)
throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- List<GetLoansLoanIdTransactions> transactions = loanDetails.body().getTransactions();
+ GetLoansLoanIdResponse loanDetails = ok(() -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "transactions")));
+ List<GetLoansLoanIdTransactions> transactions = loanDetails.getTransactions();
List<Long> transactionIdList = new ArrayList<>();
for (GetLoansLoanIdTransactions f : transactions) {
@@ -124,11 +121,11 @@ public class LoanChargeBackStepDef extends AbstractStepDef {
@When("Admin makes {string} chargeback with {double} EUR transaction amount for MIR nr. {double}")
public void makeLoanChargebackForMIR(String repaymentType, double transactionAmount, double paymentNr) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- List<GetLoansLoanIdTransactions> transactions = loanDetails.body().getTransactions();
+ GetLoansLoanIdResponse loanDetails = ok(() -> fineractClient.loans().retrieveLoan(loanId, Map.of("associations", "transactions")));
+ List<GetLoansLoanIdTransactions> transactions = loanDetails.getTransactions();
List<Long> transactionIdList = new ArrayList<>();
for (GetLoansLoanIdTransactions f : transactions) {
@@ -151,16 +148,14 @@ public class LoanChargeBackStepDef extends AbstractStepDef {
PostLoansLoanIdTransactionsTransactionIdRequest chargebackRequest = LoanRequestFactory.defaultChargebackRequest()
.paymentTypeId(paymentTypeValue).transactionAmount(transactionAmount);
- Response<PostLoansLoanIdTransactionsResponse> chargebackResponse = loanTransactionsApi
- .adjustLoanTransaction(loanId, transactionId, chargebackRequest, "chargeback").execute();
+ PostLoansLoanIdTransactionsResponse chargebackResponse = ok(() -> fineractClient.loanTransactions().adjustLoanTransaction(loanId,
+ transactionId, chargebackRequest, Map.of("command", "chargeback")));
testContext().set(TestContextKey.LOAN_CHARGEBACK_RESPONSE, chargebackResponse);
- ErrorHelper.checkSuccessfulApiCall(chargebackResponse);
-
checkEvents(chargebackResponse);
}
- private void checkEvents(Response<PostLoansLoanIdTransactionsResponse> chargebackResponse) throws IOException {
- PostLoansLoanIdTransactionsResponse responseBody = chargebackResponse.body();
+ private void checkEvents(PostLoansLoanIdTransactionsResponse chargebackResponse) throws IOException {
+ PostLoansLoanIdTransactionsResponse responseBody = chargebackResponse;
Long loanId = responseBody.getLoanId();
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
@@ -174,11 +169,8 @@ public class LoanChargeBackStepDef extends AbstractStepDef {
long transactionId = Long.valueOf(chargebackResponse.getResourceId());
// retrieve transaction details
- Response<GetLoansLoanIdTransactionsTransactionIdResponse> transactionResponse = loanTransactionsApi
- .retrieveTransaction(loanId, transactionId, "").execute();
- ErrorHelper.checkSuccessfulApiCall(transactionResponse);
-
- GetLoansLoanIdTransactionsTransactionIdResponse transactionResponseBody = transactionResponse.body();
+ GetLoansLoanIdTransactionsTransactionIdResponse transactionResponseBody = ok(
+ () -> fineractClient.loanTransactions().retrieveTransaction(loanId, transactionId, Map.of()));
// Get transaction type from response
GetLoansType transactionType = transactionResponseBody.getType();
diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeStepDef.java
index 5442cc449e..0cf4a19e87 100644
--- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeStepDef.java
+++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanChargeStepDef.java
@@ -18,9 +18,9 @@
*/
package org.apache.fineract.test.stepdef.loan;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.assertj.core.api.Assertions.assertThat;
-import com.google.gson.Gson;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
@@ -29,8 +29,11 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.List;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.avro.loan.v1.LoanChargeDataV1;
+import org.apache.fineract.client.feign.FeignException;
+import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetLoansLoanIdChargesChargeIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
@@ -41,14 +44,9 @@ import org.apache.fineract.client.models.PostLoansLoanIdChargesResponse;
import org.apache.fineract.client.models.PostLoansResponse;
import org.apache.fineract.client.models.PutChargeTransactionChangesRequest;
import org.apache.fineract.client.models.PutChargeTransactionChangesResponse;
-import org.apache.fineract.client.services.LoanChargesApi;
-import org.apache.fineract.client.services.LoanTransactionsApi;
-import org.apache.fineract.client.services.LoansApi;
-import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.data.ErrorMessageType;
import org.apache.fineract.test.factory.LoanChargeRequestFactory;
-import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.ErrorResponse;
import org.apache.fineract.test.messaging.EventAssertion;
@@ -58,7 +56,6 @@ import org.apache.fineract.test.messaging.store.EventStore;
import org.apache.fineract.test.stepdef.AbstractStepDef;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.beans.factory.annotation.Autowired;
-import retrofit2.Response;
@Slf4j
public class LoanChargeStepDef extends AbstractStepDef {
@@ -66,14 +63,10 @@ public class LoanChargeStepDef extends AbstractStepDef {
public static final String DEFAULT_DATE_FORMAT = "dd MMMM yyyy";
public static final String DATE_FORMAT_EVENTS = "yyyy-MM-dd";
public static final Double DEFAULT_CHARGE_FEE_FLAT = 10D;
- private static final Gson GSON = new JSON().getGson();
@Autowired
- private LoanChargesApi loanChargesApi;
- @Autowired
- private LoanTransactionsApi loanTransactionsApi;
- @Autowired
- private LoansApi loansApi;
+ private FineractFeignClient fineractClient;
+
@Autowired
private EventAssertion eventAssertion;
@Autowired
@@ -83,8 +76,8 @@ public class LoanChargeStepDef extends AbstractStepDef {
@When("Admin adds {string} due date charge with {string} due date and {double} EUR transaction amount")
public void addChargeDueDate(String chargeType, String transactionDate, double transactionAmount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeTypeId = chargeProductType.getValue();
@@ -97,9 +90,8 @@ public class LoanChargeStepDef extends AbstractStepDef {
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest().chargeId(chargeTypeId)
.dueDate(transactionDate).amount(transactionAmount);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- ErrorHelper.checkSuccessfulApiCall(loanChargeResponse);
+ PostLoansLoanIdChargesResponse loanChargeResponse = ok(
+ () -> fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of()));
testContext().set(TestContextKey.ADD_DUE_DATE_CHARGE_RESPONSE, loanChargeResponse);
testContext().set(TestContextKey.ADD_NSF_FEE_RESPONSE, loanChargeResponse);
@@ -108,8 +100,8 @@ public class LoanChargeStepDef extends AbstractStepDef {
@When("Admin adds {string} charge with {double} % of transaction amount")
public void addChargePercentage(String chargeType, double transactionPercentageAmount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeTypeId = chargeProductType.getValue();
@@ -123,17 +115,16 @@ public class LoanChargeStepDef extends AbstractStepDef {
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest().chargeId(chargeTypeId)
.amount(transactionPercentageAmount);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- ErrorHelper.checkSuccessfulApiCall(loanChargeResponse);
+ PostLoansLoanIdChargesResponse loanChargeResponse = ok(
+ () -> fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of()));
testContext().set(TestContextKey.ADD_DUE_DATE_CHARGE_RESPONSE, loanChargeResponse);
}
@When("Admin adds {string} installment charge with {double} amount")
public void addInstallmentFeeCharge(final String chargeType, final double amount) throws IOException {
- final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- assert loanResponse.body() != null;
- final long loanId = loanResponse.body().getLoanId();
+ final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ assert loanResponse != null;
+ final long loanId = loanResponse.getLoanId();
final ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
final Long chargeTypeId = chargeProductType.getValue();
@@ -148,39 +139,40 @@ public class LoanChargeStepDef extends AbstractStepDef {
final PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest()
.chargeId(chargeTypeId).amount(amount);
- final Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi
- .executeLoanCharge(loanId, loanIdChargesRequest, "").execute();
- ErrorHelper.checkSuccessfulApiCall(loanChargeResponse);
+ final PostLoansLoanIdChargesResponse loanChargeResponse = ok(
+ () -> fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of()));
testContext().set(TestContextKey.ADD_INSTALLMENT_FEE_CHARGE_RESPONSE, loanChargeResponse);
}
@Then("Admin fails to add {string} installment charge with {double} amount because of wrong charge calculation type")
public void addInstallmentFeeChargeFails(final String chargeType, final double amount) throws IOException {
- final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- assert loanResponse.body() != null;
+ final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ assert loanResponse != null;
- final long loanId = loanResponse.body().getLoanId();
+ final long loanId = loanResponse.getLoanId();
final ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
final Long chargeTypeId = chargeProductType.getValue();
final PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest()
.chargeId(chargeTypeId).amount(amount);
- final Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi
- .executeLoanCharge(loanId, loanIdChargesRequest, "").execute();
- testContext().set(TestContextKey.ADD_INSTALLMENT_FEE_CHARGE_RESPONSE, loanChargeResponse);
- final ErrorResponse errorDetails = ErrorResponse.from(loanChargeResponse);
- assertThat(errorDetails.getHttpStatusCode()).isEqualTo(400);
- assertThat(errorDetails.getSingleError().getDeveloperMessage())
- .isEqualTo(chargeProductType.equals(ChargeProductType.LOAN_INSTALLMENT_FEE_PERCENTAGE_INTEREST)
- ? ErrorMessageHelper.addInstallmentFeeInterestPercentageChargeFailure()
- : ErrorMessageHelper.addInstallmentFeePrincipalPercentageChargeFailure());
+ try {
+ fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of());
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ final ErrorResponse errorDetails = ErrorResponse.fromFeignException(e);
+ assertThat(errorDetails.getHttpStatusCode()).isEqualTo(400);
+ String expectedMessage = chargeTypeId.equals(ChargeProductType.LOAN_INSTALLMENT_FEE_PERCENTAGE_INTEREST.getValue())
+ ? ErrorMessageHelper.addInstallmentFeeInterestPercentageChargeFailure()
+ : ErrorMessageHelper.addInstallmentFeePrincipalPercentageChargeFailure();
+ assertThat(errorDetails.getSingleError().getDeveloperMessage()).contains(expectedMessage);
+ }
}
@Then("Admin is not able to add {string} due date charge with {string} due date and {double} EUR transaction amount because the of charged-off account")
public void addChargeDueDateOnChargedOff(String chargeType, String transactionDate, double transactionAmount) throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeTypeId = chargeProductType.getValue();
@@ -188,27 +180,28 @@ public class LoanChargeStepDef extends AbstractStepDef {
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest().chargeId(chargeTypeId)
.dueDate(transactionDate).amount(transactionAmount);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- testContext().set(TestContextKey.ADD_DUE_DATE_CHARGE_RESPONSE, loanChargeResponse);
- ErrorResponse errorDetails = ErrorResponse.from(loanChargeResponse);
- assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addChargeForChargeOffLoanCodeMsg()).isEqualTo(403);
- assertThat(errorDetails.getSingleError().getDeveloperMessage())
- .isEqualTo(ErrorMessageHelper.addChargeForChargeOffLoanFailure(loanId));
+ try {
+ fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of());
+ throw new AssertionError("Expected FeignException but request succeeded");
+ } catch (FeignException e) {
+ ErrorResponse errorDetails = ErrorResponse.fromFeignException(e);
+ assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addChargeForChargeOffLoanCodeMsg()).isEqualTo(403);
+ assertThat(errorDetails.getSingleError().getDeveloperMessage())
+ .contains(ErrorMessageHelper.addChargeForChargeOffLoanFailure(loanId));
+ }
}
@And("Admin adds a {double} % Processing charge to the loan with {string} locale on date: {string}")
public void addProcessingFee(double chargeAmount, String locale, String date) throws IOException {
eventStore.reset();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest()
.chargeId(ChargeProductType.LOAN_PERCENTAGE_PROCESSING_FEE.value).amount(chargeAmount).dueDate(date)
.dateFormat(DEFAULT_DATE_FORMAT).locale(locale);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- ErrorHelper.checkSuccessfulApiCall(loanChargeResponse);
+ PostLoansLoanIdChargesResponse loanChargeResponse = ok(
+ () -> fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of()));
testContext().set(TestContextKey.ADD_PROCESSING_FEE_RESPONSE, loanChargeResponse);
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}
@@ -216,102 +209,91 @@ public class LoanChargeStepDef extends AbstractStepDef {
@And("Admin adds an NSF fee because of payment bounce with {string} transaction date")
public void addNSFfee(String date) throws IOException {
eventStore.reset();
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest()
.chargeId(ChargeProductType.LOAN_NSF_FEE.value).amount(DEFAULT_CHARGE_FEE_FLAT).dueDate(date)
.dateFormat(DEFAULT_DATE_FORMAT);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- ErrorHelper.checkSuccessfulApiCall(loanChargeResponse);
+ PostLoansLoanIdChargesResponse loanChargeResponse = ok(
+ () -> fineractClient.loanCharges().executeLoanCharge(loanId, loanIdChargesRequest, Map.<String, Object>of()));
testContext().set(TestContextKey.ADD_NSF_FEE_RESPONSE, loanChargeResponse);
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}
@And("Admin waives charge")
public void waiveCharge() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = testContext().get(TestContextKey.ADD_NSF_FEE_RESPONSE);
- Long chargeId = Long.valueOf(loanChargeResponse.body().getResourceId());
+ PostLoansLoanIdChargesResponse loanChargeResponse = testContext().get(TestContextKey.ADD_NSF_FEE_RESPONSE);
+ Long chargeId = Long.valueOf(loanChargeResponse.getResourceId());
PostLoansLoanIdChargesChargeIdRequest waiveRequest = new PostLoansLoanIdChargesChargeIdRequest();
- Response<PostLoansLoanIdChargesChargeIdResponse> waiveResponse = loanChargesApi
- .executeLoanCharge2(loanId, chargeId, waiveRequest, "waive").execute();
- ErrorHelper.checkSuccessfulApiCall(waiveResponse);
+ PostLoansLoanIdChargesChargeIdResponse waiveResponse = ok(() -> fineractClient.loanCharges().executeLoanCharge2(loanId, chargeId,
+ waiveRequest, Map.<String, Object>of("command", "waive")));
testContext().set(TestContextKey.WAIVE_CHARGE_RESPONSE, waiveResponse);
}
@And("Admin waives due date charge")
public void waiveDueDateCharge() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = testContext().get(TestContextKey.ADD_DUE_DATE_CHARGE_RESPONSE);
- Long chargeId = Long.valueOf(loanChargeResponse.body().getResourceId());
+ PostLoansLoanIdChargesResponse loanChargeResponse = testContext().get(TestContextKey.ADD_DUE_DATE_CHARGE_RESPONSE);
+ Long chargeId = Long.valueOf(loanChargeResponse.getResourceId());
PostLoansLoanIdChargesChargeIdRequest waiveRequest = new PostLoansLoanIdChargesChargeIdRequest();
- Response<PostLoansLoanIdChargesChargeIdResponse> waiveResponse = loanChargesApi
- .executeLoanCharge2(loanId, chargeId, waiveRequest, "waive").execute();
- ErrorHelper.checkSuccessfulApiCall(waiveResponse);
+ PostLoansLoanIdChargesChargeIdResponse waiveResponse = ok(() -> fineractClient.loanCharges().executeLoanCharge2(loanId, chargeId,
+ waiveRequest, Map.<String, Object>of("command", "waive")));
testContext().set(TestContextKey.WAIVE_CHARGE_RESPONSE, waiveResponse);
}
@And("Admin makes waive undone for charge")
public void undoWaiveForCharge() throws IOException {
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
-
- Response<GetLoansLoanIdResponse> loanDetails = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
- List<GetLoansLoanIdTransactions> transactions = loanDetails.body().getTransactions();
-
- Long transactionId = 0L;
- for (GetLoansLoanIdTransactions f : transactions) {
- String code = f.getType().getCode();
- if (code.equals("loanTransactionType.waiveCharges")) {
- transactionId = f.getId();
- }
- }
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
+
+ GetLoansLoanIdResponse loanDetails = ok(
+ () -> fineractClient.loans().retrieveLoan(loanId, Map.<String, Object>of("associations", "transactions")));
+ List<GetLoansLoanIdTransactions> transactions = loanDetails.getTransactions();
+
+ final Long transactionId = transactions.stream().filter(t -> "loanTransactionType.waiveCharges".equals(t.getType().getCode()))
+ .findFirst().map(GetLoansLoanIdTransactions::getId).orElse(0L);
PutChargeTransactionChangesRequest undoWaiveRequest = new PutChargeTransactionChangesRequest();
- Response<PutChargeTransactionChangesResponse> undoWaiveResponse = loanTransactionsApi
- .undoWaiveCharge(loanId, transactionId, undoWaiveRequest).execute();
- ErrorHelper.checkSuccessfulApiCall(undoWaiveResponse);
+ PutChargeTransactionChangesResponse undoWaiveResponse = ok(
+ () -> fineractClient.loanTransactions().undoWaiveCharge(loanId, transactionId, undoWaiveRequest));
testContext().set(TestContextKey.UNDO_WAIVE_RESPONSE, undoWaiveResponse);
}
@Then("Charge is successfully added to the loan")
public void loanChargeStatus() throws IOException {
- Response<PostLoansLoanIdChargesResponse> response = testContext().get(TestContextKey.ADD_NSF_FEE_RESPONSE);
+ PostLoansLoanIdChargesResponse response = testContext().get(TestContextKey.ADD_NSF_FEE_RESPONSE);
- assertThat(response.isSuccessful()).as(ErrorMessageHelper.requestFailed(response)).isTrue();
- assertThat(response.code()).as(ErrorMessageHelper.requestFailedWithCode(response)).isEqualTo(200);
+ assertThat(response).as("Charge response should not be null").isNotNull();
+ assertThat(response.getResourceId()).as("Charge resource ID should be present").isNotNull();
}
@Then("Charge is successfully added to the loan with {float} EUR")
public void checkLoanChargeAmount(float chargeAmount) throws IOException {
- Response<PostLoansLoanIdChargesResponse> response = testContext().get(TestContextKey.ADD_PROCESSING_FEE_RESPONSE);
- Response<GetLoansLoanIdChargesChargeIdResponse> loanChargeAmount = loanChargesApi
- .retrieveLoanCharge(response.body().getLoanId(), Long.valueOf(response.body().getResourceId())).execute();
-
- ErrorHelper.checkSuccessfulApiCall(response);
- assertThat(loanChargeAmount.body().getAmount()).as("Charge amount is wrong").isEqualTo(chargeAmount);
+ PostLoansLoanIdChargesResponse response = testContext().get(TestContextKey.ADD_PROCESSING_FEE_RESPONSE);
+ GetLoansLoanIdChargesChargeIdResponse loanChargeAmount = ok(
+ () -> fineractClient.loanCharges().retrieveLoanCharge(response.getLoanId(), Long.valueOf(response.getResourceId())));
+ assertThat(loanChargeAmount.getAmount()).as("Charge amount is wrong").isEqualByComparingTo(Double.valueOf(chargeAmount));
}
- private void addChargeEventCheck(Response<PostLoansLoanIdChargesResponse> loanChargeResponse) throws IOException {
+ private void addChargeEventCheck(PostLoansLoanIdChargesResponse loanChargeResponse) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT_EVENTS);
- Response<GetLoansLoanIdChargesChargeIdResponse> chargeDetails = loanChargesApi
- .retrieveLoanCharge(loanChargeResponse.body().getLoanId(), loanChargeResponse.body().getResourceId()).execute();
- GetLoansLoanIdChargesChargeIdResponse body = chargeDetails.body();
-
- eventAssertion.assertEvent(LoanAddChargeEvent.class, loanChargeResponse.body().getResourceId())
- .extractingData(LoanChargeDataV1::getName).isEqualTo(body.getName()).extractingBigDecimal(LoanChargeDataV1::getAmount)
- .isEqualTo(BigDecimal.valueOf(body.getAmount())).extractingData(LoanChargeDataV1::getDueDate)
- .isEqualTo(formatter.format(body.getDueDate()));
+ GetLoansLoanIdChargesChargeIdResponse chargeDetails = ok(
+ () -> fineractClient.loanCharges().retrieveLoanCharge(loanChargeResponse.getLoanId(), loanChargeResponse.getResourceId()));
+ GetLoansLoanIdChargesChargeIdResponse body = chargeDetails;
+
+ eventAssertion.assertEvent(LoanAddChargeEvent.class, loanChargeResponse.getResourceId()).extractingData(LoanChargeDataV1::getName)
+ .isEqualTo(body.getName()).extractingBigDecimal(LoanChargeDataV1::getAmount).isEqualTo(BigDecimal.valueOf(body.getAmount()))
+ .extractingData(LoanChargeDataV1::getDueDate).isEqualTo(formatter.format(body.getDueDate()));
}
@Then("Loan charge transaction with the following data results a {int} error and {string} error message")
@@ -322,8 +304,8 @@ public class LoanChargeStepDef extends AbstractStepDef {
String transactionDate = chargeData.get(1);
Double transactionAmount = Double.valueOf(chargeData.get(2));
- Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
- long loanId = loanResponse.body().getLoanId();
+ PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+ long loanId = loanResponse.getLoanId();
ErrorMessageType errorMsgType = ErrorMessageType.valueOf(errorMessageType);
String errorMessageExpectedRaw = errorMsgType.getValue();
@@ -340,18 +322,21 @@ public class LoanChargeStepDef extends AbstractStepDef {
PostLoansLoanIdChargesRequest loanIdChargesRequest = LoanChargeRequestFactory.defaultLoanChargeRequest().chargeId(chargeTypeId)
.dueDate(transactionDate).amount(transactionAmount);
- Response<PostLoansLoanIdChargesResponse> loanChargeResponse = loanChargesApi.executeLoanCharge(loanId, loanIdChargesRequest, "")
- .execute();
- int errorCodeActual = loanChargeResponse.code();
- String errorBody = loanChargeResponse.errorBody().string();
- ErrorResponse errorResponse = GSON.fromJson(errorBody, ErrorResponse.class);
- String errorMessageActual = errorResponse.getErrors().get(0).getDeveloperMessage();
-
- assertThat(errorCodeActual).as(ErrorMessageHelper.wrongErrorCode(errorCodeActual, errorCodeExpected)).isEqualTo(errorCodeExpected);
- assertThat(errorMessageActual).as(ErrorMessageHelper.wrongErrorMessage(errorMessageActual, errorMessageExpected))
- .isEqualTo(errorMessageExpected);
-
- log.debug("ERROR CODE: {}", errorCodeActual);
... 8546 lines suppressed ...