Changeset 6151


Ignore:
Timestamp:
04/20/10 14:55:32 (10 years ago)
Author:
melissa
Message:

Added a couple of object linkage tests. Note that Detector creation currently fails, so all tests are skipped.

File:
1 edited

Legend:

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

    r6150 r6151  
    6666import ome.xml.r201004.Union; 
    6767import ome.xml.r201004.Well; 
     68import ome.xml.r201004.WellSample; 
    6869import ome.xml.r201004.enums.DimensionOrder; 
    6970import ome.xml.r201004.enums.EnumerationException; 
     
    168169    root.setAttribute("xmlns", XML_NS); 
    169170    root.setAttribute("xmlns:xsi", XSI_NS); 
    170     root.setAttribute("xsi:schemaLocation", 
    171         XML_NS + " " + SCHEMA_LOCATION); 
     171    root.setAttribute("xsi:schemaLocation", XML_NS + " " + SCHEMA_LOCATION); 
    172172    document.appendChild(root); 
    173173    // Produce string XML 
    174174    asString = asString(); 
    175     /* debug */ System.err.println(asString); 
    176175    // Read string XML in as a DOM tree and parse into the object hierarchy 
    177176    ome = new OME(document.getDocumentElement()); 
     
    225224    assertNotNull(detector); 
    226225    assertEquals(DETECTOR_ID, detector.getID()); 
     226  } 
     227 
     228  @Test(dependsOnMethods={"testValidInstrumentNode", "testValidImageNode"}) 
     229  public void testImageInstrumentLinkage() { 
     230    Instrument instrument = ome.getInstrument(0); 
     231    Image image = ome.getImage(0); 
     232 
     233    assertEquals(1, image.sizeOfLinkedInstrumentList()); 
     234    Instrument linkedInstrument = image.getLinkedInstrument(0); 
     235    assertNotNull(linkedInstrument); 
     236    assertEquals(instrument.getID(), linkedInstrument.getID()); 
     237 
     238    assertEquals(1, instrument.sizeOfImageList()); 
     239    Image linkedImage = instrument.getImage(0); 
     240    assertNotNull(linkedImage); 
     241    assertEquals(image.getID(), linkedImage.getID()); 
    227242  } 
    228243 
     
    247262  } 
    248263 
     264  @Test(dependsOnMethods={"testValidPlateNode"}) 
     265  public void testValidWellSamples() { 
     266    Plate plate = ome.getPlate(0); 
     267    for (int row=0; row<plate.getRows(); row++) { 
     268      for (int col=0; col<plate.getColumns(); col++) { 
     269        Well well = plate.getWell(row * plate.getColumns() + col); 
     270        assertEquals(1, well.sizeOfWellSampleList()); 
     271        WellSample sample = well.getWellSample(0); 
     272        assertNotNull(sample); 
     273        assertEquals(1, sample.sizeOfLinkedImageList()); 
     274        Image image = sample.getLinkedImage(0); 
     275        assertNotNull(image); 
     276        assertEquals(IMAGE_ID, image.getID()); 
     277      } 
     278    } 
     279  } 
     280 
    249281  @Test(dependsOnMethods={"testValidOMENode"}) 
    250282  public void testValidROINode() { 
     
    255287    Union shapeUnion = roi.getUnion(); 
    256288    assertNotNull(shapeUnion); 
     289    assertEquals(1, shapeUnion.sizeOfShapeList()); 
    257290    Shape s = shapeUnion.getShape(0); 
    258291    assertNotNull(s); 
    259  
    260     Rectangle rect = s.getRectangle(); 
    261     assertNotNull(rect); 
     292    assertTrue(s instanceof Rectangle); 
     293 
     294    Rectangle rect = (Rectangle) s; 
    262295    assertEquals(RECTANGLE_X, rect.getX()); 
    263296    assertEquals(RECTANGLE_Y, rect.getY()); 
    264297    assertEquals(RECTANGLE_WIDTH, rect.getWidth()); 
    265298    assertEquals(RECTANGLE_HEIGHT, rect.getHeight()); 
    266  
    267     assertNull(s.getMask()); 
    268     assertNull(s.getEllipse()); 
    269     assertNull(s.getPoint()); 
    270     assertNull(s.getPolyline()); 
    271     assertNull(s.getLine()); 
    272     assertNull(s.getPath()); 
    273     assertNull(s.getText()); 
    274299  } 
    275300 
     
    313338    laser.setType(LaserType.DYE); 
    314339    //instrument.addLightSource(laser);  // XXX: Fucked type hierarchy!?! 
     340 
     341    // link Instrument to the first Image 
     342    Image image = ome.getImage(0); 
     343    instrument.addImage(image); 
     344    image.linkInstrument(instrument); 
     345 
    315346    return instrument; 
    316347  } 
     
    329360        well.setRow(row); 
    330361        well.setColumn(col); 
     362 
     363        WellSample sample = new WellSample(); 
     364        sample.setIndex(0); 
     365        sample.linkImage(ome.getImage(0)); 
     366        well.addWellSample(sample); 
    331367        plate.addWell(well); 
    332368      } 
     
    340376    roi.setID(ROI_ID); 
    341377    Union shapeUnion = new Union(); 
    342     Shape s = new Shape(); 
    343378    Rectangle rect = new Rectangle(); 
    344379    rect.setX(RECTANGLE_X); 
     
    347382    rect.setHeight(RECTANGLE_HEIGHT); 
    348383 
    349     s.setRectangle(rect); 
    350     shapeUnion.addShape(s); 
     384    shapeUnion.addShape(rect); 
    351385    roi.setUnion(shapeUnion); 
    352386 
Note: See TracChangeset for help on using the changeset viewer.