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);
}
};
}
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);
}
};
}
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);
}
};
}
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);
}
};
}
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));
}
}
}
Aggregations