use of net.imagej.table.DefaultColumn in project imagej-omero by imagej.
the class DownloadTableTest method downloadLongArrayTable.
@SuppressWarnings("unchecked")
@Test
public void downloadLongArrayTable() throws PermissionDeniedException, CannotCreateSessionException, ServerError, DSOutOfServiceException, ExecutionException, DSAccessException {
// Setup OMERO data structures
final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, Long[].class), new TableDataColumn("Header 2", 1, Long[].class) };
final Object[][] data = new Object[2][];
data[0] = new Long[][] { { 0l, -9223372036854775808l }, { 134l, 9223372036854775807l } };
data[1] = new Long[][] { { -2139847l, 1023894l }, { 12l, 23415l } };
final TableData table = new TableData(tdc, data);
table.setNumberOfRows(2);
// Create expectations
setUpMethodCalls(table);
final Table<?, ?> imageJTable = ((DefaultOMEROService) service).downloadTable(credentials, 0);
// Tests
assertTrue(GenericTable.class.isInstance(imageJTable));
assertEquals(imageJTable.getColumnCount(), 2);
assertEquals(imageJTable.getRowCount(), 2);
assertEquals(imageJTable.get(0).size(), 2);
assertEquals(imageJTable.getColumnHeader(0), "Header 1");
assertEquals(imageJTable.getColumnHeader(1), "Header 2");
for (int r = 0; r < imageJTable.getRowCount(); r++) {
for (int c = 0; c < imageJTable.getColumnCount(); c++) {
assertTrue(DefaultColumn.class.isInstance(imageJTable.get(c)));
assertTrue(imageJTable.get(c).getType() == LongArray.class);
final Long[] l = (Long[]) data[c][r];
final Object[] ijl = ((DefaultColumn<LongArray>) imageJTable.get(c)).get(r).toArray();
assertArrayEquals(l, ijl);
}
}
}
use of net.imagej.table.DefaultColumn in project imagej-omero by imagej.
the class DownloadTableTest method downloadStringTable.
@Test
@SuppressWarnings("unchecked")
public void downloadStringTable() 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, String.class), new TableDataColumn("Header 3", 2, String.class) };
final Object[][] data = new Object[3][];
data[0] = new String[] { "abc", "123", "hi!" };
data[1] = new String[] { "Good Morning", "Good evening", "good night" };
data[2] = new String[] { "good afternoon", "hey", "hello." };
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));
assertEquals(imageJTable.getColumnCount(), 3);
assertEquals(imageJTable.getRowCount(), 3);
assertEquals(imageJTable.getColumnHeader(0), "Header 1");
assertEquals(imageJTable.getColumnHeader(1), "Header 2");
assertEquals(imageJTable.getColumnHeader(2), "Header 3");
for (int r = 0; r < imageJTable.getRowCount(); r++) {
for (int c = 0; c < imageJTable.getColumnCount(); c++) {
assertTrue(DefaultColumn.class.isInstance(imageJTable.get(c)));
assertTrue(imageJTable.get(c).getType() == String.class);
assertEquals(data[c][r], ((DefaultColumn<String>) imageJTable.get(c)).get(r));
}
}
}
Aggregations