OrderTest.java (1115B)
1 package osm.protobuf; 2 3 import java.io.File; 4 import java.io.RandomAccessFile; 5 import java.net.URI; 6 import java.util.List; 7 import java.util.Map; 8 import java.util.Map.Entry; 9 10 import org.junit.Assert; 11 import org.junit.Test; 12 13 import osm.message.Node; 14 import osm.message.Relation; 15 import osm.message.Way; 16 import osm.protobuf.common.CountingCollector; 17 18 public class OrderTest { 19 @Test 20 public void test() throws Exception { 21 URI testFileURL = WayTest.class.getClassLoader().getResource("protobuf-test.osm.pbf").toURI(); 22 23 List<Entry<Class<?>, Integer>> expectedCounts = List.of( 24 Map.entry(Node.class, 290), 25 Map.entry(Way.class, 44), 26 Map.entry(Relation.class, 5)); 27 28 List<Entry<Class<?>, Integer>> counts = new BlobSpliterator( 29 new RandomAccessFile(new File(testFileURL), "r"), 30 System.out::println) 31 .stream() 32 .flatMap(List::stream) 33 .map(Object::getClass) 34 .collect(new CountingCollector()); 35 36 Assert.assertEquals(expectedCounts, counts); 37 } 38 }