Search in sources :

Example 16 with SinkEntityInspector

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

the class MergeBoundTest method testBothEmpty.

/**
 * Tests the proper working of the merge task if both sources are
 * empty.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testBothEmpty() throws Exception {
    RunnableSource source0 = new EmptyReader();
    RunnableSource source1 = new EmptyReader();
    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1, BoundRemovedAction.Ignore);
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
    Assert.assertTrue("Expected empty result set but got some data", merged.getLastEntityContainer() == null);
}
Also used : 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)

Example 17 with SinkEntityInspector

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

the class TagFilterTest method testRejectRelation.

/**
 * Test rejecting a relation without tag-based filtering.
 */
@Test
public final void testRejectRelation() {
    Set<String> keys = new HashSet<String>();
    Map<String, Set<String>> keyValues = new HashMap<String, Set<String>>();
    tagFilter = new TagFilter("reject-relations", keys, keyValues);
    entityInspector = new SinkEntityInspector();
    tagFilter.setSink(entityInspector);
    tagFilter.process(amenityNodeContainer);
    tagFilter.process(residentialWayContainer);
    tagFilter.process(testRelationContainer);
    tagFilter.complete();
    List<EntityContainer> expectedResult = Arrays.asList(amenityNodeContainer, residentialWayContainer);
    assertTrue(entityInspector.getProcessedEntities().equals(expectedResult));
    tagFilter.close();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with SinkEntityInspector

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

the class TagFilterTest method testRejectWay.

/**
 * Test rejecting a way which matches the filter.
 */
@Test
public final void testRejectWay() {
    Set<String> keys = new HashSet<String>();
    Map<String, Set<String>> keyValues = new HashMap<String, Set<String>>();
    keyValues.put("highway", new HashSet<String>(Arrays.asList("motorway", "motorway_link")));
    tagFilter = new TagFilter("reject-ways", keys, keyValues);
    entityInspector = new SinkEntityInspector();
    tagFilter.setSink(entityInspector);
    tagFilter.process(amenityNodeContainer);
    tagFilter.process(residentialWayContainer);
    tagFilter.process(motorwayWayContainer);
    tagFilter.complete();
    List<EntityContainer> expectedResult = Arrays.asList(amenityNodeContainer, residentialWayContainer);
    assertTrue(entityInspector.getProcessedEntities().equals(expectedResult));
    tagFilter.close();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with SinkEntityInspector

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

the class TagFilterTest method testAcceptNode.

/**
 * Test passing a node which matches the filter.
 */
@Test
public final void testAcceptNode() {
    Set<String> keys = new HashSet<String>(Arrays.asList("amenity"));
    Map<String, Set<String>> keyValues = new HashMap<String, Set<String>>();
    keyValues.put("key", new HashSet<String>(Arrays.asList("valone", "valtwo")));
    tagFilter = new TagFilter("accept-nodes", keys, keyValues);
    entityInspector = new SinkEntityInspector();
    tagFilter.setSink(entityInspector);
    tagFilter.process(amenityNodeContainer);
    tagFilter.process(taglessNodeContainer);
    tagFilter.process(residentialWayContainer);
    tagFilter.complete();
    List<EntityContainer> expectedResult = Arrays.asList(amenityNodeContainer, residentialWayContainer);
    assertTrue(entityInspector.getProcessedEntities().equals(expectedResult));
    tagFilter.close();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) HashSet(java.util.HashSet) 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