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
The following commit(s) were added to refs/heads/develop by this push:
new b5728652c7 FINERACT-2165: Migrate OfficeHelper to
fineract-client-feign and remove RestAssured/GSON dependencies
b5728652c7 is described below
commit b5728652c77f34727672866cfb2b9d5a643e43ac
Author: avinashvijayvargiya <[email protected]>
AuthorDate: Wed Mar 11 22:24:14 2026 +0530
FINERACT-2165: Migrate OfficeHelper to fineract-client-feign and remove
RestAssured/GSON dependencies
---
.../AccountNumberPreferencesTest.java | 3 +-
.../integrationtests/AccountTransferTest.java | 49 +++---
.../integrationtests/AuditIntegrationTest.java | 4 +-
.../integrationtests/CenterIntegrationTest.java | 11 +-
.../integrationtests/HookIntegrationTest.java | 4 +-
.../InstanceModeIntegrationTest.java | 12 +-
.../LoanReschedulingWithinCenterTest.java | 5 +-
.../integrationtests/NotificationApiTest.java | 2 +-
.../integrationtests/OfficeIntegrationTest.java | 74 +++-----
.../integrationtests/UserAdministrationTest.java | 6 +-
.../accounting/AccountingRuleIntegrationTest.java | 2 +-
.../client/ClientEntityImportHandlerTest.java | 4 +-
.../importhandler/loan/LoanImportHandlerTest.java | 8 +-
.../office/OfficeImportHandlerTest.java | 34 +++-
.../savings/SavingsImportHandlerTest.java | 8 +-
.../client/ClientEntityWorkbookPopulatorTest.java | 4 +-
.../populator/loan/LoanWorkbookPopulatorTest.java | 4 +-
.../office/OfficeWorkBookPopulatorTest.java | 17 +-
.../savings/SavingsWorkbookPopulateTest.java | 4 +-
.../client/feign/helpers/FeignOfficeHelper.java | 97 +++++++++++
.../integrationtests/common/OfficeDomain.java | 155 -----------------
.../integrationtests/common/OfficeHelper.java | 191 +++++----------------
.../InitiateExternalAssetOwnerTransferTest.java | 6 +-
.../useradministration/users/UserHelper.java | 4 +-
24 files changed, 283 insertions(+), 425 deletions(-)
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java
index e43f39d993..84359a5695 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java
@@ -25,6 +25,7 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.math.BigDecimal;
import java.sql.Timestamp;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -311,7 +312,7 @@ public class AccountNumberPreferencesTest {
private void createAndValidateCenter(Boolean isAccountPreferenceSetUp) {
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
- Integer officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ Integer officeId = new OfficeHelper().createOffice(LocalDate.of(2007,
7, 1)).getResourceId().intValue();
String name = "CenterCreation" + new Timestamp(new
java.util.Date().getTime());
this.centerId = CenterHelper.createCenter(name, officeId, requestSpec,
responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountTransferTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountTransferTest.java
index 52824bbb35..8f252c7977 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountTransferTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountTransferTest.java
@@ -27,6 +27,7 @@ import io.restassured.path.json.JsonPath;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.math.BigDecimal;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -158,8 +159,8 @@ public class AccountTransferTest {
final Account expenseAccount =
this.accountHelper.createExpenseAccount();
final Account liabilityAccount =
this.accountHelper.createLiabilityAccount();
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Savings Account to which fund to be Transferred
@@ -186,7 +187,7 @@ public class AccountTransferTest {
final HashMap toSavingsSummaryBefore =
this.savingsAccountHelper.getSavingsSummary(toSavingsID);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -257,8 +258,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -286,7 +287,7 @@ public class AccountTransferTest {
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(toLoanStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -355,8 +356,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -381,7 +382,7 @@ public class AccountTransferTest {
toSavingsStatusHashMap =
this.savingsAccountHelper.activateSavings(toSavingsID);
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -479,8 +480,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -505,7 +506,7 @@ public class AccountTransferTest {
toSavingsStatusHashMap =
this.savingsAccountHelper.activateSavings(toSavingsID);
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -571,8 +572,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -597,7 +598,7 @@ public class AccountTransferTest {
toSavingsStatusHashMap =
this.savingsAccountHelper.activateSavings(toSavingsID);
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -664,8 +665,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -690,7 +691,7 @@ public class AccountTransferTest {
toSavingsStatusHashMap =
this.savingsAccountHelper.activateSavings(toSavingsID);
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -757,8 +758,8 @@ public class AccountTransferTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountTransferHelper = new
AccountTransferHelper(this.requestSpec, this.responseSpec);
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Loan Account to which fund to be Transferred
@@ -783,7 +784,7 @@ public class AccountTransferTest {
toSavingsStatusHashMap =
this.savingsAccountHelper.activateSavings(toSavingsID);
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
@@ -843,8 +844,8 @@ public class AccountTransferTest {
final Account expenseAccount =
this.accountHelper.createExpenseAccount();
final Account liabilityAccount =
this.accountHelper.createLiabilityAccount();
- OfficeHelper officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
- Integer toOfficeId = officeHelper.createOffice("01 January 2011");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer toOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(toOfficeId);
// Creating Savings Account to which fund to be Transferred
@@ -871,7 +872,7 @@ public class AccountTransferTest {
final HashMap toSavingsSummaryBefore =
this.savingsAccountHelper.getSavingsSummary(toSavingsID);
- Integer fromOfficeId = officeHelper.createOffice("01 January 2011");
+ Integer fromOfficeId = officeHelper.createOffice(LocalDate.of(2011, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(fromOfficeId);
// Creating Savings Account from which the Fund has to be Transferred
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
index e95becaaed..8e67d46b82 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
@@ -120,8 +120,8 @@ public class AuditIntegrationTest {
}
// When Office is created
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- int officeId = officeHelper.createOffice("22 June 2020");
+ OfficeHelper officeHelper = new OfficeHelper();
+ int officeId = officeHelper.createOffice(java.time.LocalDate.of(2020,
6, 22)).getResourceId().intValue();
auditsRecieved = auditHelper.getAuditDetails(officeId, "CREATE",
"OFFICE");
auditHelper.verifyOneAuditOnly(auditsRecieved, officeId, "CREATE",
"OFFICE");
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java
index 64e18c7740..e64b6d6b60 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java
@@ -27,6 +27,7 @@ import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.sql.Timestamp;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -59,7 +60,7 @@ public class CenterIntegrationTest {
@Test
public void testBasicCenterCreation() {
- int officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ int officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7,
1)).getResourceId().intValue();
String name = "TestBasicCreation" + new Timestamp(new
java.util.Date().getTime());
int resourceId = CenterHelper.createCenter(name, officeId,
requestSpec, responseSpec);
@@ -85,7 +86,7 @@ public class CenterIntegrationTest {
@Test
public void testFullCenterCreation() {
- int officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ int officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7,
1)).getResourceId().intValue();
String name = "TestFullCreation" + new Timestamp(new
java.util.Date().getTime());
String externalId = UUID.randomUUID().toString();
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
@@ -125,7 +126,7 @@ public class CenterIntegrationTest {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testCenterUpdate() {
- int officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ int officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7,
1)).getResourceId().intValue();
String name = "TestFullCreation" + new Timestamp(new
java.util.Date().getTime());
String externalId = UUID.randomUUID().toString();
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
@@ -171,7 +172,7 @@ public class CenterIntegrationTest {
@Test
public void testCenterDeletion() {
- int officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ int officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7,
1)).getResourceId().intValue();
String name = "TestBasicCreation" + new Timestamp(new
java.util.Date().getTime());
int resourceId = CenterHelper.createCenter(name, officeId,
requestSpec, responseSpec);
@@ -264,7 +265,7 @@ public class CenterIntegrationTest {
@Test
public void testCentersOrphanGroups() {
- int officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ int officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7,
1)).getResourceId().intValue();
String name = "TestBasicCreation" + new Timestamp(new
java.util.Date().getTime());
int resourceId = CenterHelper.createCenter(name, officeId,
requestSpec, responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/HookIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/HookIntegrationTest.java
index 489098b551..c148deff8b 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/HookIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/HookIntegrationTest.java
@@ -55,7 +55,7 @@ public class HookIntegrationTest {
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
this.hookHelper = new HookHelper(this.requestSpec, this.responseSpec);
- this.officeHelper = new OfficeHelper(this.requestSpec,
this.responseSpec);
+ this.officeHelper = new OfficeHelper();
}
@Test
@@ -66,7 +66,7 @@ public class HookIntegrationTest {
final String payloadURL = "http://echo-webhook.herokuapp.com:80/" +
uniqueId + "/";
final Integer hookId = this.hookHelper.createHook(payloadURL);
Assertions.assertNotNull(hookId);
- final Integer createdOfficeID = this.officeHelper.createOffice("01
January 2012");
+ final Integer createdOfficeID =
this.officeHelper.createOffice(java.time.LocalDate.of(2012, 1,
1)).getResourceId().intValue();
Assertions.assertNotNull(createdOfficeID);
try {
// sleep for a three seconds after each failure to increase the
likelihood of the previous request for
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/InstanceModeIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/InstanceModeIntegrationTest.java
index a1d3276747..4e3c07514b 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/InstanceModeIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/InstanceModeIntegrationTest.java
@@ -18,13 +18,16 @@
*/
package org.apache.fineract.integrationtests;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
+import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.GetOfficesResponse;
import org.apache.fineract.client.models.PostClientsRequest;
import org.apache.fineract.integrationtests.common.ClientHelper;
@@ -66,7 +69,7 @@ public class InstanceModeIntegrationTest {
public void testGetHeadOfficeWorks_WhenInstanceModeIsReadOnly() {
// given
// when
- GetOfficesResponse result = OfficeHelper.getHeadOffice(requestSpec,
responseSpec200);
+ GetOfficesResponse result = OfficeHelper.getHeadOffice();
// then
assertNotNull(result);
}
@@ -76,7 +79,7 @@ public class InstanceModeIntegrationTest {
public void testGetHeadOfficeWorks_WhenInstanceModeIsWriteOnly() {
// given
// when
- GetOfficesResponse result = OfficeHelper.getHeadOffice(requestSpec,
responseSpec200);
+ GetOfficesResponse result = OfficeHelper.getHeadOffice();
// then
assertNotNull(result);
}
@@ -86,8 +89,9 @@ public class InstanceModeIntegrationTest {
public void testGetHeadOfficeDoesntWork_WhenInstanceModeIsBatchOnly() {
// given
// when
- OfficeHelper.getHeadOffice(requestSpec, responseSpec405);
- // then no exception is thrown
+ CallFailedRuntimeException exception =
assertThrows(CallFailedRuntimeException.class, () ->
OfficeHelper.getHeadOffice());
+ // then
+ assertEquals(405, exception.getStatus());
}
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false,
batchWorkerEnabled = false, batchManagerEnabled = false)
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java
index f800042a26..e3418fbba1 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java
@@ -31,6 +31,7 @@ import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -85,7 +86,7 @@ public class LoanReschedulingWithinCenterTest extends
BaseLoanIntegrationTest {
@Test
public void testCenterReschedulingLoansWithInterestRecalculationEnabled() {
- Integer officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ Integer officeId = new OfficeHelper().createOffice(LocalDate.of(2007,
7, 1)).getResourceId().intValue();
String name = "TestFullCreation" + new Timestamp(new
java.util.Date().getTime());
String externalId = UUID.randomUUID().toString();
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
@@ -218,7 +219,7 @@ public class LoanReschedulingWithinCenterTest extends
BaseLoanIntegrationTest {
@Test
public void
testCenterReschedulingMultiTrancheLoansWithInterestRecalculationEnabled() {
- Integer officeId = new OfficeHelper(requestSpec,
responseSpec).createOffice("01 July 2007");
+ Integer officeId = new OfficeHelper().createOffice(LocalDate.of(2007,
7, 1)).getResourceId().intValue();
String name = "TestFullCreation" + new Timestamp(new
java.util.Date().getTime());
String externalId = UUID.randomUUID().toString();
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/NotificationApiTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/NotificationApiTest.java
index 6a8dda7b80..ea730bc8ae 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/NotificationApiTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/NotificationApiTest.java
@@ -59,7 +59,7 @@ public class NotificationApiTest {
requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
String username =
Utils.uniqueRandomStringGenerator("NotificationUser", 4);
String password = Utils.randomStringGenerator("A1b2c3d4e5f$", 1); //
prefix is to conform with the password
//
rules
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/OfficeIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/OfficeIntegrationTest.java
index 9040422b59..49fc8888a7 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/OfficeIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/OfficeIntegrationTest.java
@@ -18,86 +18,66 @@
*/
package org.apache.fineract.integrationtests;
-import io.restassured.builder.RequestSpecBuilder;
-import io.restassured.builder.ResponseSpecBuilder;
-import io.restassured.http.ContentType;
-import io.restassured.specification.RequestSpecification;
-import io.restassured.specification.ResponseSpecification;
-import java.io.IOException;
import java.time.LocalDate;
import java.util.UUID;
import org.apache.fineract.client.models.GetOfficesResponse;
+import org.apache.fineract.client.models.PostOfficesResponse;
import org.apache.fineract.client.models.PutOfficesOfficeIdResponse;
import org.apache.fineract.infrastructure.core.service.DateUtils;
-import org.apache.fineract.integrationtests.common.OfficeDomain;
import org.apache.fineract.integrationtests.common.OfficeHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import retrofit2.Response;
public class OfficeIntegrationTest {
- private ResponseSpecification responseSpec;
- private RequestSpecification requestSpec;
-
- @BeforeEach
- public void setup() {
- Utils.initializeRESTAssured();
- this.requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
- this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
- this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
- }
+ private final OfficeHelper officeHelper = new OfficeHelper();
@Test
public void testOfficeModification() {
- OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec);
- int officeId = oh.createOffice("01 July 2007");
+ PostOfficesResponse createResponse =
officeHelper.createOffice(LocalDate.of(2007, 7, 1));
+ Long officeId = createResponse.getResourceId();
+
String name = Utils.uniqueRandomStringGenerator("New_Office_", 4);
String date = "02 July 2007";
- String[] dateArr = { "2007", "7", "2" };
- oh.updateOffice(officeId, name, date);
- OfficeDomain newOffice = oh.retrieveOfficeByID(officeId);
+ officeHelper.updateOffice(officeId, name, date);
+ GetOfficesResponse updatedOffice =
officeHelper.retrieveOffice(officeId);
- Assertions.assertTrue(name.equals(newOffice.getName()));
- Assertions.assertArrayEquals(dateArr, newOffice.getOpeningDate());
+ Assertions.assertEquals(name, updatedOffice.getName());
+
Assertions.assertTrue(DateUtils.isEqual(updatedOffice.getOpeningDate(),
LocalDate.of(2007, 7, 2)));
}
@Test
- public void testOfficeModificationWithExternalId() throws IOException {
- OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec);
+ public void testOfficeModificationWithExternalId() {
String externalId = UUID.randomUUID().toString();
- int officeId = oh.createOfficeWithExternalId(externalId, "01 July
2007");
- String date = "02 July 2007";
+ PostOfficesResponse createResponse =
officeHelper.createOffice(externalId, LocalDate.of(2007, 7, 1));
+ Long officeId = createResponse.getResourceId();
+
String name = Utils.uniqueRandomStringGenerator("New_Office_", 4);
- String[] dateArr = { "2007", "7", "2" };
+ String date = "02 July 2007";
+
+ PutOfficesOfficeIdResponse updateResult =
officeHelper.updateOfficeByExternalId(externalId, name, date);
+ Assertions.assertEquals(officeId, updateResult.getOfficeId());
- Response<PutOfficesOfficeIdResponse> updateResult =
oh.updateOfficeUsingExternalId(externalId, name, date);
- Assertions.assertTrue(updateResult.isSuccessful());
- Assertions.assertEquals(officeId, updateResult.body().getOfficeId());
- OfficeDomain newOffice = oh.retrieveOfficeByID(officeId);
+ GetOfficesResponse updatedOffice =
officeHelper.retrieveOffice(officeId);
- Assertions.assertTrue(name.equals(newOffice.getName()));
- Assertions.assertArrayEquals(dateArr, newOffice.getOpeningDate());
+ Assertions.assertEquals(name, updatedOffice.getName());
+
Assertions.assertTrue(DateUtils.isEqual(updatedOffice.getOpeningDate(),
LocalDate.of(2007, 7, 2)));
}
@Test
- public void testOfficeModificationAndFetchWithExternalId() throws
IOException {
- OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec);
+ public void testOfficeModificationAndFetchWithExternalId() {
String externalId = UUID.randomUUID().toString();
- int officeId = oh.createOfficeWithExternalId(externalId, "01 July
2007");
+ officeHelper.createOffice(externalId, LocalDate.of(2007, 7, 1));
+
String name = Utils.uniqueRandomStringGenerator("New_Office_", 4);
String date = "02 July 2007";
- String[] dateArr = { "2007", "7", "2" };
-
- oh.updateOfficeUsingExternalId(externalId, name, date);
- Response<GetOfficesResponse> officeResult =
oh.retrieveOfficeByExternalId(externalId);
- GetOfficesResponse newOffice = officeResult.body();
+ officeHelper.updateOfficeByExternalId(externalId, name, date);
+ GetOfficesResponse updatedOffice =
officeHelper.retrieveOfficeByExternalId(externalId);
- Assertions.assertTrue(name.equals(newOffice.getName()));
- Assertions.assertTrue(DateUtils.isEqual(newOffice.getOpeningDate(),
LocalDate.of(2007, 7, 2)));
+ Assertions.assertEquals(name, updatedOffice.getName());
+
Assertions.assertTrue(DateUtils.isEqual(updatedOffice.getOpeningDate(),
LocalDate.of(2007, 7, 2)));
}
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java
index 6e4b6bc7a2..623f267c48 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java
@@ -158,7 +158,7 @@ public class UserAdministrationTest extends IntegrationTest
{
Integer roleId = RolesHelper.createRole(requestSpec, responseSpec);
String originalPassword = "QwE!5rTy#9uP0";
String simpleUsername =
Utils.uniqueRandomStringGenerator("NotificationUser", 4);
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
PostUsersRequest createUserRequest = new
PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
.lastname(Utils.randomLastNameGenerator()).email("[email protected]").password(originalPassword)
.repeatPassword(originalPassword).sendPasswordToEmail(false).officeId(headOffice.getId())
@@ -191,7 +191,7 @@ public class UserAdministrationTest extends IntegrationTest
{
Integer roleId = RolesHelper.createRole(requestSpec, responseSpec);
String originalPassword = "QwE!5rTy#9uP0";
String simpleUsername =
Utils.uniqueRandomStringGenerator("NotificationUser", 4);
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
PostUsersRequest createUserRequest = new
PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
.lastname(Utils.randomLastNameGenerator()).email("[email protected]").password(originalPassword)
.repeatPassword(originalPassword).sendPasswordToEmail(false).officeId(headOffice.getId())
@@ -225,7 +225,7 @@ public class UserAdministrationTest extends IntegrationTest
{
Integer roleId = RolesHelper.createRole(requestSpec, responseSpec);
String password = "QwE!5rTy#9uP0";
String simpleUsername =
Utils.uniqueRandomStringGenerator("NotificationUser", 4);
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
PostUsersRequest createUserRequest = new
PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
.lastname(Utils.randomLastNameGenerator()).email("[email protected]").password(password).repeatPassword(password)
.sendPasswordToEmail(false).officeId(headOffice.getId()).roles(List.of(Long.valueOf(roleId)));
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/accounting/AccountingRuleIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/accounting/AccountingRuleIntegrationTest.java
index 049384c4e7..03ef5af163 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/accounting/AccountingRuleIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/accounting/AccountingRuleIntegrationTest.java
@@ -63,7 +63,7 @@ public class AccountingRuleIntegrationTest {
// given
final Account accountToCredit = accountHelper.createIncomeAccount();
final Account accountToDebit = accountHelper.createExpenseAccount();
- final GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ final GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
// when
final PostAccountingRulesResponse accountingRule =
accountRuleHelper.createAccountRule(headOffice.getId(), accountToCredit,
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
index c1160fc23c..f553d5a2d1 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
@@ -77,8 +77,8 @@ public class ClientEntityImportHandlerTest {
Assertions.assertNotNull(outcome_staff_creation, "Could not create
staff");
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
// in order to populate helper columns in client entity sheet
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
index 9d8906c4c5..c1b621022e 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
@@ -41,13 +41,13 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
+import org.apache.fineract.client.models.GetOfficesResponse;
import org.apache.fineract.client.models.PaymentTypeCreateRequest;
import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import
org.apache.fineract.integrationtests.bulkimport.importhandler.LocalContentStorageUtil;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
import org.apache.fineract.integrationtests.common.GroupHelper;
-import org.apache.fineract.integrationtests.common.OfficeDomain;
import org.apache.fineract.integrationtests.common.OfficeHelper;
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
import org.apache.fineract.integrationtests.common.Utils;
@@ -93,11 +93,11 @@ public class LoanImportHandlerTest {
requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON);
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
- OfficeDomain office =
officeHelper.retrieveOfficeByID(outcome_office_creation);
+ GetOfficesResponse office =
officeHelper.retrieveOffice(outcome_office_creation.longValue());
Assertions.assertNotNull(office, "Could not retrieve created office");
String firstName = Utils.randomStringGenerator("Client_FirstName_", 5);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
index af538ce833..748681076a 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
@@ -22,10 +22,14 @@ import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -35,7 +39,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.bulkimport.constants.OfficeConstants;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import
org.apache.fineract.integrationtests.bulkimport.importhandler.LocalContentStorageUtil;
-import org.apache.fineract.integrationtests.common.OfficeHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
@@ -48,6 +51,8 @@ import org.junit.jupiter.api.Test;
@Slf4j
public class OfficeImportHandlerTest {
+ private static final String OFFICE_URL =
"/fineract-provider/api/v1/offices";
+
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -61,8 +66,7 @@ public class OfficeImportHandlerTest {
@Test
public void testOfficeImport() throws IOException, InterruptedException,
NoSuchFieldException, ParseException {
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
+ Workbook workbook = getOfficeWorkBook("dd MMMM yyyy");
// insert dummy data into excel
Sheet sheet =
workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
@@ -87,7 +91,7 @@ public class OfficeImportHandlerTest {
workbook.write(outputStream);
outputStream.close();
- String importDocumentId = officeHelper.importOfficeTemplate(file);
+ String importDocumentId = importOfficeTemplate(file);
file.delete();
Assertions.assertNotNull(importDocumentId);
@@ -95,7 +99,7 @@ public class OfficeImportHandlerTest {
Thread.sleep(10000);
// check status column of output excel
- String location =
LocalContentStorageUtil.path(officeHelper.getOutputTemplateLocation(importDocumentId));
+ String location =
LocalContentStorageUtil.path(getOutputTemplateLocation(importDocumentId));
FileInputStream fileInputStream = new FileInputStream(location);
Workbook outputWorkbook = new HSSFWorkbook(fileInputStream);
Sheet officeSheet =
outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
@@ -107,4 +111,24 @@ public class OfficeImportHandlerTest {
Assertions.assertEquals("Imported",
row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
outputWorkbook.close();
}
+
+ private Workbook getOfficeWorkBook(final String dateFormat) throws
IOException {
+ requestSpec.header(HttpHeaders.CONTENT_TYPE,
"application/vnd.ms-excel");
+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec,
responseSpec,
+ OFFICE_URL + "/downloadtemplate" + "?" +
Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
+ InputStream inputStream = new ByteArrayInputStream(byteArray);
+ return new HSSFWorkbook(inputStream);
+ }
+
+ private String importOfficeTemplate(File file) {
+ requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA);
+ return Utils.performServerTemplatePost(requestSpec, responseSpec,
OFFICE_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
+ null, file, "en", "dd MMMM yyyy");
+ }
+
+ private String getOutputTemplateLocation(final String importDocumentId) {
+ requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
+ return Utils.performServerOutputTemplateLocationGet(requestSpec,
responseSpec,
+ "/fineract-provider/api/v1/imports/getOutputTemplateLocation"
+ "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
+ }
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
index 13ea0d18fb..0e11e777de 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
@@ -38,11 +38,11 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
+import org.apache.fineract.client.models.GetOfficesResponse;
import
org.apache.fineract.infrastructure.bulkimport.constants.SavingsConstants;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import
org.apache.fineract.integrationtests.bulkimport.importhandler.LocalContentStorageUtil;
import org.apache.fineract.integrationtests.common.GroupHelper;
-import org.apache.fineract.integrationtests.common.OfficeDomain;
import org.apache.fineract.integrationtests.common.OfficeHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
@@ -83,11 +83,11 @@ public class SavingsImportHandlerTest {
requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON);
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
- OfficeDomain office =
officeHelper.retrieveOfficeByID(outcome_office_creation);
+ GetOfficesResponse office =
officeHelper.retrieveOffice(outcome_office_creation.longValue());
Assertions.assertNotNull(office, "Could not retrieve created office");
String firstName = Utils.randomStringGenerator("Client_FirstName_", 5);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
index fbc0230e71..0a3419e311 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
@@ -60,8 +60,8 @@ public class ClientEntityWorkbookPopulatorTest {
Assertions.assertNotNull(outcome_staff_creation, "Could not create
staff");
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
ClientHelper clientHelper = new ClientHelper(requestSpec,
responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
index a1baa2723f..9688486353 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
@@ -63,8 +63,8 @@ public class LoanWorkbookPopulatorTest {
public void testLoanWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON);
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
// in order to populate helper sheets
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/office/OfficeWorkBookPopulatorTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/office/OfficeWorkBookPopulatorTest.java
index 894ec69d78..331365e355 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/office/OfficeWorkBookPopulatorTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/office/OfficeWorkBookPopulatorTest.java
@@ -22,11 +22,14 @@ import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
+import jakarta.ws.rs.core.HttpHeaders;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.fineract.infrastructure.bulkimport.constants.OfficeConstants;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
-import org.apache.fineract.integrationtests.common.OfficeHelper;
import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -36,6 +39,8 @@ import org.junit.jupiter.api.Test;
public class OfficeWorkBookPopulatorTest {
+ private static final String OFFICE_URL =
"/fineract-provider/api/v1/offices";
+
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -49,12 +54,18 @@ public class OfficeWorkBookPopulatorTest {
@Test
public void testOfficeWorkbookPopulate() throws IOException {
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Workbook workbook = officeHelper.getOfficeWorkBook("dd MMMM yyyy");
+ Workbook workbook = getOfficeWorkBook("dd MMMM yyyy");
Sheet sheet =
workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstRow = sheet.getRow(1);
Assertions.assertNotNull("No parent offices found",
firstRow.getCell(OfficeConstants.LOOKUP_OFFICE_COL).getStringCellValue());
Assertions.assertEquals(1,
firstRow.getCell(OfficeConstants.LOOKUP_OFFICE_ID_COL).getNumericCellValue(),
0.0);
+ }
+ private Workbook getOfficeWorkBook(final String dateFormat) throws
IOException {
+ requestSpec.header(HttpHeaders.CONTENT_TYPE,
"application/vnd.ms-excel");
+ byte[] byteArray = Utils.performGetBinaryResponse(requestSpec,
responseSpec,
+ OFFICE_URL + "/downloadtemplate" + "?" +
Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
+ InputStream inputStream = new ByteArrayInputStream(byteArray);
+ return new HSSFWorkbook(inputStream);
}
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/savings/SavingsWorkbookPopulateTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/savings/SavingsWorkbookPopulateTest.java
index ebcb866211..2d62fffc32 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/savings/SavingsWorkbookPopulateTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/savings/SavingsWorkbookPopulateTest.java
@@ -59,8 +59,8 @@ public class SavingsWorkbookPopulateTest {
public void testSavingsWorkbookPopulate() throws IOException {
requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON);
// in order to populate helper sheets
- OfficeHelper officeHelper = new OfficeHelper(requestSpec,
responseSpec);
- Integer outcome_office_creation = officeHelper.createOffice("02 May
2000");
+ OfficeHelper officeHelper = new OfficeHelper();
+ Integer outcome_office_creation =
officeHelper.createOffice(java.time.LocalDate.of(2000, 5,
2)).getResourceId().intValue();
assertNotNull(outcome_office_creation, "Could not create office");
// in order to populate helper sheets
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignOfficeHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignOfficeHelper.java
new file mode 100644
index 0000000000..4e2fa85e6a
--- /dev/null
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignOfficeHelper.java
@@ -0,0 +1,97 @@
+/**
+ * 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.feign.helpers;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.time.LocalDate;
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetOfficesResponse;
+import org.apache.fineract.client.models.PostOfficesRequest;
+import org.apache.fineract.client.models.PostOfficesResponse;
+import org.apache.fineract.client.models.PutOfficesOfficeIdRequest;
+import org.apache.fineract.client.models.PutOfficesOfficeIdResponse;
+import org.apache.fineract.integrationtests.common.Utils;
+
+public class FeignOfficeHelper {
+
+ public static final long HEAD_OFFICE_ID = 1L;
+
+ private final FineractFeignClient fineractClient;
+
+ public FeignOfficeHelper(FineractFeignClient fineractClient) {
+ this.fineractClient = fineractClient;
+ }
+
+ public PostOfficesResponse createOffice(LocalDate openingDate) {
+ PostOfficesRequest request = new PostOfficesRequest()//
+ .parentId(HEAD_OFFICE_ID)//
+ .name(Utils.uniqueRandomStringGenerator("O_", 9))//
+ .openingDate(openingDate)//
+ .dateFormat("yyyy-MM-dd")//
+ .locale("en");
+ return ok(() -> fineractClient.offices().createOffice(request));
+ }
+
+ public PostOfficesResponse createOffice(String externalId, LocalDate
openingDate) {
+ PostOfficesRequest request = new PostOfficesRequest()//
+ .parentId(HEAD_OFFICE_ID)//
+ .name(Utils.uniqueRandomStringGenerator("O_", 9))//
+ .externalId(externalId)//
+ .openingDate(openingDate)//
+ .dateFormat("yyyy-MM-dd")//
+ .locale("en");
+ return ok(() -> fineractClient.offices().createOffice(request));
+ }
+
+ public GetOfficesResponse retrieveOffice(Long officeId) {
+ return ok(() -> fineractClient.offices().retrieveOffice(officeId));
+ }
+
+ public GetOfficesResponse retrieveOfficeByExternalId(String externalId) {
+ return ok(() ->
fineractClient.offices().retrieveOfficeByExternalId(externalId));
+ }
+
+ public GetOfficesResponse getHeadOffice() {
+ return ok(() ->
fineractClient.offices().retrieveOffice(HEAD_OFFICE_ID));
+ }
+
+ public PutOfficesOfficeIdResponse updateOffice(Long officeId, String name,
String openingDate) {
+ PutOfficesOfficeIdRequest request = new PutOfficesOfficeIdRequest()//
+ .name(name)//
+ .openingDate(openingDate)//
+ .dateFormat("dd MMMM yyyy")//
+ .locale("en");
+ return ok(() -> fineractClient.offices().updateOffice(officeId,
request));
+ }
+
+ public PutOfficesOfficeIdResponse updateOfficeByExternalId(String
externalId, String name, String openingDate) {
+ PutOfficesOfficeIdRequest request = new PutOfficesOfficeIdRequest()//
+ .name(name)//
+ .openingDate(openingDate)//
+ .dateFormat("dd MMMM yyyy")//
+ .locale("en");
+ return ok(() ->
fineractClient.offices().updateOfficeWithExternalId(externalId, request));
+ }
+
+ public List<GetOfficesResponse> retrieveAllOffices() {
+ return ok(() -> fineractClient.offices().retrieveOffices(false, null,
null));
+ }
+}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeDomain.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeDomain.java
deleted file mode 100644
index 320770ce8b..0000000000
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeDomain.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.fineract.integrationtests.common;
-
-import com.google.gson.Gson;
-import java.util.Arrays;
-
-public class OfficeDomain {
-
- public static final class Builder {
-
- private int id;
- private String name;
- private String nameDecorated;
- private String externalId;
- private String[] openingDate;
- private String hierarchy;
-
- private Builder(final int id, final String name, final String
nameDecorated, final String externalId, final String[] openingDate,
- final String hierarchy) {
- this.id = id;
- this.name = name;
- this.nameDecorated = nameDecorated;
- this.externalId = externalId;
- this.openingDate = openingDate;
- this.hierarchy = hierarchy;
- }
-
- public OfficeDomain build() {
- return new OfficeDomain(this.id, this.name, this.nameDecorated,
this.externalId, this.openingDate, this.hierarchy);
- }
- }
-
- private int id;
- private String name;
- private String nameDecorated;
- private String externalId;
- private String[] openingDate;
- private String hierarchy;
-
- OfficeDomain() {
-
- }
-
- private OfficeDomain(final int id, final String name, final String
nameDecorated, final String externalId, final String[] openingDate,
- final String hierarchy) {
-
- this.id = id;
- this.name = name;
- this.nameDecorated = nameDecorated;
- this.externalId = externalId;
- this.openingDate = openingDate;
- this.hierarchy = hierarchy;
- }
-
- public String toJSON() {
- return new Gson().toJson(this);
- }
-
- public static OfficeDomain fromJSON(final String jsonData) {
- return new Gson().fromJson(jsonData, OfficeDomain.class);
- }
-
- public static Builder create(final int id, final String name, final String
nameDecorated, final String externalId,
- final String[] openingDate, final String hierarchy) {
- return new Builder(id, name, nameDecorated, externalId, openingDate,
hierarchy);
- }
-
- public int getId() {
- return this.id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String getNameDecorated() {
- return this.nameDecorated;
- }
-
- public String getExternalId() {
- return this.externalId;
- }
-
- public String[] getOpeningDate() {
- return this.openingDate;
- }
-
- public String getHierarchy() {
- return this.hierarchy;
- }
-
- @Override
- public int hashCode() {
- int hash = 1;
-
- if (this.id > 0) {
- hash += this.id;
- }
- if (this.name != null) {
- hash += this.name.hashCode();
- }
- if (this.nameDecorated != null) {
- hash += this.nameDecorated.hashCode();
- }
- if (this.externalId != null) {
- hash += this.externalId.hashCode();
- }
- if (this.openingDate != null) {
- hash += Arrays.hashCode(this.openingDate);
- }
- if (this.hierarchy != null) {
- hash += this.hierarchy.hashCode();
- }
-
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof OfficeDomain)) {
- return false;
- }
-
- OfficeDomain od = (OfficeDomain) obj;
-
- if (this.id == od.getId() && this.name.equals(od.getName()) &&
this.nameDecorated.equals(od.getName())
- && this.externalId.equals(od.getExternalId()) &&
Arrays.equals(this.openingDate, od.getOpeningDate())
- && this.hierarchy.equals(od.getHierarchy())) {
- return true;
- }
-
- return false;
- }
-}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeHelper.java
index 8e3ec6efea..d11b44a6f1 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeHelper.java
@@ -18,174 +18,67 @@
*/
package org.apache.fineract.integrationtests.common;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import io.restassured.specification.RequestSpecification;
-import io.restassured.specification.ResponseSpecification;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+
+import java.time.LocalDate;
import org.apache.fineract.client.models.GetOfficesResponse;
+import org.apache.fineract.client.models.PostOfficesRequest;
+import org.apache.fineract.client.models.PostOfficesResponse;
import org.apache.fineract.client.models.PutOfficesOfficeIdRequest;
import org.apache.fineract.client.models.PutOfficesOfficeIdResponse;
-import org.apache.fineract.client.util.JSON;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import retrofit2.Response;
public class OfficeHelper {
public static final long HEAD_OFFICE_ID = 1L; // The ID is hardcoded in
the initial Liquibase migration script
- private static final Logger LOG =
LoggerFactory.getLogger(OfficeHelper.class);
- private static final String OFFICE_URL =
"/fineract-provider/api/v1/offices";
- private static final Gson GSON = new JSON().getGson();
- private final RequestSpecification requestSpec;
- private final ResponseSpecification responseSpec;
-
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public OfficeHelper(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec) {
- this.requestSpec = requestSpec;
- this.responseSpec = responseSpec;
+ public GetOfficesResponse retrieveOffice(Long officeId) {
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().retrieveOffice(officeId));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public OfficeDomain retrieveOfficeByID(int id) {
- Object get = Utils.performServerGet(requestSpec, responseSpec,
OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, "");
- final String json = new Gson().toJson(get);
- return new Gson().fromJson(json, new TypeToken<OfficeDomain>()
{}.getType());
+ public static GetOfficesResponse getHeadOffice() {
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().retrieveOffice(HEAD_OFFICE_ID));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public static GetOfficesResponse getHeadOffice(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec) {
- String response = Utils.performServerGet(requestSpec, responseSpec,
- OFFICE_URL + "/" + HEAD_OFFICE_ID + "?" +
Utils.TENANT_IDENTIFIER);
- return GSON.fromJson(response, GetOfficesResponse.class);
+ public PostOfficesResponse createOffice(final LocalDate openingDate) {
+ PostOfficesRequest request = new PostOfficesRequest()//
+ .parentId(HEAD_OFFICE_ID)//
+ .name(Utils.uniqueRandomStringGenerator("O_", 9))//
+ .openingDate(openingDate)//
+ .dateFormat("yyyy-MM-dd")//
+ .locale("en");
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().createOffice(request));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public Integer createOffice(final String openingDate) {
- String json = getAsJSON(openingDate);
- return Utils.performServerPost(this.requestSpec, this.responseSpec,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
- CommonConstants.RESPONSE_RESOURCE_ID);
+ public PostOfficesResponse createOffice(final String externalId, final
LocalDate openingDate) {
+ PostOfficesRequest request = new PostOfficesRequest()//
+ .parentId(HEAD_OFFICE_ID)//
+ .name(Utils.uniqueRandomStringGenerator("O_", 9))//
+ .externalId(externalId)//
+ .openingDate(openingDate)//
+ .dateFormat("yyyy-MM-dd")//
+ .locale("en");
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().createOffice(request));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public Integer createOfficeWithExternalId(String externalId, final String
openingDate) {
- String json = getAsJSON(externalId, openingDate);
- return Utils.performServerPost(this.requestSpec, this.responseSpec,
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
- CommonConstants.RESPONSE_RESOURCE_ID);
- }
-
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public Integer updateOffice(int id, String name, String openingDate) {
- final HashMap<String, String> map = new HashMap<String, String>();
- map.put("name", name);
- map.put("dateFormat", "dd MMMM yyyy");
- map.put("locale", "en");
- map.put("openingDate", openingDate);
-
- LOG.info("map : {}", map);
-
- return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL +
"/" + id + "?" + Utils.TENANT_IDENTIFIER,
- new Gson().toJson(map), "resourceId");
- }
-
- public Response<GetOfficesResponse> retrieveOfficeByExternalId(String
externalId) throws IOException {
- return
FineractClientHelper.getFineractClient().offices.retrieveOfficeByExternalId(externalId).execute();
- }
-
- public Response<PutOfficesOfficeIdResponse>
updateOfficeUsingExternalId(String externalId, String name, String openingDate)
- throws IOException {
- return FineractClientHelper.getFineractClient().offices
- .updateOfficeWithExternalId(externalId,
- new
PutOfficesOfficeIdRequest().name(name).openingDate(openingDate).dateFormat("dd
MMMM yyyy").locale("en"))
- .execute();
- }
-
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public static String getAsJSON(final String openingDate) {
- return getAsJSON(null, openingDate);
- }
-
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public static String getAsJSON(String externalId, final String
openingDate) {
- final HashMap<String, String> map = new HashMap<>();
- map.put("parentId", "1");
- map.put("name", Utils.uniqueRandomStringGenerator("O_", 9));
- map.put("dateFormat", "dd MMMM yyyy");
- map.put("locale", "en");
- map.put("openingDate", openingDate);
- if (externalId != null) {
- map.put("externalId", externalId);
- }
- LOG.info("map : {}", map);
- return new Gson().toJson(map);
- }
-
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public String importOfficeTemplate(File file) {
- String locale = "en";
- String dateFormat = "dd MMMM yyyy";
- requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA);
- return Utils.performServerTemplatePost(requestSpec, responseSpec,
OFFICE_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
- null, file, locale, dateFormat);
-
+ public PutOfficesOfficeIdResponse updateOffice(Long officeId, String name,
String openingDate) {
+ PutOfficesOfficeIdRequest request = new PutOfficesOfficeIdRequest()//
+ .name(name)//
+ .openingDate(openingDate)//
+ .dateFormat("dd MMMM yyyy")//
+ .locale("en");
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().updateOffice(officeId,
request));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public String getOutputTemplateLocation(final String importDocumentId) {
- requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
- return Utils.performServerOutputTemplateLocationGet(requestSpec,
responseSpec,
- "/fineract-provider/api/v1/imports/getOutputTemplateLocation"
+ "?" + Utils.TENANT_IDENTIFIER, importDocumentId);
+ public GetOfficesResponse retrieveOfficeByExternalId(String externalId) {
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().retrieveOfficeByExternalId(externalId));
}
- // TODO: Rewrite to use fineract-client instead!
- // Example:
org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
- // org.apache.fineract.client.models.PostLoansLoanIdRequest)
- @Deprecated(forRemoval = true)
- public Workbook getOfficeWorkBook(final String dateFormat) throws
IOException {
- requestSpec.header(HttpHeaders.CONTENT_TYPE,
"application/vnd.ms-excel");
- byte[] byteArray = Utils.performGetBinaryResponse(requestSpec,
responseSpec,
- OFFICE_URL + "/downloadtemplate" + "?" +
Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat);
- InputStream inputStream = new ByteArrayInputStream(byteArray);
- Workbook workbook = new HSSFWorkbook(inputStream);
- return workbook;
+ public PutOfficesOfficeIdResponse updateOfficeByExternalId(String
externalId, String name, String openingDate) {
+ PutOfficesOfficeIdRequest request = new PutOfficesOfficeIdRequest()//
+ .name(name)//
+ .openingDate(openingDate)//
+ .dateFormat("dd MMMM yyyy")//
+ .locale("en");
+ return ok(() ->
FineractFeignClientHelper.getFineractFeignClient().offices().updateOfficeWithExternalId(externalId,
request));
}
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java
index b6bf1b4dca..be2b61e1c5 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java
@@ -146,7 +146,7 @@ public class InitiateExternalAssetOwnerTransferTest extends
BaseLoanIntegrationT
SCHEDULER_JOB_HELPER = new SchedulerJobHelper(REQUEST_SPEC);
FINANCIAL_ACTIVITY_ACCOUNT_HELPER = new
FinancialActivityAccountHelper(REQUEST_SPEC);
LOAN_TRANSACTION_HELPER = new LoanTransactionHelper(REQUEST_SPEC,
RESPONSE_SPEC);
- OFFICE_HELPER = new OfficeHelper(REQUEST_SPEC, RESPONSE_SPEC);
+ OFFICE_HELPER = new OfficeHelper();
TODAYS_DATE = Utils.getLocalDateOfTenant();
new BusinessStepHelper().updateSteps("LOAN_CLOSE_OF_BUSINESS",
"APPLY_CHARGE_TO_OVERDUE_LOANS", "LOAN_DELINQUENCY_CLASSIFICATION",
@@ -963,7 +963,7 @@ public class InitiateExternalAssetOwnerTransferTest extends
BaseLoanIntegrationT
ExternalEventHelper.deleteAllExternalEvents(REQUEST_SPEC, new
ResponseSpecBuilder().expectStatusCode(Matchers.is(204)).build());
ExternalEventHelper.changeEventState(REQUEST_SPEC, RESPONSE_SPEC,
"LoanOwnershipTransferBusinessEvent", true);
- final var officeId = OFFICE_HELPER.createOffice("1 January 2020");
+ final Integer officeId =
OFFICE_HELPER.createOffice(LocalDate.of(2020, 1, 1)).getResourceId().intValue();
final var clientID = ClientHelper.createClient(REQUEST_SPEC,
RESPONSE_SPEC, "1 January 2020", officeId.toString());
final var loanID = createLoanForClient(clientID);
addPenaltyForLoan(loanID, "10");
@@ -1218,7 +1218,7 @@ public class InitiateExternalAssetOwnerTransferTest
extends BaseLoanIntegrationT
ExternalEventHelper.deleteAllExternalEvents(REQUEST_SPEC, new
ResponseSpecBuilder().expectStatusCode(Matchers.is(204)).build());
ExternalEventHelper.changeEventState(REQUEST_SPEC, RESPONSE_SPEC,
"LoanOwnershipTransferBusinessEvent", true);
- final Integer officeId = OFFICE_HELPER.createOffice("1 January
2020");
+ final Integer officeId =
OFFICE_HELPER.createOffice(LocalDate.of(2020, 1, 1)).getResourceId().intValue();
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC,
RESPONSE_SPEC, "1 January 2020", officeId.toString());
final Integer loanID = createLoanForClient(clientID);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java
index 6ea211bb98..3d72511b81 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java
@@ -196,7 +196,7 @@ public final class UserHelper {
final ResponseSpecification responseSpec) {
String password = SIMPLE_USER_PASSWORD;
if (!SIMPLE_USER_CREATED) {
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
String simpleRoleId = createSimpleRole(requestSpec, responseSpec);
PostUsersRequest createUserRequest = new
PostUsersRequest().username(SIMPLE_USER_NAME)
.firstname(Utils.randomFirstNameGenerator()).lastname(Utils.randomLastNameGenerator()).email("[email protected]")
@@ -220,7 +220,7 @@ public final class UserHelper {
public static PostUsersRequest buildUserRequest(ResponseSpecification
responseSpec, RequestSpecification requestSpec, String password) {
Integer roleId = RolesHelper.createRole(requestSpec, responseSpec);
String uniqueUsername = Utils.uniqueRandomStringGenerator("TestUser",
4);
- GetOfficesResponse headOffice =
OfficeHelper.getHeadOffice(requestSpec, responseSpec);
+ GetOfficesResponse headOffice = OfficeHelper.getHeadOffice();
return new
PostUsersRequest().username(uniqueUsername).firstname(Utils.randomFirstNameGenerator())
.lastname(Utils.randomLastNameGenerator()).email("[email protected]").password(password).repeatPassword(password)