Skip to content

Commit e0619f6

Browse files
authored
AYS-221 | Validations of EmergencyEvacuationApplicationRequest Have Been Fixed (#324)
1 parent 344f11d commit e0619f6

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/main/java/org/ays/common/model/request/AysPhoneNumberRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import jakarta.validation.constraints.NotBlank;
44
import lombok.Getter;
55
import lombok.Setter;
6+
import org.apache.commons.lang3.StringUtils;
67
import org.ays.common.util.AysJsonUtil;
78
import org.ays.common.util.validation.PhoneNumber;
89

@@ -34,8 +35,8 @@ public String toString() {
3435
return AysJsonUtil.toJson(this);
3536
}
3637

37-
public boolean isEmpty() {
38-
return this.countryCode == null && this.lineNumber == null;
38+
public boolean isBlank() {
39+
return StringUtils.isBlank(this.countryCode) && StringUtils.isBlank(this.lineNumber);
3940
}
4041

4142
}

src/main/java/org/ays/common/util/validation/NameValidator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NameValidator implements ConstraintValidator<Name, String> {
2424
* </p>
2525
* <p>
2626
*/
27-
private static final String NAME_REGEX = "^(?![^a-zA-ZÇçĞğİıÖöŞşÜü]).*[a-zA-ZÇçĞğİıÖöŞşÜü ,.'-]+$";
27+
private static final String NAME_REGEX = "^(?![^a-zA-ZÇçĞğİıÖöŞşÜü])[a-zA-ZÇçĞğİıÖöŞşÜü ,.'-]*$";
2828
private static final Integer NAME_MIN_LENGTH = 2;
2929
private static final Integer NAME_MAX_LENGTH = 100;
3030

@@ -45,6 +45,8 @@ class NameValidator implements ConstraintValidator<Name, String> {
4545
* <li>Ahmet?*</li>
4646
* <li>Mehmet!</li>
4747
* <li>A</li>
48+
* <li>123</li>
49+
* <li>Mary*land</li>
4850
* </ul>
4951
*
5052
* @param value object to validate

src/main/java/org/ays/emergency_application/model/request/EmergencyEvacuationApplicationRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ private boolean isAllApplicantFieldsFilled() {
7878
return true;
7979
}
8080

81-
return !StringUtils.isEmpty(this.applicantFirstName) && !StringUtils.isEmpty(this.applicantLastName)
81+
return !StringUtils.isBlank(this.applicantFirstName) && !StringUtils.isBlank(this.applicantLastName)
8282
&&
83-
this.applicantPhoneNumber != null && !this.applicantPhoneNumber.isEmpty();
83+
this.applicantPhoneNumber != null && !this.applicantPhoneNumber.isBlank();
8484
}
8585

8686
@JsonIgnore

src/test/java/org/ays/emergency_application/controller/EmergencyEvacuationApplicationControllerTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenPhoneNumberIsNotValid
571571
@ParameterizedTest
572572
@ValueSource(strings = {
573573
"",
574+
"Mary*land",
575+
"Mary$land",
576+
"CityName$",
574577
"Invalid with special characters: #$%",
575578
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
576579
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
@@ -606,6 +609,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenSourceCityIsNotValid_
606609
@ParameterizedTest
607610
@ValueSource(strings = {
608611
"",
612+
"Mary*land",
613+
"Mary$land",
614+
"CityName$",
609615
"Invalid with special characters: #$%",
610616
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
611617
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
@@ -697,6 +703,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenAddressIsNotValid_the
697703
@ParameterizedTest
698704
@ValueSource(strings = {
699705
"",
706+
"Mary*land",
707+
"Mary$land",
708+
"CityName$",
700709
"Invalid with special characters: #$%",
701710
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
702711
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
@@ -732,6 +741,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenTargetCityIsNotValid_
732741
@ParameterizedTest
733742
@ValueSource(strings = {
734743
"",
744+
"Mary*land",
745+
"Mary$land",
746+
"CityName$",
735747
"Invalid with special characters: #$%",
736748
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
737749
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
@@ -740,7 +752,7 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenTargetCityIsNotValid_
740752
"151201485621548562154851458614125461254125412",
741753
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam In hac habitasse platea dictumst. Nullam in turpis at nunc ultrices.",
742754
})
743-
void givenInvalidEmergencyEvacuationApplicationRequest_whenSourceTargetIsNotValid_thenReturnValidationError(String targetDistrict) throws Exception {
755+
void givenInvalidEmergencyEvacuationApplicationRequest_whenTargetDistrictIsNotValid_thenReturnValidationError(String targetDistrict) throws Exception {
744756
// Given
745757
EmergencyEvacuationApplicationRequest mockApplicationRequest = new EmergencyEvacuationRequestBuilder()
746758
.withValidValues()
@@ -766,6 +778,7 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenSourceTargetIsNotVali
766778

767779
@ParameterizedTest
768780
@ValueSource(strings = {
781+
" ",
769782
"Invalid with special characters: #$%",
770783
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
771784
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
@@ -800,6 +813,7 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenApplicantFirstNameIsN
800813

801814
@ParameterizedTest
802815
@ValueSource(strings = {
816+
" ",
803817
"Invalid with special characters: #$%",
804818
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
805819
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",

0 commit comments

Comments
 (0)