Search in sources :

Example 16 with TableData

use of omero.gateway.model.TableData in project imagej-omero by imagej.

the class UploadTableTest method testDoubleArrayTable.

@Test
public void testDoubleArrayTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final GenericTable table = new DefaultGenericTable();
    final DefaultColumn<DoubleArray> ij0 = new DefaultColumn<>(DoubleArray.class, "H1");
    final DefaultColumn<DoubleArray> ij1 = new DefaultColumn<>(DoubleArray.class, "H2");
    ij0.add(new DoubleArray(new double[] { 0.5, 0.25, 0.125 }));
    ij1.add(new DoubleArray(new double[] { -0.125, -0.0625, 0.03125 }));
    table.add(ij0);
    table.add(ij1);
    // Create expectations
    setUpMethodCalls();
    final long id = service.uploadTable(credentials, "table", table, 0);
    assertEquals(id, -1);
    // NB: Can only capture in a Verifications block
    new Verifications() {

        {
            TableData td;
            tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
            tableEquals(table, td, Double[].class);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) DoubleArray(org.scijava.util.DoubleArray) Test(org.junit.Test)

Example 17 with TableData

use of omero.gateway.model.TableData in project imagej-omero by imagej.

the class UploadTableTest method testLongTable.

@Test
public void testLongTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final LongTable table = new DefaultLongTable(2, 2);
    table.get(0).fill(new long[] { 9223372036854775807l, 0 });
    table.get(1).fill(new long[] { -9223372036854775808l, 4 });
    // Create expectations
    setUpMethodCalls();
    final long id = service.uploadTable(credentials, "table", table, 0);
    assertEquals(id, -1);
    // NB: Can only capture in a Verifications block
    new Verifications() {

        {
            TableData td;
            tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
            tableEquals(table, td, Long.class);
        }
    };
}
Also used : DefaultLongTable(net.imagej.table.DefaultLongTable) LongTable(net.imagej.table.LongTable) DefaultLongTable(net.imagej.table.DefaultLongTable) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Example 18 with TableData

use of omero.gateway.model.TableData in project imagej-omero by imagej.

the class UploadTableTest method testShortTable.

@Test
public void testShortTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final ShortTable table = new DefaultShortTable(6, 3);
    table.get(0).fill(new short[] { -32768, 0, 32767 });
    table.get(1).fill(new short[] { 12, -12, 5 });
    table.get(2).fill(new short[] { 10000, 20000, -30000 });
    table.get(3).fill(new short[] { 1111, 2222, 8888 });
    table.get(4).fill(new short[] { -4, -17, -31194 });
    table.get(5).fill(new short[] { 0, 17239, -20 });
    // Create expectations
    setUpMethodCalls();
    final long id = service.uploadTable(credentials, "table", table, 0);
    assertEquals(id, -1);
    // NB: Can only capture in a Verifications block
    new Verifications() {

        {
            TableData td;
            tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
            tableEquals(table, td, Long.class);
        }
    };
}
Also used : ShortTable(net.imagej.table.ShortTable) DefaultShortTable(net.imagej.table.DefaultShortTable) DefaultShortTable(net.imagej.table.DefaultShortTable) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Example 19 with TableData

use of omero.gateway.model.TableData in project imagej-omero by imagej.

the class UploadTableTest method testMixedTable.

@Test
public void testMixedTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final GenericTable table = new DefaultGenericTable();
    final BoolColumn ijc0 = new BoolColumn("h0");
    final DoubleColumn ijc1 = new DoubleColumn("h1");
    final DefaultColumn<String> ijc2 = new DefaultColumn<>(String.class, "h2");
    final DefaultColumn<IntArray> ijc3 = new DefaultColumn<>(IntArray.class, "h3");
    final OMERORefColumn ijc4 = new OMERORefColumn("h4", OMERORef.ROI);
    ijc0.fill(new boolean[] { true, false });
    ijc1.fill(new double[] { 0.03125, -2134.5 });
    ijc2.add("abc");
    ijc2.add("123");
    ijc3.add(new IntArray(new int[] { 9012, 1294 }));
    ijc3.add(new IntArray(new int[] { -4123, -9 }));
    ijc4.fill(new long[] { 2314, 1234 });
    ijc4.setOriginalData(new Object[] { new ROIData(new RoiI(2314, true)), new ROIData(new RoiI(1234, true)) });
    table.add(ijc0);
    table.add(ijc1);
    table.add(ijc2);
    table.add(ijc3);
    table.add(ijc4);
    // Create expectations
    setUpMethodCalls();
    final long id = service.uploadTable(credentials, "table", table, 0);
    assertEquals(id, -1);
    // NB: Can only capture in a Verifications block
    new Verifications() {

        {
            TableData td;
            tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
            tableEquals(table, td, Boolean.class, Double.class, String.class, Long[].class, ROIData.class);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) BoolColumn(net.imagej.table.BoolColumn) DefaultColumn(net.imagej.table.DefaultColumn) ROIData(omero.gateway.model.ROIData) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) Verifications(mockit.Verifications) DoubleColumn(net.imagej.table.DoubleColumn) IntArray(org.scijava.util.IntArray) RoiI(omero.model.RoiI) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Example 20 with TableData

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

Aggregations

TableData (omero.gateway.model.TableData)23 Test (org.junit.Test)17 Verifications (mockit.Verifications)9 GenericTable (net.imagej.table.GenericTable)9 TableDataColumn (omero.gateway.model.TableDataColumn)9 DefaultColumn (net.imagej.table.DefaultColumn)6 DefaultGenericTable (net.imagej.table.DefaultGenericTable)4 TablesFacility (omero.gateway.facility.TablesFacility)4 ImageData (omero.gateway.model.ImageData)3 BoolColumn (net.imagej.table.BoolColumn)2 BoolTable (net.imagej.table.BoolTable)2 LongTable (net.imagej.table.LongTable)2 DataObject (omero.gateway.model.DataObject)2 DoubleArray (org.scijava.util.DoubleArray)2 HashMap (java.util.HashMap)1 Expectations (mockit.Expectations)1 DefaultOMEROSession (net.imagej.omero.DefaultOMEROSession)1 OMEROCredentials (net.imagej.omero.OMEROCredentials)1 OMEROSession (net.imagej.omero.OMEROSession)1 ByteTable (net.imagej.table.ByteTable)1