Avoid NPE; just noop

This commit is contained in:
2024-04-18 15:43:44 -05:00
parent d40a466d16
commit 66cf485c41
2 changed files with 37 additions and 6 deletions

View File

@ -101,6 +101,7 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
}
/*******************************************************************************
**
*******************************************************************************/
@ -124,6 +125,25 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
/*******************************************************************************
**
*******************************************************************************/
@Test
void testNullValue()
{
QInstance qInstance = QContext.getQInstance();
QTableMetaData table = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY);
table.withField(new QFieldMetaData("timeZone", QFieldType.STRING));
table.getField("createDate").withBehavior(new DateTimeDisplayValueBehavior().withZoneIdFromFieldName("timeZone"));
QRecord record = new QRecord().withValue("createDate", null).withValue("timeZone", "UTC");
ValueBehaviorApplier.applyFieldBehaviors(ValueBehaviorApplier.Action.FORMATTING, qInstance, table, List.of(record), null);
assertNull(record.getDisplayValue("createDate"));
}
/*******************************************************************************
**
*******************************************************************************/
@ -131,8 +151,8 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
void testValidation()
{
QInstance qInstance = QContext.getQInstance();
QTableMetaData table = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY);
QFieldMetaData field = table.getField("createDate");
QTableMetaData table = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY);
QFieldMetaData field = table.getField("createDate");
table.withField(new QFieldMetaData("timeZone", QFieldType.STRING));
Function<Consumer<DateTimeDisplayValueBehavior>, List<String>> testOne = setup ->