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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations