Search in sources :

Example 1 with SinkChangeInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkChangeInspector in project osmosis by openstreetmap.

the class ChangeDeriverTest method rightEmpty.

/**
 * Deriving change with an empty right input should yield
 * a change with creates only.
 *
 * @throws Exception if something goes wrong.
 */
@Test
public void rightEmpty() throws Exception {
    // Cannot be tested with file comparison as the derived
    // change contains deletes which have a current timestamp
    // that cannot be reliably predicted.
    // Therefore, check all relevant attributes manually.
    ChangeDeriver deriver = new ChangeDeriver(1);
    RunnableSource left = new XmlReader(dataUtils.createDataFile("v0_6/derive_change/simple.osm"), true, CompressionMethod.None);
    RunnableSource right = new EmptyReader();
    SinkChangeInspector result = RunTaskUtilities.run(deriver, left, right);
    List<ChangeContainer> changes = result.getProcessedChanges();
    Assert.assertEquals(3, changes.size());
    for (ChangeContainer changeContainer : changes) {
        Assert.assertEquals(ChangeAction.Delete, changeContainer.getAction());
    }
    Entity e;
    e = changes.get(0).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Node, e.getType());
    Assert.assertEquals(10, e.getId());
    Assert.assertEquals(34, e.getVersion());
    e = changes.get(1).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Way, e.getType());
    Assert.assertEquals(100, e.getId());
    Assert.assertEquals(56, e.getVersion());
    e = changes.get(2).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Relation, e.getType());
    Assert.assertEquals(1000, e.getId());
    Assert.assertEquals(78, e.getVersion());
}
Also used : SinkChangeInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkChangeInspector) Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) XmlReader(org.openstreetmap.osmosis.xml.v0_6.XmlReader) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) EmptyReader(org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)1 Entity (org.openstreetmap.osmosis.core.domain.v0_6.Entity)1 EmptyReader (org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader)1 RunnableSource (org.openstreetmap.osmosis.core.task.v0_6.RunnableSource)1 AbstractDataTest (org.openstreetmap.osmosis.testutil.AbstractDataTest)1 SinkChangeInspector (org.openstreetmap.osmosis.testutil.v0_6.SinkChangeInspector)1 XmlReader (org.openstreetmap.osmosis.xml.v0_6.XmlReader)1