OrderTest.java (1115B) download
1package osm.protobuf;
2
3import java.io.File;
4import java.io.RandomAccessFile;
5import java.net.URI;
6import java.util.List;
7import java.util.Map;
8import java.util.Map.Entry;
9
10import org.junit.Assert;
11import org.junit.Test;
12
13import osm.message.Node;
14import osm.message.Relation;
15import osm.message.Way;
16import osm.protobuf.common.CountingCollector;
17
18public 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}