No logs if null zone id in other-field; smaller logs if invalid zone (shouldn't really need stack)

This commit is contained in:
2024-04-17 17:04:20 -05:00
parent af3c0cd041
commit 34b5da78eb
2 changed files with 51 additions and 11 deletions

View File

@ -36,6 +36,7 @@ import com.kingsrook.qqq.backend.core.utils.TestUtils;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
/*******************************************************************************
@ -100,6 +101,28 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testBadZoneIdFromOtherField()
{
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", Instant.parse("2024-04-04T19:12:00Z")).withValue("timeZone", "fail");
ValueBehaviorApplier.applyFieldBehaviors(ValueBehaviorApplier.Action.FORMATTING, qInstance, table, List.of(record), null);
assertNull(record.getDisplayValue("createDate"));
record = new QRecord().withValue("createDate", Instant.parse("2024-04-04T19:12:00Z")).withValue("timeZone", null);
ValueBehaviorApplier.applyFieldBehaviors(ValueBehaviorApplier.Action.FORMATTING, qInstance, table, List.of(record), null);
assertNull(record.getDisplayValue("createDate"));
}
/*******************************************************************************
**