Search in sources :

Example 1 with PolarizationState

use of ca.nrc.cadc.caom2.PolarizationState in project caom2db by opencadc.

the class AbstractObservationDAOTest method testEqual.

private void testEqual(Plane expected, Plane actual) {
    testEntity(expected, actual);
    Assert.assertEquals("productID", expected.getProductID(), actual.getProductID());
    Assert.assertEquals("creatorID", expected.creatorID, actual.creatorID);
    Assert.assertEquals("calibrationLevel", expected.calibrationLevel, actual.calibrationLevel);
    Assert.assertEquals("dataProductType", expected.dataProductType, actual.dataProductType);
    testEqualSeconds("plane.metaRelease", expected.metaRelease, actual.metaRelease);
    testEqualSeconds("plane.dataRelease", expected.dataRelease, actual.dataRelease);
    if (expected.provenance != null) {
        Assert.assertEquals("provenance.name", expected.provenance.getName(), actual.provenance.getName());
        Assert.assertEquals("provenance.reference", expected.provenance.reference, actual.provenance.reference);
        Assert.assertEquals("provenance.version", expected.provenance.version, actual.provenance.version);
        Assert.assertEquals("provenance.project", expected.provenance.project, actual.provenance.project);
        Assert.assertEquals("provenance.producer", expected.provenance.producer, actual.provenance.producer);
        Assert.assertEquals("provenance.runID", expected.provenance.runID, actual.provenance.runID);
        testEqualSeconds("provenance.lastExecuted", expected.provenance.lastExecuted, actual.provenance.lastExecuted);
        Assert.assertEquals("provenance.inputs", expected.provenance.getInputs(), actual.provenance.getInputs());
        testEqual("provenance.keywords", expected.provenance.getKeywords(), actual.provenance.getKeywords());
    } else
        Assert.assertNull(actual.provenance);
    if (expected.metrics != null) {
        Assert.assertEquals("metrics.sourceNumberDensity", expected.metrics.sourceNumberDensity, actual.metrics.sourceNumberDensity);
        Assert.assertEquals("metrics.background", expected.metrics.background, actual.metrics.background);
        Assert.assertEquals("metrics.backgroundStdde", expected.metrics.backgroundStddev, actual.metrics.backgroundStddev);
        Assert.assertEquals("metrics.fluxDensityLimit", expected.metrics.fluxDensityLimit, actual.metrics.fluxDensityLimit);
        Assert.assertEquals("metrics.magLimit", expected.metrics.magLimit, actual.metrics.magLimit);
    } else
        Assert.assertNull(actual.metrics);
    if (expected.position != null) {
        Assert.assertNotNull("plane.position", actual.position);
        if (expected.position.bounds != null && Polygon.class.equals(expected.position.bounds.getClass())) {
            Polygon ep = (Polygon) expected.position.bounds;
            Polygon ap = (Polygon) actual.position.bounds;
            Assert.assertEquals("num points", ep.getPoints().size(), ap.getPoints().size());
            for (int i = 0; i < ep.getPoints().size(); i++) {
                Point ept = ep.getPoints().get(i);
                Point apt = ap.getPoints().get(i);
                Assert.assertEquals("point.cval1", ept.cval1, apt.cval1, 0.0);
                Assert.assertEquals("point.cval2", ept.cval2, apt.cval2, 0.0);
            }
            Assert.assertEquals("num vertices", ep.getSamples().getVertices().size(), ap.getSamples().getVertices().size());
            for (int i = 0; i < ep.getSamples().getVertices().size(); i++) {
                Vertex ev = ep.getSamples().getVertices().get(i);
                Vertex av = ap.getSamples().getVertices().get(i);
                Assert.assertEquals("vertex.cval2", ev.getType(), av.getType());
                Assert.assertEquals("vertex.cval1", ev.cval1, av.cval1, 0.0);
                Assert.assertEquals("vertex.cval2", ev.cval2, av.cval2, 0.0);
            }
        } else if (expected.position.bounds != null && Circle.class.equals(expected.position.bounds.getClass())) {
            Circle ep = (Circle) expected.position.bounds;
            Circle ap = (Circle) actual.position.bounds;
            Assert.assertEquals("center.cval1", ep.getCenter().cval1, ap.getCenter().cval1, 0.0);
            Assert.assertEquals("center.cval2", ep.getCenter().cval2, ap.getCenter().cval2, 0.0);
            Assert.assertEquals("radius", ep.getRadius(), ap.getRadius(), 0.0);
        } else
            Assert.assertNull(actual.position.bounds);
        if (expected.position.dimension != null) {
            Assert.assertEquals("position.dimension.naxis1", expected.position.dimension.naxis1, actual.position.dimension.naxis1);
            Assert.assertEquals("position.dimension.naxis2", expected.position.dimension.naxis2, actual.position.dimension.naxis2);
        } else
            Assert.assertNull(actual.position.dimension);
        Assert.assertEquals("position.resolution", expected.position.resolution, actual.position.resolution);
        Assert.assertEquals("position.sampleSize", expected.position.sampleSize, actual.position.sampleSize);
        Assert.assertEquals("position.timeDependent", expected.position.timeDependent, actual.position.timeDependent);
    }
    if (expected.energy != null) {
        Assert.assertNotNull("plane.energy", actual.energy);
        if (expected.energy.bounds != null) {
            Assert.assertNotNull("energy.bounds", actual.energy.bounds);
            Assert.assertEquals("energy.bounds.lower", expected.energy.bounds.getLower(), actual.energy.bounds.getLower(), 0.0);
            Assert.assertEquals("energy.bounds.upper", expected.energy.bounds.getUpper(), actual.energy.bounds.getUpper(), 0.0);
            Assert.assertEquals("energy.bounds.samples.size", expected.energy.bounds.getSamples().size(), actual.energy.bounds.getSamples().size());
            for (int i = 0; i < expected.energy.bounds.getSamples().size(); i++) {
                Interval esi = expected.energy.bounds.getSamples().get(i);
                Interval asi = actual.energy.bounds.getSamples().get(i);
                Assert.assertEquals("SubInterval.lb", esi.getLower(), asi.getLower(), 0.0);
                Assert.assertEquals("SubInterval.ub", esi.getUpper(), asi.getUpper(), 0.0);
            }
        } else
            Assert.assertNull("energy.bounds", actual.energy.bounds);
        Assert.assertEquals("energy.bandpassName", expected.energy.bandpassName, actual.energy.bandpassName);
        Assert.assertEquals("energy.dimension", expected.energy.dimension, actual.energy.dimension);
        Iterator<EnergyBand> ee = expected.energy.getEnergyBands().iterator();
        Iterator<EnergyBand> ae = actual.energy.getEnergyBands().iterator();
        while (ee.hasNext()) {
            EnergyBand ex = ee.next();
            EnergyBand ac = ae.next();
            Assert.assertEquals("energy.energyBand", ex, ac);
        }
        Assert.assertEquals("energy.resolvingPower", expected.energy.resolvingPower, actual.energy.resolvingPower);
        Assert.assertEquals("energy.restwav", expected.energy.restwav, actual.energy.restwav);
        Assert.assertEquals("energy.sampleSize", expected.energy.sampleSize, actual.energy.sampleSize);
        Assert.assertEquals("energy.transition", expected.energy.transition, actual.energy.transition);
    }
    if (expected.time != null) {
        Assert.assertNotNull("plane.time", actual.time);
        if (expected.time.bounds != null) {
            Assert.assertNotNull("time.bounds", actual.time.bounds);
            Assert.assertEquals("time.bounds.lower", expected.time.bounds.getLower(), actual.time.bounds.getLower(), 0.0);
            Assert.assertEquals("time.bounds.upper", expected.time.bounds.getUpper(), actual.time.bounds.getUpper(), 0.0);
            Assert.assertEquals("time.bounds.samples.size", expected.time.bounds.getSamples().size(), actual.time.bounds.getSamples().size());
            for (int i = 0; i < expected.time.bounds.getSamples().size(); i++) {
                Interval esi = expected.time.bounds.getSamples().get(i);
                Interval asi = actual.time.bounds.getSamples().get(i);
                Assert.assertEquals("SubInterval.lb", esi.getLower(), asi.getLower(), 0.0);
                Assert.assertEquals("SubInterval.ub", esi.getUpper(), asi.getUpper(), 0.0);
            }
        } else
            Assert.assertNull("time.bounds", actual.time.bounds);
        Assert.assertEquals("time.dimension", expected.time.dimension, actual.time.dimension);
        Assert.assertEquals("time.exposure", expected.time.exposure, actual.time.exposure);
        Assert.assertEquals("time.resolution", expected.time.resolution, actual.time.resolution);
        Assert.assertEquals("time.sampleSize", expected.time.sampleSize, actual.time.sampleSize);
    }
    if (expected.polarization != null) {
        Assert.assertNotNull("plane.polarization", actual.polarization);
        if (expected.polarization.states != null) {
            Assert.assertNotNull("polarization.states", actual.polarization.states);
            Assert.assertEquals("polarization.states.size", expected.polarization.states.size(), actual.polarization.states.size());
            Iterator<PolarizationState> ei = expected.polarization.states.iterator();
            Iterator<PolarizationState> ai = actual.polarization.states.iterator();
            while (ei.hasNext()) {
                Assert.assertEquals("polarization.state", ei.next(), ai.next());
            }
            Assert.assertEquals("polarization.dimension", expected.polarization.dimension, actual.polarization.dimension);
        }
    }
    Assert.assertEquals("metaReadGroups.size", expected.getMetaReadGroups().size(), actual.getMetaReadGroups().size());
    Iterator<URI> emra = expected.getMetaReadGroups().iterator();
    Iterator<URI> amra = actual.getMetaReadGroups().iterator();
    while (emra.hasNext() || amra.hasNext()) {
        Assert.assertEquals(emra.next(), amra.next());
    }
    Assert.assertEquals("dataReadGroups.size", expected.getMetaReadGroups().size(), actual.getMetaReadGroups().size());
    Iterator<URI> edra = expected.getDataReadGroups().iterator();
    Iterator<URI> adra = actual.getDataReadGroups().iterator();
    while (edra.hasNext() || adra.hasNext()) {
        Assert.assertEquals(edra.next(), adra.next());
    }
    log.debug("num artifacts: " + expected.getArtifacts().size() + " == " + actual.getArtifacts().size());
    Assert.assertEquals("number of artifacts", expected.getArtifacts().size(), actual.getArtifacts().size());
    Iterator<Artifact> ea = expected.getArtifacts().iterator();
    Iterator<Artifact> aa = actual.getArtifacts().iterator();
    while (ea.hasNext()) {
        Artifact ex = ea.next();
        Artifact ac = aa.next();
        testEqual(ex, ac);
    }
    testEntityChecksums(expected, actual);
}
Also used : Vertex(ca.nrc.cadc.caom2.types.Vertex) Circle(ca.nrc.cadc.caom2.types.Circle) EnergyBand(ca.nrc.cadc.caom2.EnergyBand) PolarizationState(ca.nrc.cadc.caom2.PolarizationState) Point(ca.nrc.cadc.caom2.types.Point) PlaneURI(ca.nrc.cadc.caom2.PlaneURI) URI(java.net.URI) ObservationURI(ca.nrc.cadc.caom2.ObservationURI) Point(ca.nrc.cadc.caom2.types.Point) Artifact(ca.nrc.cadc.caom2.Artifact) MultiPolygon(ca.nrc.cadc.caom2.types.MultiPolygon) Polygon(ca.nrc.cadc.caom2.types.Polygon) Interval(ca.nrc.cadc.caom2.types.Interval) SampledInterval(ca.nrc.cadc.caom2.types.SampledInterval)

Aggregations

Artifact (ca.nrc.cadc.caom2.Artifact)1 EnergyBand (ca.nrc.cadc.caom2.EnergyBand)1 ObservationURI (ca.nrc.cadc.caom2.ObservationURI)1 PlaneURI (ca.nrc.cadc.caom2.PlaneURI)1 PolarizationState (ca.nrc.cadc.caom2.PolarizationState)1 Circle (ca.nrc.cadc.caom2.types.Circle)1 Interval (ca.nrc.cadc.caom2.types.Interval)1 MultiPolygon (ca.nrc.cadc.caom2.types.MultiPolygon)1 Point (ca.nrc.cadc.caom2.types.Point)1 Polygon (ca.nrc.cadc.caom2.types.Polygon)1 SampledInterval (ca.nrc.cadc.caom2.types.SampledInterval)1 Vertex (ca.nrc.cadc.caom2.types.Vertex)1 URI (java.net.URI)1