Search in sources :

Example 1 with AccumulatingConsumer

use of com.baremaps.stream.AccumulatingConsumer in project baremaps by baremaps.

the class XmlChangeSpliteratorTest method forEachRemaining.

@Test
void forEachRemaining() throws IOException {
    try (InputStream input = DATA_OSC_XML.openStream()) {
        Spliterator<Change> spliterator = new OsmChangeSpliterator(input);
        AccumulatingConsumer<Change> accumulator = new AccumulatingConsumer<>();
        spliterator.forEachRemaining(accumulator);
        assertEquals(accumulator.values().size(), 7);
        assertEquals(accumulator.values().stream().flatMap(change -> change.getEntities().stream()).collect(Collectors.toList()).size(), 51);
    }
}
Also used : AccumulatingConsumer(com.baremaps.stream.AccumulatingConsumer) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Change(com.baremaps.osm.domain.Change) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) OsmChangeSpliterator(com.baremaps.osm.change.OsmChangeSpliterator) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) DATA_OSC_XML(com.baremaps.testing.TestFiles.DATA_OSC_XML) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HoldingConsumer(com.baremaps.stream.HoldingConsumer) Spliterator(java.util.Spliterator) InputStream(java.io.InputStream) InputStream(java.io.InputStream) Change(com.baremaps.osm.domain.Change) OsmChangeSpliterator(com.baremaps.osm.change.OsmChangeSpliterator) AccumulatingConsumer(com.baremaps.stream.AccumulatingConsumer) Test(org.junit.jupiter.api.Test)

Example 2 with AccumulatingConsumer

use of com.baremaps.stream.AccumulatingConsumer in project baremaps by baremaps.

the class XmlEntitySpliteratorTest method forEachRemaining.

@Test
void forEachRemaining() throws IOException {
    try (InputStream input = DATA_OSM_XML.openStream()) {
        Spliterator<Entity> spliterator = new OsmXmlSpliterator(input);
        AccumulatingConsumer<Object> accumulator = new AccumulatingConsumer<>();
        spliterator.forEachRemaining(accumulator);
        assertEquals(12, accumulator.values().size());
    }
}
Also used : Entity(com.baremaps.osm.domain.Entity) InputStream(java.io.InputStream) AccumulatingConsumer(com.baremaps.stream.AccumulatingConsumer) Test(org.junit.jupiter.api.Test)

Aggregations

AccumulatingConsumer (com.baremaps.stream.AccumulatingConsumer)2 InputStream (java.io.InputStream)2 Test (org.junit.jupiter.api.Test)2 OsmChangeSpliterator (com.baremaps.osm.change.OsmChangeSpliterator)1 Change (com.baremaps.osm.domain.Change)1 Entity (com.baremaps.osm.domain.Entity)1 HoldingConsumer (com.baremaps.stream.HoldingConsumer)1 DATA_OSC_XML (com.baremaps.testing.TestFiles.DATA_OSC_XML)1 IOException (java.io.IOException)1 Spliterator (java.util.Spliterator)1 Collectors (java.util.stream.Collectors)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1