FINERACT-2421: Generate better client names during testing

This commit is contained in:
Adam Saghy
2026-02-06 09:34:00 +01:00
committed by Arnold Gálovics
parent d61b5e65f9
commit 967e0ea306
21 changed files with 149 additions and 103 deletions
@@ -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";
@@ -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) {
@@ -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)
@@ -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());
@@ -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();
@@ -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();
}
@@ -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();
}
@@ -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) {
@@ -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)//
@@ -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);
@@ -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);
@@ -39,7 +39,7 @@ public class FeignLoanTestBaseSmokeTest extends FeignLoanTestBase {
@Test
void testCreateClient() {
Long clientId = createClient("Test", "User");
Long clientId = createClient();
assertNotNull(clientId);
}
}
@@ -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) {
@@ -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()));
}
}
@@ -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!