use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.
the class MergeBoundTest method testSource1HasBound.
/**
* Tests whether merge will delete the declared bound if only source 1
* has a declared bound.
*
* @throws Exception if something goes wrong
*/
@Test
public void testSource1HasBound() throws Exception {
RunnableSource source0 = new BoundSource(new Bound(1, 2, 4, 3, "source0"), false);
RunnableSource source1 = new BoundSource(new Bound(5, 6, 8, 7, "source1"), 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());
for (EntityContainer entityContainer : mergedList) {
Assert.assertEquals(EntityType.Node, entityContainer.getEntity().getType());
}
}
use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.
the class BoundSetterTest method setNewBoundTest.
/**
* Tests the bound setting when there is no bound upstream.
*/
@Test
public void setNewBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
BoundSetter setter = new BoundSetter(newBound);
setter.setSink(inspector);
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
EntityContainer ec = inspector.getProcessedEntities().iterator().next();
Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
Bound bound = (Bound) ec.getEntity();
Assert.assertEquals(bound, newBound);
}
use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.
the class BoundSetterTest method removeNoBoundTest.
/**
* Tests the bound removal when there is no bound upstream.
*/
@Test
public void removeNoBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
BoundSetter setter = new BoundSetter(null);
setter.setSink(inspector);
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
EntityContainer ec = inspector.getProcessedEntities().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 BoundSetterTest method overwriteBoundTest.
/**
* Tests the bound setting.
*/
@Test
public void overwriteBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
BoundSetter setter = new BoundSetter(newBound);
setter.setSink(inspector);
setter.process(new BoundContainer(new Bound("Test")));
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
EntityContainer ec = iterator.next();
Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
Bound bound = (Bound) ec.getEntity();
Assert.assertEquals(bound, newBound);
// 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 BoundSetterTest method removeExistingBoundTest.
/**
* Tests the bound removal.
*/
@Test
public void removeExistingBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
BoundSetter setter = new BoundSetter(null);
setter.setSink(inspector);
setter.process(new BoundContainer(new Bound("Test")));
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
EntityContainer ec = inspector.getProcessedEntities().iterator().next();
Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
Aggregations