Skip to content

Commit

Permalink
AYS-661 | Fix emergency evacuation application tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m1erla committed Jan 15, 2025
1 parent 8445f18 commit 06a5c25
Show file tree
Hide file tree
Showing 4 changed files with 482 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import org.ays.common.util.validation.Name;
import org.hibernate.validator.constraints.Range;


/**
* Represents a request to complete emergency evacuation request. The request includes fields for the required user
* information, such as the user's phone number, as well as their first and last name.
* Represents a request to complete emergency evacuation request. The request
* includes fields for the required user
* information, such as the user's phone number, as well as their first and last
* name.
*/
@Getter
@Setter
Expand Down Expand Up @@ -64,7 +65,6 @@ public class EmergencyEvacuationApplicationRequest {
@Size(min = 2, max = 100)
private String targetDistrict;


@Name
@Size(min = 2, max = 100)
private String applicantFirstName;
Expand All @@ -76,22 +76,25 @@ public class EmergencyEvacuationApplicationRequest {
@Valid
private AysPhoneNumberRequest applicantPhoneNumber;

@NotNull
private Boolean hasObstaclePersonExist;

@JsonIgnore
@AssertTrue(message = "all applicant fields must be filled")
@SuppressWarnings("This method is unused by the application directly but Spring is using it in the background.")
private boolean isAllApplicantFieldsFilled() {

if (StringUtils.isEmpty(this.applicantFirstName) && StringUtils.isEmpty(this.applicantLastName) && this.applicantPhoneNumber == null) {
if (StringUtils.isEmpty(this.applicantFirstName) && StringUtils.isEmpty(this.applicantLastName)
&& this.applicantPhoneNumber == null) {
return true;
}


return !StringUtils.isBlank(this.applicantFirstName) && !StringUtils.isBlank(this.applicantLastName)
&&
this.applicantPhoneNumber != null
&&
!(StringUtils.isBlank(this.applicantPhoneNumber.getCountryCode()) && StringUtils.isBlank(this.applicantPhoneNumber.getLineNumber()));
!(StringUtils.isBlank(this.applicantPhoneNumber.getCountryCode())
&& StringUtils.isBlank(this.applicantPhoneNumber.getLineNumber()));
}

@JsonIgnore
Expand All @@ -103,7 +106,8 @@ private boolean isPhoneNumberMustNotBeSameOne() {
return true;
}

if (StringUtils.isEmpty(this.applicantPhoneNumber.getLineNumber()) || StringUtils.isEmpty(this.phoneNumber.getLineNumber())) {
if (StringUtils.isEmpty(this.applicantPhoneNumber.getLineNumber())
|| StringUtils.isEmpty(this.phoneNumber.getLineNumber())) {
return true;
}

Expand All @@ -115,11 +119,12 @@ private boolean isPhoneNumberMustNotBeSameOne() {
@SuppressWarnings("This method is unused by the application directly but Spring is using it in the background.")
private boolean isSourceCityAndDistrictDifferentFromTargetCityAndDistrict() {

if (this.sourceCity == null || this.sourceDistrict == null || this.targetCity == null || this.targetDistrict == null) {
if (this.sourceCity == null || this.sourceDistrict == null || this.targetCity == null
|| this.targetDistrict == null) {
return true;
}
}

if (!this.sourceCity.equalsIgnoreCase(this.targetCity)){
if (!this.sourceCity.equalsIgnoreCase(this.targetCity)) {
return true;
}

Expand Down
Loading

0 comments on commit 06a5c25

Please sign in to comment.