FINERACT-1929: Allow the length of client name to be 160 chars
This commit is contained in:
+23
-26
@@ -100,10 +100,10 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom {
|
|||||||
@Column(name = "lastname", length = 50)
|
@Column(name = "lastname", length = 50)
|
||||||
private String lastname;
|
private String lastname;
|
||||||
|
|
||||||
@Column(name = "fullname", length = 100)
|
@Column(name = "fullname", length = 160)
|
||||||
private String fullname;
|
private String fullname;
|
||||||
|
|
||||||
@Column(name = "display_name", length = 100, nullable = false)
|
@Column(name = "display_name", length = 160, nullable = false)
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
|
||||||
@Column(name = "mobile_no", length = 50, unique = true)
|
@Column(name = "mobile_no", length = 50, unique = true)
|
||||||
@@ -493,32 +493,29 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deriveDisplayName() {
|
public void deriveDisplayName() {
|
||||||
|
if (StringUtils.isNotBlank(this.fullname)) {
|
||||||
StringBuilder nameBuilder = new StringBuilder();
|
this.displayName = this.fullname;
|
||||||
Integer legalForm = this.getLegalForm();
|
} else {
|
||||||
if (legalForm == null || LegalForm.fromInt(legalForm).isPerson()) {
|
StringBuilder nameBuilder = new StringBuilder();
|
||||||
if (StringUtils.isNotBlank(this.firstname)) {
|
if (legalForm == null || LegalForm.fromInt(legalForm).isPerson()) {
|
||||||
nameBuilder.append(this.firstname).append(' ');
|
if (StringUtils.isNotBlank(this.firstname)) {
|
||||||
}
|
nameBuilder.append(this.firstname);
|
||||||
|
}
|
||||||
if (StringUtils.isNotBlank(this.middlename)) {
|
if (StringUtils.isNotBlank(this.middlename)) {
|
||||||
nameBuilder.append(this.middlename).append(' ');
|
if (!nameBuilder.isEmpty()) {
|
||||||
}
|
nameBuilder.append(' ');
|
||||||
|
}
|
||||||
if (StringUtils.isNotBlank(this.lastname)) {
|
nameBuilder.append(this.middlename);
|
||||||
nameBuilder.append(this.lastname);
|
}
|
||||||
}
|
if (StringUtils.isNotBlank(this.lastname)) {
|
||||||
|
if (!nameBuilder.isEmpty()) {
|
||||||
if (StringUtils.isNotBlank(this.fullname)) {
|
nameBuilder.append(' ');
|
||||||
nameBuilder = new StringBuilder(this.fullname);
|
}
|
||||||
}
|
nameBuilder.append(this.lastname);
|
||||||
} else if (LegalForm.fromInt(legalForm).isEntity()) {
|
}
|
||||||
if (StringUtils.isNotBlank(this.fullname)) {
|
|
||||||
nameBuilder = new StringBuilder(this.fullname);
|
|
||||||
}
|
}
|
||||||
|
this.displayName = nameBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.displayName = nameBuilder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getActivationLocalDate() {
|
public LocalDate getActivationLocalDate() {
|
||||||
|
|||||||
+2
@@ -304,6 +304,8 @@ final class ClientsApiResourceSwagger {
|
|||||||
public String fullname;
|
public String fullname;
|
||||||
@Schema(example = "Client_FirstName")
|
@Schema(example = "Client_FirstName")
|
||||||
public String firstname;
|
public String firstname;
|
||||||
|
@Schema(example = "Client_MiddleName")
|
||||||
|
public String middlename;
|
||||||
@Schema(example = "123")
|
@Schema(example = "123")
|
||||||
public String externalId;
|
public String externalId;
|
||||||
@Schema(example = "Client_LastName")
|
@Schema(example = "Client_LastName")
|
||||||
|
|||||||
+1
-1
@@ -318,7 +318,7 @@ public final class ClientDataValidator {
|
|||||||
|
|
||||||
private void fullnameCannotBeBlank(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
|
private void fullnameCannotBeBlank(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
|
||||||
final String fullnameParam = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.fullnameParamName, element);
|
final String fullnameParam = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.fullnameParamName, element);
|
||||||
baseDataValidator.reset().parameter(ClientApiConstants.fullnameParamName).value(fullnameParam).notBlank().notExceedingLengthOf(100);
|
baseDataValidator.reset().parameter(ClientApiConstants.fullnameParamName).value(fullnameParam).notBlank().notExceedingLengthOf(160);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIndividualNamePartParameterPassed(final JsonElement element) {
|
private boolean isIndividualNamePartParameterPassed(final JsonElement element) {
|
||||||
|
|||||||
@@ -146,4 +146,5 @@
|
|||||||
<include file="parts/0124_transaction_summary_with_asset_owner_report_typo_fix_3.xml" relativeToChangelogFile="true" />
|
<include file="parts/0124_transaction_summary_with_asset_owner_report_typo_fix_3.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0125_transaction_summary_with_asset_owner_report_chargeoff_reason.xml" relativeToChangelogFile="true" />
|
<include file="parts/0125_transaction_summary_with_asset_owner_report_chargeoff_reason.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0126_add_loan_product_installment_level_delinquency.xml" relativeToChangelogFile="true" />
|
<include file="parts/0126_add_loan_product_installment_level_delinquency.xml" relativeToChangelogFile="true" />
|
||||||
|
<include file="parts/0127_client_name_length.xml" relativeToChangelogFile="true" />
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||||
|
<changeSet id="1" author="fineract">
|
||||||
|
<modifyDataType tableName="m_client" columnName="fullname" newDataType="VARCHAR(160)" />
|
||||||
|
<modifyDataType tableName="m_client" columnName="display_name" newDataType="VARCHAR(160)" />
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -19,7 +19,11 @@
|
|||||||
package org.apache.fineract.integrationtests;
|
package org.apache.fineract.integrationtests;
|
||||||
|
|
||||||
import static org.apache.fineract.integrationtests.client.IntegrationTest.assertThat;
|
import static org.apache.fineract.integrationtests.client.IntegrationTest.assertThat;
|
||||||
|
import static org.apache.fineract.integrationtests.common.ClientHelper.DEFAULT_DATE;
|
||||||
|
import static org.apache.fineract.integrationtests.common.ClientHelper.LEGALFORM_ID_PERSON;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
@@ -30,8 +34,10 @@ import io.restassured.specification.ResponseSpecification;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.fineract.client.models.GetClientClientIdAddressesResponse;
|
import org.apache.fineract.client.models.GetClientClientIdAddressesResponse;
|
||||||
|
import org.apache.fineract.client.models.GetClientsClientIdResponse;
|
||||||
import org.apache.fineract.client.models.GlobalConfigurationPropertyData;
|
import org.apache.fineract.client.models.GlobalConfigurationPropertyData;
|
||||||
import org.apache.fineract.client.models.PostClientClientIdAddressesRequest;
|
import org.apache.fineract.client.models.PostClientClientIdAddressesRequest;
|
||||||
import org.apache.fineract.client.models.PostClientClientIdAddressesResponse;
|
import org.apache.fineract.client.models.PostClientClientIdAddressesResponse;
|
||||||
@@ -263,4 +269,31 @@ public class ClientTest {
|
|||||||
assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
|
assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClientName() {
|
||||||
|
String firstName = Utils.randomStringGenerator("FN", 48);
|
||||||
|
String middleName = Utils.randomStringGenerator("MN", 48);
|
||||||
|
String lastName = Utils.randomStringGenerator("LN", 48);
|
||||||
|
String fullName = firstName + ' ' + middleName + ' ' + lastName;
|
||||||
|
|
||||||
|
PostClientsRequest request = new PostClientsRequest().officeId(1).legalFormId(LEGALFORM_ID_PERSON).firstname(firstName)
|
||||||
|
.middlename(middleName).lastname(lastName).externalId(UUID.randomUUID().toString()).dateFormat(Utils.DATE_FORMAT)
|
||||||
|
.locale("en").active(true).activationDate(DEFAULT_DATE);
|
||||||
|
Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, request);
|
||||||
|
assertNotNull(clientId);
|
||||||
|
|
||||||
|
GetClientsClientIdResponse client = ClientHelper.getClient(requestSpec, responseSpec, clientId);
|
||||||
|
assertNotNull(client);
|
||||||
|
assertEquals(fullName, client.getDisplayName());
|
||||||
|
|
||||||
|
request = new PostClientsRequest().officeId(1).legalFormId(LEGALFORM_ID_PERSON).fullname(fullName)
|
||||||
|
.externalId(UUID.randomUUID().toString()).dateFormat(Utils.DATE_FORMAT).locale("en").active(true)
|
||||||
|
.activationDate(DEFAULT_DATE);
|
||||||
|
clientId = ClientHelper.createClient(requestSpec, responseSpec, request);
|
||||||
|
assertNotNull(clientId);
|
||||||
|
|
||||||
|
client = ClientHelper.getClient(requestSpec, responseSpec, clientId);
|
||||||
|
assertNotNull(client);
|
||||||
|
assertEquals(fullName, client.getDisplayName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user