Search in sources :

Example 1 with Stories

use of ru.yandex.qatools.allure.annotations.Stories in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceArcsGml32_grid.

/**
 * Test surface geometries read from a GML 3.2 file
 *
 * @throws Exception if an error occurs
 */
@Stories("Arcs")
@Test
public void testSurfaceArcsGml32_grid() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-arcs.xml").toURI(), gridConfig);
    // three instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        List<GeometryProperty<?>> geoms = new ArrayList<>();
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance1 = it.next();
        geoms.addAll(checkSingleGeometry(instance1, null));
        assertTrue("Second sample feature missing", it.hasNext());
        Instance instance2 = it.next();
        geoms.addAll(checkSingleGeometry(instance2, null));
        assertTrue("Third sample feature missing", it.hasNext());
        Instance instance3 = it.next();
        geoms.addAll(checkSingleGeometry(instance3, null));
        assertEquals("Unexpected number of geometries", 3, geoms.size());
        Geometry geom1 = geoms.get(0).getGeometry();
        Geometry geom2 = geoms.get(1).getGeometry();
        Geometry geom3 = geoms.get(2).getGeometry();
        Envelope envelope = new Envelope();
        envelope.expandToInclude(geom1.getEnvelopeInternal());
        envelope.expandToInclude(geom2.getEnvelopeInternal());
        envelope.expandToInclude(geom3.getEnvelopeInternal());
        PaintSettings settings = new PaintSettings(envelope, 1000, 10);
        SVGPainter svg = new SVGPainter(settings);
        svg.setColor(Color.BLACK);
        svg.drawGeometry(geom1);
        svg.setColor(Color.BLUE);
        svg.drawGeometry(geom2);
        svg.setColor(Color.RED);
        svg.drawGeometry(geom3);
        saveDrawing(svg);
        // ensure that polygons could be created
        assertTrue(Polygon.class.isAssignableFrom(geom1.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom2.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom3.getClass()));
    // XXX how to test?
    // assertTrue("Geometries intersect", geom1.touches(geom2));
    // assertTrue("Geometries intersect", geom2.touches(geom3));
    } finally {
        it.close();
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) SVGPainter(eu.esdihumboldt.util.svg.test.SVGPainter) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Envelope(com.vividsolutions.jts.geom.Envelope) PaintSettings(eu.esdihumboldt.util.svg.test.PaintSettings) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest) Stories(ru.yandex.qatools.allure.annotations.Stories)

Example 2 with Stories

use of ru.yandex.qatools.allure.annotations.Stories in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceArcsGml32.

/**
 * Test surface geometries read from a GML 3.2 file
 *
 * @throws Exception if an error occurs
 */
@Stories("Arcs")
@Test
public void testSurfaceArcsGml32() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-arcs.xml").toURI(), InterpolationConfigurations.segment(maxPositionalError));
    // three instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        List<GeometryProperty<?>> geoms = new ArrayList<>();
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance1 = it.next();
        geoms.addAll(checkSingleGeometry(instance1, null));
        assertTrue("Second sample feature missing", it.hasNext());
        Instance instance2 = it.next();
        geoms.addAll(checkSingleGeometry(instance2, null));
        assertTrue("Third sample feature missing", it.hasNext());
        Instance instance3 = it.next();
        geoms.addAll(checkSingleGeometry(instance3, null));
        assertEquals("Unexpected number of geometries", 3, geoms.size());
        Geometry geom1 = geoms.get(0).getGeometry();
        Geometry geom2 = geoms.get(1).getGeometry();
        Geometry geom3 = geoms.get(2).getGeometry();
        Envelope envelope = new Envelope();
        envelope.expandToInclude(geom1.getEnvelopeInternal());
        envelope.expandToInclude(geom2.getEnvelopeInternal());
        envelope.expandToInclude(geom3.getEnvelopeInternal());
        PaintSettings settings = new PaintSettings(envelope, 1000, 10);
        SVGPainter svg = new SVGPainter(settings);
        svg.setColor(Color.BLACK);
        svg.drawGeometry(geom1);
        svg.setColor(Color.BLUE);
        svg.drawGeometry(geom2);
        svg.setColor(Color.RED);
        svg.drawGeometry(geom3);
        saveDrawing(svg);
        // ensure that polygons could be created
        assertTrue(Polygon.class.isAssignableFrom(geom1.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom2.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom3.getClass()));
    // XXX how to test?
    // intersection area cannot be computed
    // double interArea1 = geom1.intersection(geom2).getArea();
    // double interArea2 = geom2.intersection(geom3).getArea();
    } finally {
        it.close();
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) SVGPainter(eu.esdihumboldt.util.svg.test.SVGPainter) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Envelope(com.vividsolutions.jts.geom.Envelope) PaintSettings(eu.esdihumboldt.util.svg.test.PaintSettings) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest) Stories(ru.yandex.qatools.allure.annotations.Stories)

Example 3 with Stories

use of ru.yandex.qatools.allure.annotations.Stories in project allure-cucumberjvm by allure-framework.

the class AllureRunListener method testSuiteStarted.

public void testSuiteStarted(Description description, String suiteName) throws IllegalAccessException {
    String[] annotationParams = findFeatureByScenarioName(suiteName);
    // Create feature and story annotations. Remove unnecessary words from it
    Features feature = getFeaturesAnnotation(new String[] { annotationParams[0].split(":")[1].trim() });
    Stories story = getStoriesAnnotation(new String[] { annotationParams[1].split(":")[1].trim() });
    // If it`s Scenario Outline, add example string to story name
    if (description.getDisplayName().startsWith("|") || description.getDisplayName().endsWith("|")) {
        story = getStoriesAnnotation(new String[] { annotationParams[1].split(":")[1].trim() + " " + description.getDisplayName() });
    }
    String uid = generateSuiteUid(suiteName);
    TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.value()[0]);
    event.setTitle(story.value()[0]);
    // Add feature and story annotations
    Collection<Annotation> annotations = new ArrayList<>();
    for (Annotation annotation : description.getAnnotations()) {
        annotations.add(annotation);
    }
    annotations.add(story);
    annotations.add(feature);
    AnnotationManager am = new AnnotationManager(annotations);
    am.update(event);
    event.withLabels(AllureModelUtils.createTestFrameworkLabel("CucumberJVM"));
    getLifecycle().fire(event);
}
Also used : AnnotationManager(ru.yandex.qatools.allure.utils.AnnotationManager) TestSuiteStartedEvent(ru.yandex.qatools.allure.events.TestSuiteStartedEvent) ArrayList(java.util.ArrayList) Features(ru.yandex.qatools.allure.annotations.Features) Stories(ru.yandex.qatools.allure.annotations.Stories) Annotation(java.lang.annotation.Annotation)

Aggregations

ArrayList (java.util.ArrayList)3 Stories (ru.yandex.qatools.allure.annotations.Stories)3 Envelope (com.vividsolutions.jts.geom.Envelope)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 Polygon (com.vividsolutions.jts.geom.Polygon)2 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)2 InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)2 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)2 AbstractHandlerTest (eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)2 PaintSettings (eu.esdihumboldt.util.svg.test.PaintSettings)2 SVGPainter (eu.esdihumboldt.util.svg.test.SVGPainter)2 Test (org.junit.Test)2 Annotation (java.lang.annotation.Annotation)1 Features (ru.yandex.qatools.allure.annotations.Features)1 TestSuiteStartedEvent (ru.yandex.qatools.allure.events.TestSuiteStartedEvent)1 AnnotationManager (ru.yandex.qatools.allure.utils.AnnotationManager)1