[FINERACT-1760] Client transactions APIs with external client ID
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.integrationtests.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.UUID;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdTransactionsResponse;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdTransactionsTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.PostClientsClientIdTransactionsTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.PostClientsRequest;
|
||||
import org.apache.fineract.client.models.PostClientsResponse;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ClientTransactionTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ClientHelper clientHelper;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
clientHelper = new ClientHelper(requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientTransactions() {
|
||||
PostClientsRequest createClientRequest = ClientHelper.defaultClientCreationRequest();
|
||||
String clientExternalId = UUID.randomUUID().toString();
|
||||
createClientRequest.setExternalId(clientExternalId);
|
||||
PostClientsResponse client = clientHelper.createClient(createClientRequest);
|
||||
Long clientId = client.getClientId();
|
||||
assertNotNull(clientId);
|
||||
|
||||
final Integer chargeId = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getChargeSpecifiedDueDateJSON());
|
||||
Assertions.assertNotNull(chargeId);
|
||||
final Integer clientChargeId1 = ClientHelper.addChargesForClient(requestSpec, responseSpec, clientId.intValue(),
|
||||
ClientHelper.getSpecifiedDueDateChargesClientAsJSON(chargeId.toString(), "29 October 2011"));
|
||||
Assertions.assertNotNull(clientChargeId1);
|
||||
final String clientChargePaidTransactionId1 = ClientHelper.payChargesForClients(requestSpec, responseSpec, clientId.intValue(),
|
||||
clientChargeId1, ClientHelper.getPayChargeJSON("25 AUGUST 2015", "10"));
|
||||
assertNotNull(clientChargePaidTransactionId1);
|
||||
|
||||
final Integer clientChargeId2 = ClientHelper.addChargesForClient(requestSpec, responseSpec, clientId.intValue(),
|
||||
ClientHelper.getSpecifiedDueDateChargesClientAsJSON(chargeId.toString(), "29 October 2011"));
|
||||
Assertions.assertNotNull(clientChargeId2);
|
||||
final String clientChargePaidTransactionId2 = ClientHelper.payChargesForClients(requestSpec, responseSpec, clientId.intValue(),
|
||||
clientChargeId2, ClientHelper.getPayChargeJSON("25 AUGUST 2015", "10"));
|
||||
assertNotNull(clientChargePaidTransactionId2);
|
||||
|
||||
GetClientsClientIdTransactionsResponse allClientTransactionsByExternalId = clientHelper
|
||||
.getAllClientTransactionsByExternalId(clientExternalId);
|
||||
assertEquals(2, allClientTransactionsByExternalId.getTotalFilteredRecords());
|
||||
|
||||
GetClientsClientIdTransactionsTransactionIdResponse clientTransactionByExternalId = clientHelper
|
||||
.getClientTransactionByExternalId(clientExternalId, clientChargePaidTransactionId1);
|
||||
assertEquals(Integer.parseInt(clientChargePaidTransactionId1), clientTransactionByExternalId.getId());
|
||||
|
||||
PostClientsClientIdTransactionsTransactionIdResponse undoTransactionResponse = clientHelper
|
||||
.undoClientTransactionByExternalId(clientExternalId, clientChargePaidTransactionId2);
|
||||
assertNotNull(undoTransactionResponse.getResourceId());
|
||||
}
|
||||
}
|
||||
+17
@@ -44,12 +44,15 @@ import org.apache.fineract.client.models.GetClientClientIdAddressesResponse;
|
||||
import org.apache.fineract.client.models.GetClientTransferProposalDateResponse;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdResponse;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdTransactionsResponse;
|
||||
import org.apache.fineract.client.models.GetClientsClientIdTransactionsTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.GetObligeeData;
|
||||
import org.apache.fineract.client.models.PageClientSearchData;
|
||||
import org.apache.fineract.client.models.PagedRequestClientTextSearch;
|
||||
import org.apache.fineract.client.models.PostClientClientIdAddressesRequest;
|
||||
import org.apache.fineract.client.models.PostClientClientIdAddressesResponse;
|
||||
import org.apache.fineract.client.models.PostClientsClientIdResponse;
|
||||
import org.apache.fineract.client.models.PostClientsClientIdTransactionsTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.PostClientsRequest;
|
||||
import org.apache.fineract.client.models.PostClientsResponse;
|
||||
import org.apache.fineract.client.models.PutClientsClientIdResponse;
|
||||
@@ -786,6 +789,20 @@ public class ClientHelper extends IntegrationTest {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed");
|
||||
}
|
||||
|
||||
public GetClientsClientIdTransactionsResponse getAllClientTransactionsByExternalId(final String externalId) {
|
||||
return ok(fineract().clientTransactions.retrieveAllClientTransactions1(externalId, 0, 100));
|
||||
}
|
||||
|
||||
public GetClientsClientIdTransactionsTransactionIdResponse getClientTransactionByExternalId(final String externalId,
|
||||
final String transactionId) {
|
||||
return ok(fineract().clientTransactions.retrieveClientTransaction1(externalId, Long.parseLong(transactionId)));
|
||||
}
|
||||
|
||||
public PostClientsClientIdTransactionsTransactionIdResponse undoClientTransactionByExternalId(final String externalId,
|
||||
final String transactionId) {
|
||||
return ok(fineract().clientTransactions.undoClientTransaction1(externalId, Long.parseLong(transactionId), "undo"));
|
||||
}
|
||||
|
||||
public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException {
|
||||
requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
|
||||
byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" + "?"
|
||||
|
||||
Reference in New Issue
Block a user