Fix possible null
This commit is contained in:
+17
@@ -99,4 +99,21 @@ public class ReadWriteNonCoreDataServiceImplTest {
|
||||
when(genericDataService.fillResultsetColumnHeaders("table")).thenReturn(Collections.emptyList());
|
||||
assertThrows(PlatformApiDataValidationException.class, () -> underTest.queryDataTable("table", "cf1", "vf1", "rc1,rc2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidDatabase() {
|
||||
SqlRowSet sqlRS = Mockito.mock(SqlRowSet.class);
|
||||
when(jdbcTemplate.queryForRowSet(eq("select rc1,rc2 from table where cf1 = ?"), any(Object[].class), any(int[].class)))
|
||||
.thenReturn(sqlRS);
|
||||
when(sqlRS.next()).thenReturn(true).thenReturn(false);
|
||||
when(sqlRS.getObject(ArgumentMatchers.anyString())).thenReturn("value1").thenReturn("value2");
|
||||
when(databaseTypeResolver.isPostgreSQL()).thenReturn(false);
|
||||
when(databaseTypeResolver.isMySQL()).thenReturn(false);
|
||||
ResultsetColumnHeaderData cf1 = ResultsetColumnHeaderData.detailed("cf1", "text", 10L, false, false, null, null);
|
||||
ResultsetColumnHeaderData rc1 = ResultsetColumnHeaderData.detailed("rc1", "text", 10L, false, false, null, null);
|
||||
ResultsetColumnHeaderData rc2 = ResultsetColumnHeaderData.detailed("rc2", "text", 10L, false, false, null, null);
|
||||
when(genericDataService.fillResultsetColumnHeaders("table")).thenReturn(List.of(cf1, rc1, rc2));
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> underTest.queryDataTable("table", "cf1", "vf1", "rc1,rc2"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user