Avoid NPE on empty input record

This commit is contained in:
2025-06-02 14:48:59 -05:00
parent 369d501071
commit 44e091a1bc
2 changed files with 13 additions and 1 deletions

View File

@ -94,7 +94,7 @@ public class QRecordApiAdapter
for(QRecord record : records) for(QRecord record : records)
{ {
ApiOutputMapWrapper apiOutputMap = qRecordToApiMap(record, tableName, apiName, apiVersion, fieldValueMappers, new ApiOutputMapWrapper(new LinkedHashMap<>())); ApiOutputMapWrapper apiOutputMap = qRecordToApiMap(record, tableName, apiName, apiVersion, fieldValueMappers, new ApiOutputMapWrapper(new LinkedHashMap<>()));
rs.add(apiOutputMap.getContents()); rs.add(apiOutputMap == null ? null : apiOutputMap.getContents());
} }
return (rs); return (rs);

View File

@ -39,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -48,6 +49,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class QRecordApiAdapterTest extends BaseTest class QRecordApiAdapterTest extends BaseTest
{ {
/*******************************************************************************
**
*******************************************************************************/
@Test
void testNullInputRecord() throws QException
{
assertNull(QRecordApiAdapter.qRecordToApiMap(null, TestUtils.TABLE_NAME_PERSON, TestUtils.API_NAME, TestUtils.V2022_Q4));
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/