Search in sources :

Example 6 with DefaultColumn

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);
        }
    }
}
Also used : DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) LongArray(org.scijava.util.LongArray) TableDataColumn(omero.gateway.model.TableDataColumn) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Example 7 with DefaultColumn

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));
        }
    }
}
Also used : DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) TableDataColumn(omero.gateway.model.TableDataColumn) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Aggregations

DefaultColumn (net.imagej.table.DefaultColumn)7 GenericTable (net.imagej.table.GenericTable)6 TableData (omero.gateway.model.TableData)6 Test (org.junit.Test)6 Verifications (mockit.Verifications)3 DefaultGenericTable (net.imagej.table.DefaultGenericTable)3 TableDataColumn (omero.gateway.model.TableDataColumn)3 DoubleArray (org.scijava.util.DoubleArray)3 BoolColumn (net.imagej.table.BoolColumn)2 LongArray (org.scijava.util.LongArray)2 DoubleColumn (net.imagej.table.DoubleColumn)1 LongColumn (net.imagej.table.LongColumn)1 ROIData (omero.gateway.model.ROIData)1 RoiI (omero.model.RoiI)1 ByteArray (org.scijava.util.ByteArray)1 FloatArray (org.scijava.util.FloatArray)1 IntArray (org.scijava.util.IntArray)1