FINERACT-2421: Generate better client names during testing
This commit is contained in:
committed by
Arnold Gálovics
parent
d61b5e65f9
commit
967e0ea306
+2
-2
@@ -34,8 +34,8 @@ public class ClientRequestFactory {
|
||||
return new PostClientsRequest()//
|
||||
.officeId(HEAD_OFFICE_ID)//
|
||||
.legalFormId(LEGAL_FORM_ID_PERSON)//
|
||||
.firstname(Utils.randomNameGenerator("Client_FirstName_", 5))//
|
||||
.lastname(Utils.randomNameGenerator("Client_LastName_", 5))//
|
||||
.firstname(Utils.randomFirstNameGenerator())//
|
||||
.lastname(Utils.randomLastNameGenerator())//
|
||||
.externalId(randomClientId("ID_", 7))//
|
||||
.dateFormat(DATE_FORMAT)//
|
||||
.locale(DEFAULT_LOCALE)//
|
||||
|
||||
+16
-16
@@ -129,7 +129,7 @@ public class LoanProductsRequestFactory {
|
||||
public static final String CHARGE_OFF_REASONS = "ChargeOffReasons";
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP1() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -239,7 +239,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP1InterestFlat() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_FLAT, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_FLAT, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -347,7 +347,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP1InterestDeclining() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_DECLINING, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_DECLINING, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -455,7 +455,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP11MonthInterestDecliningBalanceDailyRecalculationCompoundingMonthly() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_DECLINING_RECALCULATION, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_DECLINING_RECALCULATION, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -568,7 +568,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP1InterestDecliningBalanceDailyRecalculationCompoundingNone() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_DECLINING_RECALCULATION, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_DECLINING_RECALCULATION, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -678,7 +678,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2InterestDailyRecalculation() {
|
||||
final String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_RECALCULATION, 10);
|
||||
final String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_RECALCULATION, 10);
|
||||
final String shortName = generateShortNameSafely();
|
||||
|
||||
List<LoanProductChargeToGLAccountMapper> penaltyToIncomeAccountMappings = new ArrayList<>();
|
||||
@@ -793,7 +793,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_LP2, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -906,7 +906,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2InterestFlat() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_INTEREST_FLAT_LP2, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_INTEREST_FLAT_LP2, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1017,7 +1017,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2Emi() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1127,7 +1127,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2EmiWithChargeOff() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1257,7 +1257,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2ChargeOffReasonToExpenseAccountMappings() {
|
||||
final String name = Utils.randomNameGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String name = Utils.randomStringGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String shortName = generateShortNameSafely();
|
||||
|
||||
final List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1379,7 +1379,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2EmiCashAccounting() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1506,7 +1506,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2CapitalizedIncome() {
|
||||
final String name = Utils.randomNameGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String name = Utils.randomStringGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String shortName = generateShortNameSafely();
|
||||
final List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
final List<Integer> numberOfRepaymentVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1655,7 +1655,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2BuyDownFees() {
|
||||
final String name = Utils.randomNameGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String name = Utils.randomStringGenerator(NAME_PREFIX_LP2, 10);
|
||||
final String shortName = generateShortNameSafely();
|
||||
final List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
final List<Integer> numberOfRepaymentVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1793,7 +1793,7 @@ public class LoanProductsRequestFactory {
|
||||
}
|
||||
|
||||
public PostLoanProductsRequest defaultLoanProductsRequestLP2EmiUSD() {
|
||||
String name = Utils.randomNameGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String name = Utils.randomStringGenerator(NAME_PREFIX_LP2_EMI, 10);
|
||||
String shortName = generateShortNameSafely();
|
||||
|
||||
List<Integer> principalVariationsForBorrowerCycle = new ArrayList<>();
|
||||
@@ -1901,7 +1901,7 @@ public class LoanProductsRequestFactory {
|
||||
int counter = 0;
|
||||
do {
|
||||
counter++;
|
||||
generatedShortName = Utils.randomNameGenerator("", 4);
|
||||
generatedShortName = Utils.randomStringGenerator("", 4);
|
||||
if (counter > 999) {
|
||||
throw new RuntimeException("Unable to generate unique short name");
|
||||
}
|
||||
|
||||
@@ -21,10 +21,28 @@ package org.apache.fineract.test.helper;
|
||||
import java.security.SecureRandom;
|
||||
import java.time.Clock;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public final class Utils {
|
||||
|
||||
private static final SecureRandom random = new SecureRandom();
|
||||
private static final List<String> firstNames = List.of("Adam", "Alex", "Andrew", "Anthony", "Arthur", "Benjamin", "Brian", "Brandon",
|
||||
"Bruce", "Caleb", "Charles", "Christian", "Christopher", "Daniel", "David", "Dennis", "Dominic", "Edward", "Ethan", "Felix",
|
||||
"Frank", "Gabriel", "George", "Gregory", "Harry", "Henry", "Isaac", "Jack", "Jacob", "James", "Jason", "John", "Jonathan",
|
||||
"Joseph", "Joshua", "Julian", "Kevin", "Kyle", "Leo", "Liam", "Logan", "Lucas", "Luke", "Marcus", "Mark", "Martin", "Matthew",
|
||||
"Michael", "Nathan", "Nicholas", "Noah", "Oliver", "Oscar", "Patrick", "Paul", "Peter", "Philip", "Raymond", "Richard",
|
||||
"Robert", "Ryan", "Samuel", "Scott", "Sean", "Simon", "Stephen", "Steven", "Thomas", "Timothy", "Victor", "William", "Zachary",
|
||||
"Aaron", "Adrian", "Alan", "Albert", "Allen", "Antonio", "Austin", "Blake", "Cameron", "Carlos", "Colin", "Dylan", "Eric",
|
||||
"Harrison", "Ian", "Jeremy", "Jordan", "Kevin", "Louis", "Mitchell", "Neil", "Roger", "Trevor");
|
||||
|
||||
private static final List<String> lastNames = List.of("Anderson", "Armstrong", "Baker", "Barnes", "Bell", "Bennett", "Brooks", "Brown",
|
||||
"Bryant", "Butler", "Campbell", "Carter", "Clark", "Collins", "Cook", "Cooper", "Cox", "Davis", "Diaz", "Edwards", "Evans",
|
||||
"Fisher", "Foster", "Garcia", "Gomez", "Gonzalez", "Gray", "Green", "Hall", "Harris", "Hernandez", "Hill", "Howard", "Hughes",
|
||||
"Jackson", "James", "Jenkins", "Johnson", "Jones", "Kelly", "Kim", "King", "Lee", "Lewis", "Lopez", "Martin", "Martinez",
|
||||
"Miller", "Mitchell", "Moore", "Morgan", "Morris", "Murphy", "Nelson", "Nguyen", "Parker", "Perez", "Peterson", "Phillips",
|
||||
"Powell", "Price", "Ramirez", "Reed", "Richardson", "Rivera", "Roberts", "Robinson", "Rodriguez", "Rogers", "Ross", "Russell",
|
||||
"Sanchez", "Scott", "Smith", "Stewart", "Taylor", "Thomas", "Thompson", "Torres", "Turner", "Walker", "Ward", "Watson", "White",
|
||||
"Williams", "Wilson", "Wood", "Wright", "Young", "Zhang");
|
||||
|
||||
private Utils() {}
|
||||
|
||||
@@ -41,8 +59,12 @@ public final class Utils {
|
||||
return randomStringGenerator(prefix, len, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
public static String randomFirstNameGenerator() {
|
||||
return firstNames.get(random.nextInt(firstNames.size()));
|
||||
}
|
||||
|
||||
public static String randomLastNameGenerator() {
|
||||
return lastNames.get(random.nextInt(lastNames.size()));
|
||||
}
|
||||
|
||||
public static LocalDate now() {
|
||||
|
||||
+7
-7
@@ -115,7 +115,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
// if user created transferExternalId previously, it will use that, otherwise create a new one
|
||||
String transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED);
|
||||
if (transferExternalId == null) {
|
||||
transferExternalId = Utils.randomNameGenerator("TestTransferExtId_", 3);
|
||||
transferExternalId = Utils.randomStringGenerator("TestTransferExtId_", 10);
|
||||
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED, transferExternalId);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
} else if ((transferData.get(0).equals(TRANSACTION_TYPE_SALE) || transferData.get(0).equals(TRANSACTION_TYPE_INTERMEDIARY_SALE))) {
|
||||
String ownerExternalId;
|
||||
if (regenerateOwner) {
|
||||
ownerExternalId = Utils.randomNameGenerator(OWNER_EXTERNAL_ID_PREFIX, 3);
|
||||
ownerExternalId = Utils.randomStringGenerator(OWNER_EXTERNAL_ID_PREFIX, 10);
|
||||
} else {
|
||||
ownerExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
// if user created transferExternalId previously, it will use that, otherwise create a new one
|
||||
String transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED);
|
||||
if (transferExternalId == null) {
|
||||
transferExternalId = Utils.randomNameGenerator("TestTransferExtId_", 3);
|
||||
transferExternalId = Utils.randomStringGenerator("TestTransferExtId_", 10);
|
||||
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED, transferExternalId);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_BUYBACK_TRANSFER_EXTERNAL_ID_FROM_RESPONSE,
|
||||
response.getResourceExternalId());
|
||||
} else if (transferData.get(0).equals(TRANSACTION_TYPE_SALE)) {
|
||||
String ownerExternalId = Utils.randomNameGenerator(OWNER_EXTERNAL_ID_PREFIX, 3);
|
||||
String ownerExternalId = Utils.randomStringGenerator(OWNER_EXTERNAL_ID_PREFIX, 10);
|
||||
|
||||
request.settlementDate(transferData.get(1))//
|
||||
.ownerExternalId(ownerExternalId)//
|
||||
@@ -494,7 +494,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
.dateFormat(DATE_FORMAT_ASSET_EXT)//
|
||||
.locale(DEFAULT_LOCALE);//
|
||||
} else if (transferData.get(0).equals(TRANSACTION_TYPE_SALE)) {
|
||||
String ownerExternalId = Utils.randomNameGenerator(OWNER_EXTERNAL_ID_PREFIX, 3);
|
||||
String ownerExternalId = Utils.randomStringGenerator(OWNER_EXTERNAL_ID_PREFIX, 10);
|
||||
|
||||
request.settlementDate(transferData.get(1))//
|
||||
.ownerExternalId(ownerExternalId)//
|
||||
@@ -788,7 +788,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
String transferExternalId = testContext()
|
||||
.get(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED + "_" + type);
|
||||
if (transferExternalId == null) {
|
||||
transferExternalId = Utils.randomNameGenerator("TestTransferExtId_", 3);
|
||||
transferExternalId = Utils.randomStringGenerator("TestTransferExtId_", 10);
|
||||
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED + "_" + type, transferExternalId);
|
||||
}
|
||||
|
||||
@@ -923,7 +923,7 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
|
||||
public void createAssetExternalizationRequestByLoanIdUserGeneratedExtIdForceTransferIdNoTestOwner(String type, DataTable table)
|
||||
throws IOException {
|
||||
// if user created transferExternalId previously, it will use that, otherwise create a new one
|
||||
String transferExternalId = Utils.randomNameGenerator("TestTransferExtId_", 3);
|
||||
String transferExternalId = Utils.randomStringGenerator("TestTransferExtId_", 10);
|
||||
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED + "_" + type, transferExternalId);
|
||||
|
||||
createAssetExternalizationRequestByLoanId(table, transferExternalId, false);
|
||||
|
||||
+4
-4
@@ -47,7 +47,7 @@ public class UserStepDef extends AbstractStepDef {
|
||||
@When("Admin creates new user with {string} username, {string} role name and given permissions:")
|
||||
public void createUserWithUsernameAndRoles(String username, String roleName, List<String> permissions) {
|
||||
ok(() -> fineractClient.roles().retrieveAllRoles());
|
||||
PostRolesRequest newRoleRequest = new PostRolesRequest().name(Utils.randomNameGenerator(roleName, 8)).description(roleName);
|
||||
PostRolesRequest newRoleRequest = new PostRolesRequest().name(Utils.randomStringGenerator(roleName, 8)).description(roleName);
|
||||
PostRolesResponse createNewRole = ok(() -> fineractClient.roles().createRole(newRoleRequest));
|
||||
Long roleId = createNewRole.getResourceId();
|
||||
Map<String, Boolean> permissionMap = new HashMap<>();
|
||||
@@ -56,12 +56,12 @@ public class UserStepDef extends AbstractStepDef {
|
||||
.permissions(permissionMap);
|
||||
ok(() -> fineractClient.roles().updateRolePermissions(roleId, putRolesRoleIdPermissionsRequest));
|
||||
|
||||
String generatedUsername = Utils.randomNameGenerator(username, 8);
|
||||
String generatedUsername = Utils.randomStringGenerator(username, 8);
|
||||
PostUsersRequest postUsersRequest = new PostUsersRequest() //
|
||||
.username(generatedUsername) //
|
||||
.email(EMAIL) //
|
||||
.firstname(username) //
|
||||
.lastname(username) //
|
||||
.firstname(Utils.randomFirstNameGenerator()) //
|
||||
.lastname(Utils.randomLastNameGenerator()) //
|
||||
.sendPasswordToEmail(Boolean.FALSE) //
|
||||
.officeId(1L) //
|
||||
.password(PWD_USER_WITH_ROLE) //
|
||||
|
||||
+1
-1
@@ -3161,7 +3161,7 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
long loanId = loanResponse.getLoanId();
|
||||
|
||||
String reversalExternalId = Utils.randomNameGenerator("reversalExtId_", 3);
|
||||
String reversalExternalId = Utils.randomStringGenerator("reversalExtId_", 10);
|
||||
PostLoansLoanIdTransactionsRequest chargeOffUndoRequest = LoanRequestFactory.defaultUndoChargeOffRequest()
|
||||
.reversalExternalId(reversalExternalId);
|
||||
|
||||
|
||||
+2
-2
@@ -368,8 +368,8 @@ public abstract class BaseLoanIntegrationTest extends IntegrationTest {
|
||||
Calls.ok(fineractClient().roles.updateRolePermissions(roleId,
|
||||
new PutRolesRoleIdPermissionsRequest().putPermissionsItem(permission, false)));
|
||||
// create user with role
|
||||
String firstname = "Test";
|
||||
String lastname = Utils.uniqueRandomStringGenerator("User", 6);
|
||||
String firstname = Utils.randomFirstNameGenerator();
|
||||
String lastname = Utils.randomLastNameGenerator();
|
||||
String userName = Utils.uniqueRandomStringGenerator("testUserName", 4);
|
||||
String password = "AKleRbDhK421$";
|
||||
String email = firstname + "." + lastname + "@whatever.mifos.org";
|
||||
|
||||
+2
-2
@@ -7118,8 +7118,8 @@ public class ClientLoanIntegrationTest extends BaseLoanIntegrationTest {
|
||||
}
|
||||
|
||||
private PostClientsRequest createRandomClientWithDate(String date) {
|
||||
return new PostClientsRequest().officeId(1L).legalFormId(1L).firstname(Utils.randomStringGenerator("", 5))
|
||||
.lastname(Utils.randomStringGenerator("", 5)).active(true).locale("en").activationDate(date).dateFormat(DATETIME_PATTERN);
|
||||
return new PostClientsRequest().officeId(1L).legalFormId(1L).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).active(true).locale("en").activationDate(date).dateFormat(DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final List<HashMap> charges) {
|
||||
|
||||
+3
-3
@@ -270,9 +270,9 @@ public class ClientTest {
|
||||
|
||||
@Test
|
||||
public void testClientName() {
|
||||
String firstName = Utils.randomStringGenerator("FN", 48);
|
||||
String middleName = Utils.randomStringGenerator("MN", 48);
|
||||
String lastName = Utils.randomStringGenerator("LN", 48);
|
||||
String firstName = Utils.randomFirstNameGenerator();
|
||||
String middleName = Utils.randomFirstNameGenerator();
|
||||
String lastName = Utils.randomLastNameGenerator();
|
||||
String fullName = firstName + ' ' + middleName + ' ' + lastName;
|
||||
|
||||
PostClientsRequest request = new PostClientsRequest().officeId(1L).legalFormId(LEGALFORM_ID_PERSON).firstname(firstName)
|
||||
|
||||
+3
-4
@@ -63,10 +63,9 @@ public class NotificationApiTest {
|
||||
String username = Utils.uniqueRandomStringGenerator("NotificationUser", 4);
|
||||
String password = Utils.randomStringGenerator("A1b2c3d4e5f$", 1); // prefix is to conform with the password
|
||||
// rules
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(username)
|
||||
.firstname(Utils.randomStringGenerator("NotificationFN", 4)).lastname(Utils.randomStringGenerator("NotificationLN", 4))
|
||||
.email("whatever@mifos.org").password(password).repeatPassword(password).sendPasswordToEmail(false)
|
||||
.roles(List.of(SUPER_USER_ROLE_ID)).officeId(headOffice.getId());
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(username).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).email("whatever@mifos.org").password(password).repeatPassword(password)
|
||||
.sendPasswordToEmail(false).roles(List.of(SUPER_USER_ROLE_ID)).officeId(headOffice.getId());
|
||||
|
||||
PostUsersResponse userCreationResponse = UserHelper.createUser(requestSpec, responseSpec, createUserRequest);
|
||||
Assertions.assertNotNull(userCreationResponse.getResourceId());
|
||||
|
||||
+11
-12
@@ -191,10 +191,10 @@ public class UserAdministrationTest extends IntegrationTest {
|
||||
String originalPassword = "QwE!5rTy#9uP0";
|
||||
String simpleUsername = Utils.uniqueRandomStringGenerator("NotificationUser", 4);
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername)
|
||||
.firstname(Utils.randomStringGenerator("NotificationFN", 4)).lastname(Utils.randomStringGenerator("NotificationLN", 4))
|
||||
.email("whatever@mifos.org").password(originalPassword).repeatPassword(originalPassword).sendPasswordToEmail(false)
|
||||
.officeId(headOffice.getId()).roles(List.of(Long.valueOf(roleId)));
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).email("whatever@mifos.org").password(originalPassword)
|
||||
.repeatPassword(originalPassword).sendPasswordToEmail(false).officeId(headOffice.getId())
|
||||
.roles(List.of(Long.valueOf(roleId)));
|
||||
|
||||
PostUsersResponse userCreationResponse = UserHelper.createUser(requestSpec, responseSpec, createUserRequest);
|
||||
Long userId = userCreationResponse.getResourceId();
|
||||
@@ -224,10 +224,10 @@ public class UserAdministrationTest extends IntegrationTest {
|
||||
String originalPassword = "QwE!5rTy#9uP0";
|
||||
String simpleUsername = Utils.uniqueRandomStringGenerator("NotificationUser", 4);
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername)
|
||||
.firstname(Utils.randomStringGenerator("NotificationFN", 4)).lastname(Utils.randomStringGenerator("NotificationLN", 4))
|
||||
.email("whatever@mifos.org").password(originalPassword).repeatPassword(originalPassword).sendPasswordToEmail(false)
|
||||
.officeId(headOffice.getId()).roles(List.of(Long.valueOf(roleId)));
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).email("whatever@mifos.org").password(originalPassword)
|
||||
.repeatPassword(originalPassword).sendPasswordToEmail(false).officeId(headOffice.getId())
|
||||
.roles(List.of(Long.valueOf(roleId)));
|
||||
|
||||
PostUsersResponse userCreationResponse = UserHelper.createUser(requestSpec, responseSpec, createUserRequest);
|
||||
Long userId = userCreationResponse.getResourceId();
|
||||
@@ -258,10 +258,9 @@ public class UserAdministrationTest extends IntegrationTest {
|
||||
String password = "QwE!5rTy#9uP0";
|
||||
String simpleUsername = Utils.uniqueRandomStringGenerator("NotificationUser", 4);
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername)
|
||||
.firstname(Utils.randomStringGenerator("NotificationFN", 4)).lastname(Utils.randomStringGenerator("NotificationLN", 4))
|
||||
.email("whatever@mifos.org").password(password).repeatPassword(password).sendPasswordToEmail(false)
|
||||
.officeId(headOffice.getId()).roles(List.of(Long.valueOf(roleId)));
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(simpleUsername).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).email("whatever@mifos.org").password(password).repeatPassword(password)
|
||||
.sendPasswordToEmail(false).officeId(headOffice.getId()).roles(List.of(Long.valueOf(roleId)));
|
||||
|
||||
PostUsersResponse userCreationResponse = UserHelper.createUser(requestSpec, responseSpec, createUserRequest);
|
||||
Long userId = userCreationResponse.getResourceId();
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class FeignDocumentTest extends FeignIntegrationTest {
|
||||
@Order(1)
|
||||
void setupClient() {
|
||||
FeignClientHelper clientHelper = new FeignClientHelper(fineractClient());
|
||||
clientId = clientHelper.createClient("Feign", "Test");
|
||||
clientId = clientHelper.createClient();
|
||||
assertThat(clientId).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ public class StaffTest extends IntegrationTest {
|
||||
}
|
||||
|
||||
Long create() {
|
||||
return ok(fineractClient().staff.create3(new StaffRequest().officeId(1L).firstname(Utils.randomStringGenerator("StaffTest", 6))
|
||||
.lastname(Utils.randomStringGenerator("Staffer_", 6)).externalId(Utils.randomStringGenerator("", 12))
|
||||
return ok(fineractClient().staff.create3(new StaffRequest().officeId(1L).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).externalId(Utils.randomStringGenerator("", 12))
|
||||
.joiningDate(LocalDate.now(ZoneId.of("UTC")).toString()).dateFormat("yyyy-MM-dd").locale("en_US"))).getResourceId();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -93,8 +93,8 @@ public abstract class FeignLoanTestBase extends FeignIntegrationTest implements
|
||||
return getAccounts().getExpenseAccountId(accountName);
|
||||
}
|
||||
|
||||
protected Long createClient(String firstName, String lastName) {
|
||||
return clientHelper.createClient(firstName, lastName);
|
||||
protected Long createClient() {
|
||||
return clientHelper.createClient();
|
||||
}
|
||||
|
||||
protected Long createLoanProduct(PostLoanProductsRequest request) {
|
||||
|
||||
+3
-3
@@ -36,15 +36,15 @@ public class FeignClientHelper {
|
||||
this.fineractClient = fineractClient;
|
||||
}
|
||||
|
||||
public Long createClient(String firstName, String lastName) {
|
||||
public Long createClient() {
|
||||
String externalId = Utils.randomStringGenerator("EXT_", 7);
|
||||
String activationDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
|
||||
PostClientsRequest request = new PostClientsRequest()//
|
||||
.officeId(1L)//
|
||||
.legalFormId(1L)//
|
||||
.firstname(firstName)//
|
||||
.lastname(lastName)//
|
||||
.firstname(Utils.randomFirstNameGenerator())//
|
||||
.lastname(Utils.randomLastNameGenerator())//
|
||||
.externalId(externalId)//
|
||||
.active(true)//
|
||||
.activationDate(activationDate)//
|
||||
|
||||
+18
-17
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdStatus;
|
||||
import org.apache.fineract.client.models.PostLoanProductsRequest;
|
||||
import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
@@ -32,7 +33,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testCreateAndDisburseLoan_OnePeriodNoInterest() {
|
||||
Long clientId = createClient("John", "Doe");
|
||||
Long clientId = createClient();
|
||||
assertNotNull(clientId);
|
||||
|
||||
PostLoanProductsRequest productRequest = onePeriod30DaysNoInterest();
|
||||
@@ -45,7 +46,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
GetLoansLoanIdResponse loan = getLoanDetails(loanId);
|
||||
assertNotNull(loan);
|
||||
verifyLoanStatus(loan, status -> status.getActive());
|
||||
verifyLoanStatus(loan, GetLoansLoanIdStatus::getActive);
|
||||
|
||||
LocalDate expectedRepaymentDate = Utils.getLocalDateOfTenant().plusMonths(1);
|
||||
validateRepaymentPeriod(loan, 1, expectedRepaymentDate, 1000.0, 0.0, 1000.0);
|
||||
@@ -56,7 +57,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testLoanRepayment_FullRepayment() {
|
||||
Long clientId = createClient("Jane", "Smith");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(onePeriod30DaysNoInterest());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApproveAndDisburseLoan(clientId, productId, todayDate, 1000.0, 1);
|
||||
@@ -65,7 +66,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
assertNotNull(repaymentId);
|
||||
|
||||
GetLoansLoanIdResponse loan = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loan, status -> status.getClosedObligationsMet());
|
||||
verifyLoanStatus(loan, GetLoansLoanIdStatus::getClosedObligationsMet);
|
||||
|
||||
assertEquals(0.0, Utils.getDoubleValue(loan.getSummary().getTotalOutstanding()));
|
||||
assertEquals(1000.0, Utils.getDoubleValue(loan.getSummary().getTotalRepayment()));
|
||||
@@ -73,45 +74,45 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testLoanUndoApproval() {
|
||||
Long clientId = createClient("Bob", "Johnson");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(onePeriod30DaysNoInterest());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApprovedLoan(clientId, productId, todayDate, 1000.0, 1);
|
||||
|
||||
GetLoansLoanIdResponse loanBeforeUndo = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanBeforeUndo, status -> status.getWaitingForDisbursal());
|
||||
verifyLoanStatus(loanBeforeUndo, GetLoansLoanIdStatus::getWaitingForDisbursal);
|
||||
|
||||
undoApproval(loanId);
|
||||
|
||||
GetLoansLoanIdResponse loanAfterUndo = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanAfterUndo, status -> status.getPendingApproval());
|
||||
verifyLoanStatus(loanAfterUndo, GetLoansLoanIdStatus::getPendingApproval);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLoanUndoDisbursement() {
|
||||
Long clientId = createClient("Alice", "Williams");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(onePeriod30DaysNoInterest());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApproveAndDisburseLoan(clientId, productId, todayDate, 1000.0, 1);
|
||||
|
||||
GetLoansLoanIdResponse loanBeforeUndo = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanBeforeUndo, status -> status.getActive());
|
||||
verifyLoanStatus(loanBeforeUndo, GetLoansLoanIdStatus::getActive);
|
||||
|
||||
undoDisbursement(loanId);
|
||||
|
||||
GetLoansLoanIdResponse loanAfterUndo = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanAfterUndo, status -> status.getWaitingForDisbursal());
|
||||
verifyLoanStatus(loanAfterUndo, GetLoansLoanIdStatus::getWaitingForDisbursal);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFourInstallmentLoan_CumulativeInterest() {
|
||||
Long clientId = createClient("Charlie", "Brown");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(fourInstallmentsCumulative());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApproveAndDisburseLoan(clientId, productId, todayDate, 1000.0, 4);
|
||||
|
||||
GetLoansLoanIdResponse loan = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loan, status -> status.getActive());
|
||||
verifyLoanStatus(loan, GetLoansLoanIdStatus::getActive);
|
||||
|
||||
assertNotNull(loan.getRepaymentSchedule());
|
||||
assertNotNull(loan.getRepaymentSchedule().getPeriods());
|
||||
@@ -120,7 +121,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testPartialRepayment() {
|
||||
Long clientId = createClient("David", "Miller");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(onePeriod30DaysNoInterest());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApproveAndDisburseLoan(clientId, productId, todayDate, 1000.0, 1);
|
||||
@@ -129,7 +130,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
assertNotNull(repaymentId);
|
||||
|
||||
GetLoansLoanIdResponse loan = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loan, status -> status.getActive());
|
||||
verifyLoanStatus(loan, GetLoansLoanIdStatus::getActive);
|
||||
|
||||
assertEquals(500.0, Utils.getDoubleValue(loan.getSummary().getTotalOutstanding()));
|
||||
assertEquals(500.0, Utils.getDoubleValue(loan.getSummary().getTotalRepayment()));
|
||||
@@ -137,7 +138,7 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testUndoRepayment() {
|
||||
Long clientId = createClient("Eva", "Davis");
|
||||
Long clientId = createClient();
|
||||
Long productId = createLoanProduct(onePeriod30DaysNoInterest());
|
||||
String todayDate = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
|
||||
Long loanId = createApproveAndDisburseLoan(clientId, productId, todayDate, 1000.0, 1);
|
||||
@@ -146,12 +147,12 @@ public class FeignLoanCreationTest extends FeignLoanTestBase {
|
||||
assertNotNull(repaymentId);
|
||||
|
||||
GetLoansLoanIdResponse loanAfterRepayment = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanAfterRepayment, status -> status.getClosedObligationsMet());
|
||||
verifyLoanStatus(loanAfterRepayment, GetLoansLoanIdStatus::getClosedObligationsMet);
|
||||
|
||||
undoRepayment(loanId, repaymentId, todayDate);
|
||||
|
||||
GetLoansLoanIdResponse loanAfterUndo = getLoanDetails(loanId);
|
||||
verifyLoanStatus(loanAfterUndo, status -> status.getActive());
|
||||
verifyLoanStatus(loanAfterUndo, GetLoansLoanIdStatus::getActive);
|
||||
|
||||
LocalDate expectedRepaymentDate = Utils.getLocalDateOfTenant().plusMonths(1);
|
||||
validateRepaymentPeriod(loanAfterUndo, 1, expectedRepaymentDate, 1000.0, 0.0, 1000.0);
|
||||
|
||||
+10
-10
@@ -259,7 +259,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
@@ -273,7 +273,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
@@ -287,7 +287,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId, "Inactive Test", "INACTIVE");
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
final CallFailedRuntimeException exception = originatorHelper.attachOriginatorToLoanExpectingError(loanId, originatorId);
|
||||
@@ -301,7 +301,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
@@ -318,7 +318,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
final CallFailedRuntimeException exception = originatorHelper.detachOriginatorFromLoanExpectingError(loanId, originatorId);
|
||||
@@ -332,7 +332,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanProductId = loanHelper.createSimpleLoanProduct();
|
||||
final String todayDate = org.apache.fineract.integrationtests.common.Utils.dateFormatter
|
||||
.format(org.apache.fineract.integrationtests.common.Utils.getLocalDateOfTenant());
|
||||
@@ -349,7 +349,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
@@ -370,7 +370,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
@@ -387,7 +387,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testRetrieveLoanWithNoOriginatorsReturnsEmptyList() {
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
final var loanDetails = loanHelper.getLoanDetailsWithAssociations(loanId, "originators");
|
||||
@@ -401,7 +401,7 @@ public class FeignLoanOriginatorApiTest extends FeignIntegrationTest {
|
||||
final String originatorExternalId = FeignLoanOriginatorHelper.generateUniqueExternalId();
|
||||
final Long originatorId = originatorHelper.createOriginator(originatorExternalId);
|
||||
|
||||
final Long clientId = clientHelper.createClient("Test", "Client");
|
||||
final Long clientId = clientHelper.createClient();
|
||||
final Long loanId = loanHelper.createSubmittedLoan(clientId);
|
||||
|
||||
originatorHelper.attachOriginatorToLoan(loanId, originatorId);
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class FeignLoanTestBaseSmokeTest extends FeignLoanTestBase {
|
||||
|
||||
@Test
|
||||
void testCreateClient() {
|
||||
Long clientId = createClient("Test", "User");
|
||||
Long clientId = createClient();
|
||||
assertNotNull(clientId);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -450,8 +450,8 @@ public class ClientHelper {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("legalFormId", legalFormId);
|
||||
map.put("firstname", Utils.randomStringGenerator("Client_FirstName_", 5));
|
||||
map.put("lastname", Utils.randomStringGenerator("Client_LastName_", 4));
|
||||
map.put("firstname", Utils.randomFirstNameGenerator());
|
||||
map.put("lastname", Utils.randomLastNameGenerator());
|
||||
if (externalId != null) {
|
||||
map.put("externalId", externalId);
|
||||
}
|
||||
@@ -1209,10 +1209,9 @@ public class ClientHelper {
|
||||
}
|
||||
|
||||
public static PostClientsRequest defaultClientCreationRequest() {
|
||||
return new PostClientsRequest().officeId(1L).legalFormId(LEGALFORM_ID_PERSON)
|
||||
.firstname(Utils.randomStringGenerator("Client_FirstName_", 5)).lastname(Utils.randomStringGenerator("Client_LastName_", 5))
|
||||
.externalId(UUID.randomUUID().toString()).dateFormat(Utils.DATE_FORMAT).locale("en").active(true)
|
||||
.activationDate(DEFAULT_DATE);
|
||||
return new PostClientsRequest().officeId(1L).legalFormId(LEGALFORM_ID_PERSON).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).externalId(UUID.randomUUID().toString()).dateFormat(Utils.DATE_FORMAT)
|
||||
.locale("en").active(true).activationDate(DEFAULT_DATE);
|
||||
}
|
||||
|
||||
public LoanAccountLockResponseDTO retrieveLockedAccounts(int page, int limit) {
|
||||
|
||||
+26
@@ -102,6 +102,24 @@ public final class Utils {
|
||||
public static final String SOURCE_SET_NUMBERS_AND_LETTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
public static final String SOURCE_SET_NUMBERS = "1234567890";
|
||||
|
||||
private static final List<String> firstNames = List.of("Adam", "Alex", "Andrew", "Anthony", "Arthur", "Benjamin", "Brian", "Brandon",
|
||||
"Bruce", "Caleb", "Charles", "Christian", "Christopher", "Daniel", "David", "Dennis", "Dominic", "Edward", "Ethan", "Felix",
|
||||
"Frank", "Gabriel", "George", "Gregory", "Harry", "Henry", "Isaac", "Jack", "Jacob", "James", "Jason", "John", "Jonathan",
|
||||
"Joseph", "Joshua", "Julian", "Kevin", "Kyle", "Leo", "Liam", "Logan", "Lucas", "Luke", "Marcus", "Mark", "Martin", "Matthew",
|
||||
"Michael", "Nathan", "Nicholas", "Noah", "Oliver", "Oscar", "Patrick", "Paul", "Peter", "Philip", "Raymond", "Richard",
|
||||
"Robert", "Ryan", "Samuel", "Scott", "Sean", "Simon", "Stephen", "Steven", "Thomas", "Timothy", "Victor", "William", "Zachary",
|
||||
"Aaron", "Adrian", "Alan", "Albert", "Allen", "Antonio", "Austin", "Blake", "Cameron", "Carlos", "Colin", "Dylan", "Eric",
|
||||
"Harrison", "Ian", "Jeremy", "Jordan", "Kevin", "Louis", "Mitchell", "Neil", "Roger", "Trevor");
|
||||
|
||||
private static final List<String> lastNames = List.of("Anderson", "Armstrong", "Baker", "Barnes", "Bell", "Bennett", "Brooks", "Brown",
|
||||
"Bryant", "Butler", "Campbell", "Carter", "Clark", "Collins", "Cook", "Cooper", "Cox", "Davis", "Diaz", "Edwards", "Evans",
|
||||
"Fisher", "Foster", "Garcia", "Gomez", "Gonzalez", "Gray", "Green", "Hall", "Harris", "Hernandez", "Hill", "Howard", "Hughes",
|
||||
"Jackson", "James", "Jenkins", "Johnson", "Jones", "Kelly", "Kim", "King", "Lee", "Lewis", "Lopez", "Martin", "Martinez",
|
||||
"Miller", "Mitchell", "Moore", "Morgan", "Morris", "Murphy", "Nelson", "Nguyen", "Parker", "Perez", "Peterson", "Phillips",
|
||||
"Powell", "Price", "Ramirez", "Reed", "Richardson", "Rivera", "Roberts", "Robinson", "Rodriguez", "Rogers", "Ross", "Russell",
|
||||
"Sanchez", "Scott", "Smith", "Stewart", "Taylor", "Thomas", "Thompson", "Torres", "Turner", "Walker", "Ward", "Watson", "White",
|
||||
"Williams", "Wilson", "Wood", "Wright", "Young", "Zhang");
|
||||
|
||||
private Utils() {}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
@@ -576,4 +594,12 @@ public final class Utils {
|
||||
public static Double getDoubleValue(BigDecimal amount) {
|
||||
return amount == null ? null : amount.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
public static String randomFirstNameGenerator() {
|
||||
return firstNames.get(r.nextInt(firstNames.size()));
|
||||
}
|
||||
|
||||
public static String randomLastNameGenerator() {
|
||||
return lastNames.get(r.nextInt(lastNames.size()));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -220,9 +220,9 @@ public final class UserHelper {
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
String simpleRoleId = createSimpleRole(requestSpec, responseSpec);
|
||||
PostUsersRequest createUserRequest = new PostUsersRequest().username(SIMPLE_USER_NAME)
|
||||
.firstname(Utils.randomStringGenerator("NotificationFN", 4)).lastname(Utils.randomStringGenerator("NotificationLN", 4))
|
||||
.email("whatever@mifos.org").password(password).repeatPassword(password).sendPasswordToEmail(false)
|
||||
.roles(List.of(Long.valueOf(simpleRoleId))).officeId(headOffice.getId());
|
||||
.firstname(Utils.randomFirstNameGenerator()).lastname(Utils.randomLastNameGenerator()).email("whatever@mifos.org")
|
||||
.password(password).repeatPassword(password).sendPasswordToEmail(false).roles(List.of(Long.valueOf(simpleRoleId)))
|
||||
.officeId(headOffice.getId());
|
||||
|
||||
PostUsersResponse userCreationResponse = UserHelper.createUser(requestSpec, responseSpec, createUserRequest);
|
||||
Assertions.assertNotNull(userCreationResponse.getResourceId());
|
||||
@@ -243,9 +243,9 @@ public final class UserHelper {
|
||||
String uniqueUsername = Utils.uniqueRandomStringGenerator("TestUser", 4);
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
|
||||
return new PostUsersRequest().username(uniqueUsername).firstname("Test").lastname("User").email("testuser@example.com")
|
||||
.password(password).repeatPassword(password).sendPasswordToEmail(false).officeId(headOffice.getId())
|
||||
.roles(List.of(roleId.longValue()));
|
||||
return new PostUsersRequest().username(uniqueUsername).firstname(Utils.randomFirstNameGenerator())
|
||||
.lastname(Utils.randomLastNameGenerator()).email("testuser@example.com").password(password).repeatPassword(password)
|
||||
.sendPasswordToEmail(false).officeId(headOffice.getId()).roles(List.of(roleId.longValue()));
|
||||
}
|
||||
|
||||
// TODO: Rewrite to use fineract-client instead!
|
||||
|
||||
Reference in New Issue
Block a user