Entity tests
There was no current use of warnings in entity tests that I could easily "improve", so for now I use a slightly contrived example. (This is slightly contrived, because Installation is a special record, and the change below is not actually allowed in the application do to some records on the Adjustment Type table, and a valdiation on Installation.)
public void testChangeBillSegmentFreeze() {
Installation installation = getValidTestObject();
Installation_DTO instDto = (Installation_DTO) installation.getDTO();
instDto.setBillSegmentFreezeOption
(BillSegmentFreezeOptionLookup.FREEZE_AT_WILL);
installation.setDTO(instDto);
instDto.setBillSegmentFreezeOption
(BillSegmentFreezeOptionLookup.FREEZE_AT_BILL_COMPLETION);
installation.setDTO(instDto);
verifyWarningsContain
(MessageRepository.changeBillSegmentFreezeWarning());
}
Again, by default warnings are enabled, so nothing need be stated at the outset. Additionally, the conversion of warnings to an exception occurs at a later point, so there is no ApplicationWarning to catch. Instead, after the offending statement (in this case the setDTO method) you should just verify that the current warnings contain the specified message.
Parent topic