Skip to content

Commit 10968d2

Browse files
committed
FINERACT-2494: Standardized Savings API operationIds and synchronized integration tests
1 parent a9b5f12 commit 10968d2

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public String template(@QueryParam("clientId") @Parameter(description = "clientI
122122
@Consumes({ MediaType.APPLICATION_JSON })
123123
@Produces({ MediaType.APPLICATION_JSON })
124124
@Operation(summary = "List savings applications/accounts", description = "Lists savings applications/accounts\n\n"
125-
+ "Example Requests:\n" + "\n" + "savingsaccounts\n" + "\n" + "\n" + "savingsaccounts?fields=name")
125+
+ "Example Requests:\n" + "\n" + "savingsaccounts\n" + "\n" + "\n"
126+
+ "savingsaccounts?fields=name", operationId = "retrieveAllSavings")
126127
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.GetSavingsAccountsResponse.class)))
127128
public String retrieveAll(@Context final UriInfo uriInfo,
128129
@QueryParam("externalId") @Parameter(description = "externalId") final String externalId,
@@ -153,7 +154,7 @@ public String retrieveAll(@Context final UriInfo uriInfo,
153154
+ "Mandatory Fields: clientId or groupId, productId, submittedOnDate\n\n"
154155
+ "Optional Fields: accountNo, externalId, fieldOfficerId\n\n"
155156
+ "Inherited from Product (if not provided): nominalAnnualInterestRate, interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, allowOverdraft, overdraftLimit, withHoldTax\n\n"
156-
+ "Additional Mandatory Field if Entity-Datatable Check is enabled for the entity of type Savings: datatables")
157+
+ "Additional Mandatory Field if Entity-Datatable Check is enabled for the entity of type Savings: datatables", operationId = "submitSavingsApplication")
157158
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PostSavingsAccountsRequest.class)))
158159
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PostSavingsAccountsResponse.class)))
159160
public String submitApplication(@Parameter(hidden = true) final String apiRequestBodyAsJson) {
@@ -182,6 +183,8 @@ public String submitGSIMApplication(final String apiRequestBodyAsJson) {
182183
@Path("{accountId}")
183184
@Consumes({ MediaType.APPLICATION_JSON })
184185
@Produces({ MediaType.APPLICATION_JSON })
186+
@Operation(summary = "Retrieve a savings account", description = "Retrieves a savings account\n\n" + "Example Requests:\n" + "\n"
187+
+ "savingsaccounts/1", operationId = "retrieveSavingsAccount")
185188
public SavingsAccountData retrieveOne(@PathParam("accountId") final Long accountId,
186189
@DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly,
187190
@DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus,
@@ -210,7 +213,7 @@ public SavingsAccountData retrieveOne(@PathParam("externalId") final String exte
210213
+ "Savings application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method. Specific api endpoints will be created to allow change of interest detail such as rate, compounding period, posting period etc\n\n"
211214
+ "Modify savings account withhold tax applicability:\n\n"
212215
+ "Savings application's withhold tax can be modified when in 'Active' state. Once the application is activated, can modify the account withhold tax to post tax or vice-versa"
213-
+ "Showing request/response for 'Modify a savings application'")
216+
+ "Showing request/response for 'Modify a savings application'", operationId = "updateSavingsAccount")
214217
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PutSavingsAccountsAccountIdRequest.class)))
215218
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PutSavingsAccountsAccountIdResponse.class)))
216219
public String update(@PathParam("accountId") @Parameter(description = "accountId") final Long accountId,
@@ -341,7 +344,8 @@ public String handleGSIMCommands(@PathParam("parentAccountId") final Long parent
341344
+ "Block Savings Account Debit transactions:\n\n" + "All types of debit operations from Savings account wil be blocked\n\n"
342345
+ "Unblock Savings Account debit transactions:\n\n"
343346
+ "It unblocks the Saving account's debit operations. Now all types of debits can be transacted from Savings account\n\n"
344-
+ "Showing request/response for 'Unassign Savings Officer'")
347+
+ "Showing request/response for 'Unassign Savings Officer'", operationId = "handleSavingsCommands")
348+
345349
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PostSavingsAccountsAccountIdRequest.class)))
346350
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.PostSavingsAccountsAccountIdResponse.class)))
347351
public String handleCommands(@PathParam("accountId") @Parameter(description = "accountId") final Long accountId,
@@ -404,7 +408,7 @@ private boolean is(final String commandParam, final String commandValue) {
404408
@Path("{accountId}")
405409
@Consumes({ MediaType.APPLICATION_JSON })
406410
@Produces({ MediaType.APPLICATION_JSON })
407-
@Operation(summary = "Delete a savings application", description = "At present we support hard delete of savings application so long as its in 'Submitted and pending approval' state. One the application is moves past this state, it is not possible to do a 'hard' delete of the application or the account. An API endpoint will be added to close/de-activate the savings account.")
411+
@Operation(summary = "Delete a savings application", description = "At present we support hard delete of savings application so long as its in 'Submitted and pending approval' state. One the application is moves past this state, it is not possible to do a 'hard' delete of the application or the account. An API endpoint will be added to close/de-activate the savings account.", operationId = "deleteSavingsAccount")
408412
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SavingsAccountsApiResourceSwagger.DeleteSavingsAccountsAccountIdResponse.class)))
409413
public String delete(@PathParam("accountId") @Parameter(description = "accountId") final Long accountId) {
410414

integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountsExternalIdTest.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
*/
1919
package org.apache.fineract.integrationtests;
2020

21+
import static org.assertj.core.api.Assertions.assertThat;
22+
2123
import java.math.BigDecimal;
24+
import java.time.LocalDate;
25+
import java.time.ZoneId;
2226
import java.time.format.DateTimeFormatter;
2327
import java.util.UUID;
2428
import org.apache.fineract.client.models.DeleteSavingsAccountsAccountIdResponse;
@@ -33,21 +37,25 @@
3337
import org.apache.fineract.integrationtests.client.IntegrationTest;
3438
import org.apache.fineract.integrationtests.common.Utils;
3539
import org.apache.fineract.integrationtests.common.savings.SavingsTestLifecycleExtension;
40+
import org.junit.jupiter.api.BeforeEach;
41+
import org.junit.jupiter.api.MethodOrderer;
3642
import org.junit.jupiter.api.Order;
3743
import org.junit.jupiter.api.Test;
44+
import org.junit.jupiter.api.TestMethodOrder;
3845
import org.junit.jupiter.api.extension.ExtendWith;
3946
import org.slf4j.Logger;
4047
import org.slf4j.LoggerFactory;
4148
import retrofit2.Response;
4249

4350
@ExtendWith({ SavingsTestLifecycleExtension.class })
51+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
4452
public class SavingsAccountsExternalIdTest extends IntegrationTest {
4553

4654
private static final Logger LOG = LoggerFactory.getLogger(SavingsAccountsExternalIdTest.class);
47-
public static final String EXTERNAL_ID = UUID.randomUUID().toString();
55+
private static String externalId;
4856
private final String dateFormat = "dd MMMM yyyy";
4957
private final String locale = "en";
50-
private final String formattedDate = Utils.getLocalDateOfTenant().format(DateTimeFormatter.ofPattern(dateFormat));
58+
private final String formattedDate = LocalDate.now(ZoneId.systemDefault()).minusDays(5).format(DateTimeFormatter.ofPattern(dateFormat));
5159

5260
@Test
5361
@Order(1)
@@ -58,10 +66,10 @@ void submitSavingsAccountsApplication() {
5866
request.setProductId(1L);
5967
request.setLocale(locale);
6068
request.setDateFormat(dateFormat);
61-
request.setSubmittedOnDate(formattedDate);
69+
request.submittedOnDate(formattedDate);
6270
request.setExternalId(EXTERNAL_ID);
6371

64-
Response<PostSavingsAccountsResponse> response = okR(fineractClient().savingsAccounts.submitApplication2(request));
72+
Response<PostSavingsAccountsResponse> response = okR(fineractClient().savingsAccounts.submitSavingsApplication(request));
6573

6674
assertThat(response.isSuccessful()).isTrue();
6775
assertThat(response.body()).isNotNull();
@@ -74,8 +82,8 @@ void updateSavingsAccountWithExternalId() {
7482
PutSavingsAccountsAccountIdRequest request = new PutSavingsAccountsAccountIdRequest();
7583
request.setLocale(locale);
7684
request.setNominalAnnualInterestRate(5.999);
77-
Response<PutSavingsAccountsAccountIdResponse> response = okR(fineractClient().savingsAccounts.update22(EXTERNAL_ID, request, ""));
78-
85+
Response<PutSavingsAccountsAccountIdResponse> response = okR(
86+
fineractClient().savingsAccounts.updateSavingsAccount(externalId, request, ""));
7987
assertThat(response.isSuccessful()).isTrue();
8088
assertThat(response.body()).isNotNull();
8189
}
@@ -89,7 +97,7 @@ void approveSavingsAccount() {
8997
request.setLocale(locale);
9098
request.setApprovedOnDate(formattedDate);
9199
Response<PostSavingsAccountsAccountIdResponse> response = okR(
92-
fineractClient().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "approve"));
100+
fineractClient().savingsAccounts.handleSavingsCommands(externalId, request, "approve"));
93101

94102
assertThat(response.isSuccessful()).isTrue();
95103
assertThat(response.body()).isNotNull();
@@ -103,7 +111,8 @@ void retrieveSavingsAccountWithExternalId() {
103111
request.dateFormat(dateFormat);
104112
request.setLocale(locale);
105113
request.setActivatedOnDate(formattedDate);
106-
Response<SavingsAccountData> response = okR(fineractClient().savingsAccounts.retrieveOne27(EXTERNAL_ID, false, null, "all"));
114+
Response<SavingsAccountData> response = okR(
115+
fineractClient().savingsAccounts.retrieveSavingsAccount(externalId, false, null, "all"));
107116

108117
assertThat(response.isSuccessful()).isTrue();
109118
assertThat(response.body()).isNotNull();
@@ -117,7 +126,7 @@ void undoApprovalSavingsAccountWithExternalId() {
117126
LOG.info("------------------------------ UNDO APPROVAL SAVINGS ACCOUNT ---------------------------------------");
118127
PostSavingsAccountsAccountIdRequest request = new PostSavingsAccountsAccountIdRequest();
119128
Response<PostSavingsAccountsAccountIdResponse> response = okR(
120-
fineractClient().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "undoapproval"));
129+
fineractClient().savingsAccounts.handleSavingsCommands(externalId, request, "undoapproval"));
121130

122131
assertThat(response.isSuccessful()).isTrue();
123132
assertThat(response.body()).isNotNull();
@@ -131,7 +140,8 @@ void retrieveSavingsAccountWithExternalIdSecondTime() {
131140
request.dateFormat(dateFormat);
132141
request.setLocale(locale);
133142
request.setActivatedOnDate(formattedDate);
134-
Response<SavingsAccountData> response = okR(fineractClient().savingsAccounts.retrieveOne27(EXTERNAL_ID, false, null, "all"));
143+
Response<SavingsAccountData> response = okR(
144+
fineractClient().savingsAccounts.retrieveSavingsAccount(externalId, false, null, "all"));
135145

136146
assertThat(response.isSuccessful()).isTrue();
137147
assertThat(response.body()).isNotNull();
@@ -146,7 +156,7 @@ void deleteSavingsAccountWithExternalId() {
146156
request.dateFormat(dateFormat);
147157
request.setLocale(locale);
148158
request.setActivatedOnDate(formattedDate);
149-
Response<DeleteSavingsAccountsAccountIdResponse> response = okR(fineractClient().savingsAccounts.delete20(EXTERNAL_ID));
159+
Response<DeleteSavingsAccountsAccountIdResponse> response = okR(fineractClient().savingsAccounts.deleteSavingsAccount(externalId));
150160

151161
assertThat(response.isSuccessful()).isTrue();
152162
assertThat(response.body()).isNotNull();
@@ -161,7 +171,7 @@ void retrieveSavingsAccountWithExternalIdThirdTime() {
161171
request.setLocale(locale);
162172
request.setActivatedOnDate(formattedDate);
163173
Response<SavingsAccountData> response = Calls
164-
.executeU(fineractClient().savingsAccounts.retrieveOne27(EXTERNAL_ID, false, null, "all"));
174+
.executeU(fineractClient().savingsAccounts.retrieveSavingsAccount(externalId, false, null, "all"));
165175

166176
assertThat(response.raw().code()).isEqualTo(404);
167177
}

0 commit comments

Comments
 (0)