Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ccls-2061): update mapper to default all booleans to false #26

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions caab-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,13 @@ components:
type: 'string'
new_entry:
type: 'boolean'
default: true
lsc_resource_id:
type: 'string'
resource_name:
type: 'string'
submitted:
type: 'boolean'
default: 'true'
audit_trail:
$ref: "#/components/schemas/auditDetail"
baseClient:
Expand Down Expand Up @@ -1299,7 +1299,6 @@ components:
type: 'string'
lead_proceeding_ind:
type: 'boolean'
default: false
lar_scope:
type: 'string'
granted_using_devolved_powers:
Expand Down Expand Up @@ -1455,7 +1454,6 @@ components:
type: 'boolean'
app_mode:
type: 'boolean'
default: true
amendment:
type: 'boolean'
award:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface ApplicationMapper {
@Mapping(target = "clientFirstName", source = "client.firstName")
@Mapping(target = "clientSurname", source = "client.surname")
@Mapping(target = "clientReference", source = "client.reference")
@Mapping(target = "costLimitChanged", source = "costLimit.changed", defaultValue = "false")
@Mapping(target = "costLimitChanged", source = "costLimit.changed")
@Mapping(target = "costLimitAtTimeOfMerits", source = "costLimit.limitAtTimeOfMerits")
@Mapping(target = "applicationType", source = "applicationType.id")
@Mapping(target = "applicationTypeDisplayValue", source = "applicationType.displayValue")
Expand All @@ -64,16 +64,11 @@ public interface ApplicationMapper {
source = "applicationType.devolvedPowers.dateUsed")
@Mapping(target = "devolvedPowersContractFlag",
source = "applicationType.devolvedPowers.contractFlag")
@Mapping(target = "meritsReassessmentReqdInd", source = "meritsReassessmentRequired",
defaultValue = "false")
@Mapping(target = "leadProceedingChangedOpaInput", source = "leadProceedingChanged",
defaultValue = "false")
@Mapping(target = "meansAssessmentAmended", source = "meansAssessmentAmended",
defaultValue = "false")
@Mapping(target = "meritsAssessmentAmended", source = "meritsAssessmentAmended",
defaultValue = "false")
@Mapping(target = "amendment", source = "amendment",
defaultValue = "false")
@Mapping(target = "meritsReassessmentReqdInd", source = "meritsReassessmentRequired")
@Mapping(target = "leadProceedingChangedOpaInput", source = "leadProceedingChanged")
@Mapping(target = "meansAssessmentAmended", source = "meansAssessmentAmended")
@Mapping(target = "meritsAssessmentAmended", source = "meritsAssessmentAmended")
@Mapping(target = "amendment", source = "amendment")
@Mapping(target = "costs", source = "costs", qualifiedByName = "toCostStructure")
@Mapping(target = "correspondenceAddress", source = "correspondenceAddress",
qualifiedByName = "toAddress")
Expand Down Expand Up @@ -138,7 +133,7 @@ default void setParentInChildEntities(@MappingTarget Application application) {
@Mapping(target = "status", source = "status.id")
@Mapping(target = "displayStatus", source = "status.displayValue")
@Mapping(target = "typeOfOrder", source = "typeOfOrder.id")
@Mapping(target = "leadProceedingInd", source = "leadProceedingInd", defaultValue = "false")
@Mapping(target = "leadProceedingInd", source = "leadProceedingInd")
Proceeding toProceeding(uk.gov.laa.ccms.caab.model.Proceeding proceeding);

@InheritInverseConfiguration(name = "toProceeding")
Expand Down Expand Up @@ -178,9 +173,9 @@ uk.gov.laa.ccms.caab.model.ScopeLimitation toScopeLimitationModel(
@Mapping(target = "auditTrail", ignore = true)
@Mapping(target = "address", source = "address", qualifiedByName = "toAddress")
@Mapping(target = "appMode", source = "appMode", defaultValue = "true")
@Mapping(target = "amendment", source = "amendment", defaultValue = "false")
@Mapping(target = "award", source = "award", defaultValue = "false")
@Mapping(target = "sharedInd", source = "sharedInd", defaultValue = "false")
@Mapping(target = "amendment", source = "amendment")
@Mapping(target = "award", source = "award")
@Mapping(target = "sharedInd", source = "sharedInd")
@Mapping(target = "deleteInd", source = "deleteInd", defaultValue = "true")
Opponent toOpponent(uk.gov.laa.ccms.caab.model.Opponent opponent);

Expand Down Expand Up @@ -228,6 +223,7 @@ void updateOpponent(
@InheritInverseConfiguration(name = "toCostStructure")
uk.gov.laa.ccms.caab.model.CostStructure toCostStructureModel(CostStructure costs);

@Mapping(target = "newEntry", source = "newEntry", defaultValue = "true")
@Mapping(target = "auditTrail", ignore = true)
CostEntry toCostEntry(uk.gov.laa.ccms.caab.model.CostEntry costEntry);

Expand Down Expand Up @@ -377,4 +373,13 @@ void updateScopeLimitation(
BaseApplication toBaseApplication(Application application);

ApplicationDetails toApplicationDetails(Page<Application> application);

/**
* Global mapper to default Booleans to FALSE in the case of a null source value.
* @param flag - the source value
* @return the source value, or FALSE.
*/
default Boolean toBoolean(Boolean flag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS it worth moving this to a separate mapper, which the application mapper inherits/uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved

return flag != null ? flag : Boolean.FALSE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void testApplicationMapping() {
}

@Test
public void testApplicationMapping_unsetBooleansFalse() {
public void testApplicationMapping_nullBooleansDefaultCorrectly() {
ApplicationDetail detail = new ApplicationDetail();

Application application = mapper.toApplication(detail);
Expand Down Expand Up @@ -273,6 +273,7 @@ public void testProceedingMapping_checkBooleanDefaults() {

Proceeding proceeding = mapper.toProceeding(proceedingModel);
assertFalse(proceeding.getLeadProceedingInd());
assertFalse(proceeding.getEdited());
}

@Test
Expand Down Expand Up @@ -426,11 +427,13 @@ public void testToScopeLimitation() {

@Test
public void testToScopeLimitation_checkBooleanDefaults() {
uk.gov.laa.ccms.caab.model.ScopeLimitation scopeLimitationModel = new uk.gov.laa.ccms.caab.model.ScopeLimitation();
uk.gov.laa.ccms.caab.model.ScopeLimitation scopeLimitationModel =
new uk.gov.laa.ccms.caab.model.ScopeLimitation();

ScopeLimitation scopeLimitation = mapper.toScopeLimitation(scopeLimitationModel);

assertFalse(scopeLimitation.getDelegatedFuncApplyInd());
assertFalse(scopeLimitation.getDefaultInd());
}

@Test
Expand Down Expand Up @@ -513,7 +516,6 @@ public void testToOpponent() {
public void testToOpponent_checkBooleanDefaults() {
uk.gov.laa.ccms.caab.model.Opponent opponentDetail =
new uk.gov.laa.ccms.caab.model.Opponent();
opponentDetail.setAppMode(null);

Opponent opponent = mapper.toOpponent(opponentDetail);

Expand Down Expand Up @@ -627,7 +629,8 @@ public void testToLinkedCaseModel_null() {

@Test
public void testAddressMapping() {
uk.gov.laa.ccms.caab.model.Address detailAddress = new uk.gov.laa.ccms.caab.model.Address();
uk.gov.laa.ccms.caab.model.Address detailAddress =
new uk.gov.laa.ccms.caab.model.Address();
detailAddress.setNoFixedAbode(true);
detailAddress.setPostcode("12345");
detailAddress.setHouseNameOrNumber("House 123");
Expand Down
Loading