-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6342 from dominikl/loadfacility_tests
Add tests for the LoadFacility
- Loading branch information
Showing
4 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
components/tools/OmeroJava/test/integration/gateway/LoadFacilityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
*------------------------------------------------------------------------------ | ||
* Copyright (C) 2023 University of Dundee. All rights reserved. | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
*------------------------------------------------------------------------------ | ||
*/ | ||
package integration.gateway; | ||
|
||
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; | ||
import omero.gateway.model.ImageData; | ||
import omero.gateway.model.PlateData; | ||
import omero.gateway.model.ProjectData; | ||
import omero.gateway.model.ScreenData; | ||
import omero.gateway.model.WellData; | ||
import omero.model.Plate; | ||
import omero.model.Well; | ||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* | ||
* @author Dominik Lindner <a | ||
* href="mailto:[email protected]">[email protected]</a> | ||
*/ | ||
|
||
public class LoadFacilityTest extends GatewayTest { | ||
|
||
private GroupData group; | ||
private ExperimenterData user; | ||
private SecurityContext ctx; | ||
|
||
private ProjectData proj; | ||
private DatasetData ds; | ||
private ScreenData screen; | ||
private PlateData plate; | ||
private ImageData img; | ||
private ArrayList<Long> wellIds; | ||
|
||
@Override | ||
@BeforeClass(alwaysRun = true) | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
initData(); | ||
} | ||
|
||
@Test | ||
public void testGetDataset() throws DSOutOfServiceException, DSAccessException { | ||
DatasetData obj = this.loadFacility.getDataset(this.ctx, this.ds.getId()); | ||
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 testGetPlate() throws DSOutOfServiceException, DSAccessException { | ||
PlateData obj = this.loadFacility.getPlate(this.ctx, this.plate.getId()); | ||
Assert.assertEquals(obj.getName(), this.plate.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetProject() throws DSOutOfServiceException, DSAccessException { | ||
ProjectData obj = this.loadFacility.getProject(this.ctx, this.proj.getId()); | ||
Assert.assertEquals(obj.getName(), this.proj.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetScreen() throws DSOutOfServiceException, DSAccessException { | ||
ScreenData obj = this.loadFacility.getScreen(this.ctx, this.screen.getId()); | ||
Assert.assertEquals(obj.getName(), this.screen.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetWell() throws DSOutOfServiceException, DSAccessException { | ||
WellData test = this.plate.getWells().iterator().next(); | ||
WellData obj = this.loadFacility.getWell(this.ctx, test.getId()); | ||
Assert.assertEquals(obj.getColumn(), test.getColumn()); | ||
Assert.assertEquals(obj.getRow(), test.getRow()); | ||
Assert.assertEquals(obj.getWellSamples().get(0).getImage().getId(), | ||
test.getWellSamples().get(0).getImage().getId()); | ||
} | ||
|
||
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.screen = createScreen(ctx); | ||
this.plate = createPlateWithWells(ctx, screen); | ||
|
||
this.wellIds = new ArrayList<Long>(); | ||
Plate p = this.plate.asPlate(); | ||
for (Well w : p.copyWells()) { | ||
this.wellIds.add(w.getId().getValue()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters