use of org.openstreetmap.osmosis.core.domain.v0_6.Bound 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.core.domain.v0_6.Bound 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.core.domain.v0_6.Bound 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.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class BoundWriterTest method testProcess2.
/**
* Test non-writing of a Bound element with an empty origin string.
*/
@Test
public final void testProcess2() {
BoundWriter bw = new BoundWriter("bound", 2, true);
bw.setWriter(testBufferedWriter);
bw.process(new Bound(20.123456, -21.987654, 22.555555, -23.234567, ""));
try {
testBufferedWriter.flush();
} catch (IOException e) {
e.printStackTrace();
fail("IOException");
}
// not written; empty string
assertTrue(testWriter.toString().equals(""));
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class BoundWriterTest method testProcess1.
/**
* Test writing out a normal Bound element.
*/
@Test
public final void testProcess1() {
BoundWriter bw = new BoundWriter("bound", 2, true);
bw.setWriter(testBufferedWriter);
bw.process(new Bound(20.123456, -21.987654, 22.555555, -23.234567, "originstring"));
try {
testBufferedWriter.flush();
} catch (IOException e) {
e.printStackTrace();
fail("IOException");
}
// If this test fails, it could be because the regex has broken. There are a number of
// variations which are valid XML which this regex won't catch. It might need any number of
// \\s* to account for variable whitespace.
String regexMatch = "^\\s*<bound\\s*" + "box=['\"]-23.23457,-21.98765,22.55556,20.12346['\"]\\s*" + "origin=['\"]originstring['\"]/>\\s*$";
assertTrue(testWriter.toString().matches(regexMatch));
}
Aggregations