mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Fixed pre-delete warning check
This commit is contained in:
@ -151,7 +151,7 @@ public class DeleteAction
|
|||||||
recordsWithValidationErrors.add(record);
|
recordsWithValidationErrors.add(record);
|
||||||
primaryKeysToRemoveFromInput.add(record.getValue(primaryKeyField));
|
primaryKeysToRemoveFromInput.add(record.getValue(primaryKeyField));
|
||||||
}
|
}
|
||||||
else
|
else if(CollectionUtils.nullSafeHasContents(record.getWarnings()))
|
||||||
{
|
{
|
||||||
recordsWithValidationWarnings.add(record);
|
recordsWithValidationWarnings.add(record);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,27 @@ class AbstractPreDeleteCustomizerTest extends BaseTest
|
|||||||
getOutput = new GetAction().execute(getInput);
|
getOutput = new GetAction().execute(getInput);
|
||||||
assertNull(getOutput.getRecord());
|
assertNull(getOutput.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// try a delete that the pre-customizer should warn about //
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
{
|
||||||
|
DeleteInput deleteInput = new DeleteInput();
|
||||||
|
deleteInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||||
|
deleteInput.setPrimaryKeys(List.of(3));
|
||||||
|
DeleteOutput deleteOutput = new DeleteAction().execute(deleteInput);
|
||||||
|
assertEquals(0, deleteOutput.getRecordsWithErrors().size());
|
||||||
|
assertEquals(1, deleteOutput.getRecordsWithWarnings().size());
|
||||||
|
assertEquals(3, deleteOutput.getRecordsWithWarnings().get(0).getValue("id"));
|
||||||
|
assertEquals(1, deleteOutput.getDeletedRecordCount());
|
||||||
|
assertEquals("It was a bad idea to delete Bart", deleteOutput.getRecordsWithWarnings().get(0).getWarnings().get(0));
|
||||||
|
|
||||||
|
GetInput getInput = new GetInput();
|
||||||
|
getInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||||
|
getInput.setPrimaryKey(3);
|
||||||
|
GetOutput getOutput = new GetAction().execute(getInput);
|
||||||
|
assertNull(getOutput.getRecord());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,6 +129,10 @@ class AbstractPreDeleteCustomizerTest extends BaseTest
|
|||||||
{
|
{
|
||||||
record.addError("You may not delete a Homer.");
|
record.addError("You may not delete a Homer.");
|
||||||
}
|
}
|
||||||
|
else if(record.getValue("firstName").equals("Bart"))
|
||||||
|
{
|
||||||
|
record.addWarning("It was a bad idea to delete Bart");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (records);
|
return (records);
|
||||||
|
Reference in New Issue
Block a user