use of omero.gateway.model.TableDataColumn in project imagej-omero by imagej.
the class DownloadTableTest method downloadBoolTable.
@Test
public void downloadBoolTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
// Setup OMERO data structures
final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, Boolean.class), new TableDataColumn("Header 2", 1, Boolean.class), new TableDataColumn("Header 3", 2, Boolean.class) };
final Object[][] data = new Object[3][];
data[0] = new Boolean[] { true, true, true, true, false, false, false, false };
data[1] = new Boolean[] { true, true, false, false, true, true, false, false };
data[2] = new Boolean[] { true, false, true, false, true, false, true, false };
final TableData table = new TableData(tdc, data);
table.setNumberOfRows(8);
setUpMethodCalls(table);
final Table<?, ?> imageJTable = ((DefaultOMEROService) service).downloadTable(credentials, 0);
// Tests
assertTrue(BoolTable.class.isInstance(imageJTable));
assertEquals(imageJTable.getColumnCount(), 3);
assertEquals(imageJTable.getRowCount(), 8);
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++) {
assertEquals(data[c][r], imageJTable.get(c, r));
}
}
}
use of omero.gateway.model.TableDataColumn in project imagej-omero by imagej.
the class DownloadTableTest method downloadRefTable.
@Test
public void downloadRefTable() throws PermissionDeniedException, CannotCreateSessionException, ServerError, DSOutOfServiceException, ExecutionException, DSAccessException {
final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, ImageData.class), new TableDataColumn("Header 2", 1, ImageData.class), new TableDataColumn("Header 3", 2, ImageData.class) };
final Object[][] data = new Object[3][3];
final long[][] ids = new long[][] { { 101, 102, 103 }, { 201, 202, 203 }, { 301, 302, 303 } };
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
data[i][j] = new ImageData(new ImageI(ids[i][j], false));
}
}
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(OMERORefColumn.class.isInstance(imageJTable.get(c)));
assertTrue(imageJTable.get(c).getType() == Long.class);
assertEquals(((OMERORefColumn) imageJTable.get(c)).getOMERORef(), OMERORef.IMAGE);
assertEquals(ids[c][r], ((OMERORefColumn) imageJTable.get(c)).get(r).longValue());
}
}
}
use of omero.gateway.model.TableDataColumn 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 omero.gateway.model.TableDataColumn 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