/** Creates a new instance. */ public XMLMockObjects() { ome = new OME(); }
@BeforeClass public void setUp() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.parse( this.getClass().getResourceAsStream("XMLAnnotationTest.ome")); OMEModel model = new OMEModelImpl(); // Read string XML in as a DOM tree and parse into the object hierarchy ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); }
@Test public void testLightSourceType() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); }
@Test public void testMapAnnotationValid() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); }
@Test public void testGenericExcitationSourceValid() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); }
@Test public void testGenericExcitationSourceValid() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); }
public BaseModelMock() { ome = new OME(); ome.addImage(makeImage(1)); }
@Test public void testMapAnnotationValueContent() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); assertNotNull(ome); assertEquals(ome.getImage(0).getPixels().getID(), "Pixels:0"); assertNotNull(ome.getImage(0).getLinkedAnnotation(0)); MapAnnotation mapAnnotation = (MapAnnotation) ome.getImage(0).getLinkedAnnotation(0); List<MapPair> dataMap = mapAnnotation.getValue(); assertEquals(6, dataMap.size()); assertEquals("a", dataMap.get(0).getName()); assertEquals("1", dataMap.get(0).getValue()); assertEquals("d", dataMap.get(1).getName()); assertEquals("2", dataMap.get(1).getValue()); assertEquals("c", dataMap.get(2).getName()); assertEquals("3", dataMap.get(2).getValue()); assertEquals("b", dataMap.get(3).getName()); assertEquals("4", dataMap.get(3).getValue()); assertEquals("e", dataMap.get(4).getName()); assertEquals("5", dataMap.get(4).getValue()); assertEquals("c", dataMap.get(5).getName()); assertEquals("6", dataMap.get(5).getValue()); }
@Test public void testGenericExcitationSourceMapContent() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); assertNotNull(ome); assertEquals(ome.getImage(0).getPixels().getID(), "Pixels:0"); assertNotNull(ome.getImage(0).getImagingEnvironment()); ImagingEnvironment imagingEnvironment = ome.getImage(0).getImagingEnvironment(); List<MapPair> dataMap = imagingEnvironment.getMap(); assertEquals(6, dataMap.size()); assertPair(dataMap, 0, "a", "1"); assertPair(dataMap, 1, "d", "2"); assertPair(dataMap, 2, "c", "3"); assertPair(dataMap, 3, "b", "4"); assertPair(dataMap, 4, "e", "5"); assertPair(dataMap, 5, "c", "6"); }
@Test public void testGenericExcitationSourceMapContent() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.newDocument(); // Produce a valid OME DOM element hierarchy Element root = ome.asXMLElement(document); SPWModelMock.postProcess(root, document, false); OMEModel model = new OMEModelImpl(); ome = new OME(document.getDocumentElement(), model); model.resolveReferences(); assertNotNull(ome); assertEquals(ome.getImage(0).getPixels().getChannel(0).getLightSourceSettings().getID(), "LightSource:0"); assertNotNull(ome.getInstrument(0).getLightSource(0)); GenericExcitationSource geSource = (GenericExcitationSource) ome.getInstrument(0).getLightSource(0); List<MapPair> dataMap = geSource.getMap(); assertEquals(6, dataMap.size()); assertPair(dataMap, 0, "a", "1"); assertPair(dataMap, 1, "d", "2"); assertPair(dataMap, 2, "c", "3"); assertPair(dataMap, 3, "b", "4"); assertPair(dataMap, 4, "e", "5"); assertPair(dataMap, 5, "c", "6"); }
public SPWModelMock(boolean makeLightSources) { ome = new OME(); annotations = new StructuredAnnotations(); ome.addInstrument(makeInstrument(makeLightSources)); for (int i = 0; i < WELL_ROWS.getValue() * WELL_COLS.getValue(); i++) { ome.addImage(makeImage(i)); } ome.addPlate(makePlate()); ome.setStructuredAnnotations(annotations); }