Changeset 6147


Ignore:
Timestamp:
04/20/10 10:36:35 (10 years ago)
Author:
melissa
Message:

Added minimal Plate object and a few tests for Instrument and Plate objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/ome-xml/test/ome/xml/utests/InOut201004Test.java

    r6146 r6147  
    6060import ome.xml.r201004.OME; 
    6161import ome.xml.r201004.Pixels; 
     62import ome.xml.r201004.Plate; 
     63import ome.xml.r201004.Well; 
    6264import ome.xml.r201004.enums.DimensionOrder; 
    6365import ome.xml.r201004.enums.EnumerationException; 
    6466import ome.xml.r201004.enums.LaserType; 
     67import ome.xml.r201004.enums.NamingConvention; 
    6568import ome.xml.r201004.enums.PixelType; 
    6669 
     
    9194  private static String LIGHTSOURCE_ID = "LightSource:0"; 
    9295 
     96  private static String PLATE_ID = "Plate:0"; 
     97 
    9398  private static DimensionOrder dimensionOrder = DimensionOrder.XYZCT; 
    9499 
     
    105110  private static final Integer SIZE_T = 50; 
    106111 
     112  private static final Integer WELL_ROWS = 3; 
     113 
     114  private static final Integer WELL_COLS = 2; 
     115 
     116  private static final NamingConvention WELL_ROW = NamingConvention.LETTER; 
     117 
     118  private static final NamingConvention WELL_COL = NamingConvention.NUMBER; 
     119 
    107120  /** XML namespace. */ 
    108   public static final String XML_NS =  
     121  public static final String XML_NS = 
    109122    "http://www.openmicroscopy.org/Schemas/OME/2010-04"; 
    110123 
     
    125138  @BeforeClass 
    126139  public void setUp() 
    127   throws ParserConfigurationException, TransformerException, EnumerationException { 
     140    throws ParserConfigurationException, TransformerException, 
     141    EnumerationException 
     142  { 
    128143    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
    129144    DocumentBuilder parser = factory.newDocumentBuilder(); 
     
    132147    ome = new OME(); 
    133148    ome.addImage(makeImage()); 
     149    ome.addPlate(makePlate()); 
    134150    ome.addInstrument(makeInstrument()); 
    135151    // Produce a valid OME DOM element hierarchy 
     
    178194    for (Channel channel : pixels.copyChannelList()) { 
    179195      assertNotNull(channel.getID()); 
     196    } 
     197  } 
     198 
     199  @Test(dependsOnMethods={"testValidOMENode"}) 
     200  public void testValidInstrumentNode() { 
     201    Instrument instrument = ome.getInstrument(0); 
     202    assertNotNull(instrument); 
     203    assertEquals(INSTRUMENT_ID, instrument.getID()); 
     204  } 
     205 
     206  @Test(dependsOnMethods={"testValidInstrumentNode"}) 
     207  public void testValidDetectorNode() { 
     208    Detector detector = ome.getInstrument(0).getDetector(0); 
     209    assertNotNull(detector); 
     210    assertEquals(DETECTOR_ID, detector.getID()); 
     211  } 
     212 
     213  @Test(dependsOnMethods={"testValidOMENode"}) 
     214  public void testValidPlateNode() { 
     215    Plate plate = ome.getPlate(0); 
     216    assertNotNull(plate); 
     217    assertEquals(PLATE_ID, plate.getID()); 
     218    assertEquals(plate.getRows(), WELL_ROWS); 
     219    assertEquals(plate.getColumns(), WELL_COLS); 
     220    assertEquals(plate.getRowNamingConvention(), WELL_ROW); 
     221    assertEquals(plate.getColumnNamingConvention(), WELL_COL); 
     222    assertEquals(plate.sizeOfWellList(), WELL_ROWS * WELL_COLS); 
     223    for (Integer row=0; row<WELL_ROWS; row++) { 
     224      for (Integer col=0; col<WELL_COLS; col++) { 
     225        Well well = plate.getWell(row * WELL_COLS + col); 
     226        assertNotNull(well); 
     227        assertEquals(well.getRow(), row); 
     228        assertEquals(well.getColumn(), col); 
     229      } 
    180230    } 
    181231  } 
     
    223273  } 
    224274 
     275  private Plate makePlate() { 
     276    Plate plate = new Plate(); 
     277    plate.setID(PLATE_ID); 
     278    plate.setRows(WELL_ROWS); 
     279    plate.setColumns(WELL_COLS); 
     280    plate.setRowNamingConvention(WELL_ROW); 
     281    plate.setColumnNamingConvention(WELL_COL); 
     282 
     283    for (int row=0; row<WELL_ROWS; row++) { 
     284      for (int col=0; col<WELL_COLS; col++) { 
     285        Well well = new Well(); 
     286        well.setRow(row); 
     287        well.setColumn(col); 
     288        plate.addWell(well); 
     289      } 
     290    } 
     291 
     292    return plate; 
     293  } 
     294 
    225295  private String asString() throws TransformerException { 
    226296    TransformerFactory transformerFactory = 
Note: See TracChangeset for help on using the changeset viewer.