From 35fe004c377ceac3bde4b8515df2d6240ff0095a Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 1 Sep 2023 12:42:26 +0100 Subject: [PATCH 1/3] Add more tests --- .../integration/gateway/LoadFacilityTest.java | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java index 588f9893cef..8ae6ca65d00 100644 --- a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java +++ b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java @@ -41,6 +41,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; +import java.util.Set; /** * @@ -74,18 +76,36 @@ public void testGetDataset() throws DSOutOfServiceException, DSAccessException { Assert.assertEquals(obj.getName(), this.ds.getName()); } + @Test + public void testGetDatasetsForPlate() throws DSOutOfServiceException, DSAccessException { + DatasetData obj = this.loadFacility.getDatasets(this.ctx, this.proj.getId()).iterator().next(); + Assert.assertEquals(obj.getName(), this.ds.getName()); + } + @Test public void testGetImage() throws DSOutOfServiceException, DSAccessException { ImageData obj = this.loadFacility.getImage(this.ctx, this.img.getId()); Assert.assertEquals(obj.getName(), this.img.getName()); } + @Test + public void testGetImagesForDataset() throws DSOutOfServiceException, DSAccessException { + ImageData obj = this.loadFacility.getImages(this.ctx, this.ds.getId()).iterator().next(); + Assert.assertEquals(obj.getName(), this.img.getName()); + } + @Test public void testGetPlate() throws DSOutOfServiceException, DSAccessException { PlateData obj = this.loadFacility.getPlate(this.ctx, this.plate.getId()); Assert.assertEquals(obj.getName(), this.plate.getName()); } + @Test + public void testGetPlatesForScreen() throws DSOutOfServiceException, DSAccessException { + PlateData obj = this.loadFacility.getPlates(this.ctx, this.screen.getId()).iterator().next(); + Assert.assertEquals(obj.getName(), this.plate.getName()); + } + @Test public void testGetProject() throws DSOutOfServiceException, DSAccessException { ProjectData obj = this.loadFacility.getProject(this.ctx, this.proj.getId()); @@ -107,19 +127,34 @@ public void testGetWell() throws DSOutOfServiceException, DSAccessException { Assert.assertEquals(obj.getWellSamples().get(0).getImage().getId(), test.getWellSamples().get(0).getImage().getId()); } + + @Test + public void testGetWellsForPlate() throws DSOutOfServiceException, DSAccessException { + Set test = new HashSet<>(); + for (WellData w : this.plate.getWells()) { + String key = w.getColumn()+"|"+w.getRow()+"|"+w.getId(); + test.add(key); + } + for (WellData w : this.loadFacility.getWells(this.ctx, this.plate.getId())) { + String key = w.getColumn()+"|"+w.getRow()+"|"+w.getId(); + Assert.assertTrue(test.contains(key)); + test.remove(key); + } + Assert.assertTrue(test.isEmpty()); + } private void initData() throws Exception { this.group = createGroup(); this.user = createExperimenter(group); this.ctx = new SecurityContext(group.getId()); - this.img = createImage(ctx, null); - this.proj = createProject(ctx); - this.ds = createDataset(ctx, null); + this.ds = createDataset(ctx, proj); + this.img = createImage(ctx, ds); + this.screen = createScreen(ctx); this.plate = createPlateWithWells(ctx, screen); - + System.out.println("ID: "+this.plate.getId()); this.wellIds = new ArrayList(); Plate p = this.plate.asPlate(); for (Well w : p.copyWells()) { From be4e970509c01a2fd5744b56787044f78dff454a Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 1 Sep 2023 12:49:26 +0100 Subject: [PATCH 2/3] Remove some unused impoprts --- .../OmeroJava/test/integration/gateway/LoadFacilityTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java index 8ae6ca65d00..4224bedc9f2 100644 --- a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java +++ b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java @@ -23,7 +23,6 @@ import omero.gateway.SecurityContext; import omero.gateway.exception.DSAccessException; import omero.gateway.exception.DSOutOfServiceException; -import omero.gateway.facility.BrowseFacility; import omero.gateway.model.DatasetData; import omero.gateway.model.ExperimenterData; import omero.gateway.model.GroupData; @@ -39,8 +38,6 @@ import org.testng.annotations.Test; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.Set; From 1ebe0fad76686c08afaca88e5790332455e2e6f0 Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 1 Sep 2023 14:32:47 +0100 Subject: [PATCH 3/3] Remove print out --- .../OmeroJava/test/integration/gateway/LoadFacilityTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java index 4224bedc9f2..b87d7fb2c8e 100644 --- a/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java +++ b/components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java @@ -151,7 +151,6 @@ private void initData() throws Exception { this.screen = createScreen(ctx); this.plate = createPlateWithWells(ctx, screen); - System.out.println("ID: "+this.plate.getId()); this.wellIds = new ArrayList(); Plate p = this.plate.asPlate(); for (Well w : p.copyWells()) {