Search in sources :

Example 1 with SinkEntityInspector

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

the class BoundComputerTest method computeBoundNoUpstreamBound.

/**
 * Tests the bound computation when no bound entity is upstream.
 */
@Test
public void computeBoundNoUpstreamBound() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundComputer bc = new BoundComputer("NewBound");
    bc.setSink(inspector);
    bc.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
    bc.complete();
    bc.close();
    EntityContainer ec = inspector.getProcessedEntities().iterator().next();
    Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Test(org.junit.Test)

Example 2 with SinkEntityInspector

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

the class BoundComputerTest method computeBoundNoNodes.

/**
 * Tests the bound computation if no nodes are upstream.
 */
@Test
public void computeBoundNoNodes() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundComputer bc = new BoundComputer("NewBound");
    bc.setSink(inspector);
    bc.complete();
    bc.close();
    Assert.assertNull(inspector.getLastEntityContainer());
}
Also used : SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Test(org.junit.Test)

Example 3 with SinkEntityInspector

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

the class BoundComputerTest method computeBoundNoNodesWithBound.

/**
 * Tests the bound computation if no nodes but a bound entity is upstream.
 */
@Test
public void computeBoundNoNodesWithBound() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundComputer bc = new BoundComputer("NewBound");
    bc.setSink(inspector);
    bc.process(new BoundContainer(new Bound("Test")));
    bc.complete();
    bc.close();
    Assert.assertNull(inspector.getLastEntityContainer());
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Test(org.junit.Test)

Example 4 with SinkEntityInspector

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

the class BoundComputerTest method computeBoundWithUpstreamBound.

/**
 * Tests the bound computation when there is bound entity is upstream.
 */
@Test
public void computeBoundWithUpstreamBound() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundComputer bc = new BoundComputer("NewBound");
    bc.setSink(inspector);
    bc.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
    bc.complete();
    bc.close();
    Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
    EntityContainer ec = iterator.next();
    Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());
    // Ensure there is no second bound.
    ec = iterator.next();
    Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Test(org.junit.Test)

Example 5 with SinkEntityInspector

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

the class MergeBoundTest method testOneSourceEmpty.

/**
 * Tests the proper working of the merge task if exactly one source is
 * empty with respect to the declared bound.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testOneSourceEmpty() throws Exception {
    RunnableSource source0 = new EmptyReader();
    Bound bound1 = new Bound(5, 6, 8, 7, "source2");
    RunnableSource source1 = new BoundSource(bound1, true);
    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1, BoundRemovedAction.Ignore);
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
    List<EntityContainer> mergedList = createList(merged.getProcessedEntities());
    Assert.assertEquals(2, mergedList.size());
    Assert.assertEquals(bound1, mergedList.get(0).getEntity());
    Assert.assertEquals(EntityType.Node, mergedList.get(1).getEntity().getType());
}
Also used : Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) EmptyReader(org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader) Test(org.junit.Test)

Aggregations

SinkEntityInspector (org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector)19 Test (org.junit.Test)17 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)14 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)13 Date (java.util.Date)8 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)8 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)8 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)6 RunnableSource (org.openstreetmap.osmosis.core.task.v0_6.RunnableSource)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)3 Before (org.junit.Before)2 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)2 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)2 EmptyReader (org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader)2 File (java.io.File)1