use of net.imagej.table.LongColumn in project imagej-omero by imagej.
the class DownloadTableTest method downloadMixedTable.
@Test
@SuppressWarnings("unchecked")
public void downloadMixedTable() throws PermissionDeniedException, CannotCreateSessionException, ServerError, DSOutOfServiceException, ExecutionException, DSAccessException {
// / Setup OMERO data structures
final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, String.class), new TableDataColumn("Header 2", 1, Boolean.class), new TableDataColumn("Header 3", 2, Double[].class), new TableDataColumn("Header 4", 3, Long.class) };
final Object[][] data = new Object[4][];
data[0] = new String[] { "abc", "123", "hi!" };
data[1] = new Boolean[] { false, true, false };
data[2] = new Double[][] { { 0.125, 3879123.5, -93.25 }, { 0d, -123353.03125, -5.5 }, { 100.25, 0.125, -9000.5 } };
data[3] = new Long[] { -9028131908l, 0l, 12l };
final TableData table = new TableData(tdc, data);
table.setNumberOfRows(3);
// Create expectations
setUpMethodCalls(table);
final Table<?, ?> imageJTable = ((DefaultOMEROService) service).downloadTable(credentials, 0);
// Tests
assertTrue(GenericTable.class.isInstance(imageJTable));
assertTrue(DefaultColumn.class.isInstance(imageJTable.get(0)));
assertTrue(imageJTable.get(0).getType() == String.class);
assertTrue(BoolColumn.class.isInstance(imageJTable.get(1)));
assertTrue(DefaultColumn.class.isInstance(imageJTable.get(2)));
assertTrue(imageJTable.get(2).getType() == DoubleArray.class);
assertTrue(LongColumn.class.isInstance(imageJTable.get(3)));
assertEquals(imageJTable.getColumnCount(), 4);
assertEquals(imageJTable.getRowCount(), 3);
assertEquals(imageJTable.getColumnHeader(0), "Header 1");
assertEquals(imageJTable.getColumnHeader(1), "Header 2");
assertEquals(imageJTable.getColumnHeader(2), "Header 3");
assertEquals(imageJTable.getColumnHeader(3), "Header 4");
for (int r = 0; r < imageJTable.getRowCount(); r++) assertEquals(data[0][r], ((DefaultColumn<String>) imageJTable.get(0)).get(r));
for (int r = 0; r < imageJTable.getRowCount(); r++) assertEquals(data[1][r], ((BoolColumn) imageJTable.get(1)).getValue(r));
for (int r = 0; r < imageJTable.getRowCount(); r++) assertArrayEquals((Double[]) data[2][r], ((DefaultColumn<DoubleArray>) imageJTable.get(2)).get(r).toArray());
for (int r = 0; r < imageJTable.getRowCount(); r++) assertEquals(data[3][r], ((LongColumn) imageJTable.get(3)).getValue(r));
}
Aggregations