Search in sources :

Example 1 with ImageI

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

Aggregations

GenericTable (net.imagej.table.GenericTable)1 ImageData (omero.gateway.model.ImageData)1 TableData (omero.gateway.model.TableData)1 TableDataColumn (omero.gateway.model.TableDataColumn)1 ImageI (omero.model.ImageI)1 Test (org.junit.Test)1