Changeset 15838 in josm for trunk/test/unit/org
- Timestamp:
- 2020-02-10T23:58:31+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/autofilter/AutoFilterManagerTest.java
r15764 r15838 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNull;6 5 7 6 import java.util.Arrays; 7 import java.util.OptionalInt; 8 8 import java.util.TreeSet; 9 9 import java.util.stream.Collectors; … … 34 34 @Test 35 35 public void testTagValuesForPrimitive() { 36 final TreeSet<String> values = Stream.of( 36 AutoFilterManager.getInstance().setCurrentAutoFilter(null); 37 final TreeSet<Integer> values = Stream.of( 37 38 OsmUtils.createPrimitive("way level=-4--5"), 38 39 OsmUtils.createPrimitive("way level=-2"), … … 42 43 OsmUtils.createPrimitive("way level=6-9"), 43 44 OsmUtils.createPrimitive("way level=10;12-13")) 44 .flatMap(o -> AutoFilterManager.getTagValuesForPrimitive("level", o)) 45 .flatMapToInt(o -> AutoFilterManager.getInstance().getTagValuesForPrimitive("level", o)) 46 .boxed() 45 47 .collect(Collectors.toCollection(TreeSet::new)); 46 assertEquals(new TreeSet<>(Arrays.asList( "-5", "-4", "-2", "0", "1", "2", "3", "6", "7", "8", "9", "10", "12", "13")), values);48 assertEquals(new TreeSet<>(Arrays.asList(-5, -4, -2, 0, 1, 2, 3, 6, 7, 8, 9, 10, 12, 13)), values); 47 49 48 50 } … … 53 55 @Test 54 56 public void testTagValuesForPrimitivesDefaults() { 55 assertNull(getLayer("way foo=bar")); 56 assertEquals("1", getLayer("way bridge=yes")); 57 assertEquals("1", getLayer("way power=line")); 58 assertEquals("-1", getLayer("way tunnel=yes")); 59 assertEquals("0", getLayer("way tunnel=building_passage")); 60 assertEquals("0", getLayer("way highway=residential")); 61 assertEquals("0", getLayer("way railway=rail")); 62 assertEquals("0", getLayer("way waterway=canal")); 57 AutoFilterManager.getInstance().setCurrentAutoFilter(null); 58 assertEquals(OptionalInt.empty(), getLayer("way foo=bar")); 59 AutoFilterRule.getDefaultRule("layer").ifPresent(AutoFilterManager.getInstance()::enableAutoFilterRule); 60 assertEquals(OptionalInt.empty(), getLayer("way foo=bar")); 61 assertEquals(OptionalInt.of(1), getLayer("way bridge=yes")); 62 assertEquals(OptionalInt.of(1), getLayer("way power=line")); 63 assertEquals(OptionalInt.of(-1), getLayer("way tunnel=yes")); 64 assertEquals(OptionalInt.of(0), getLayer("way tunnel=building_passage")); 65 assertEquals(OptionalInt.of(0), getLayer("way highway=residential")); 66 assertEquals(OptionalInt.of(0), getLayer("way railway=rail")); 67 assertEquals(OptionalInt.of(0), getLayer("way waterway=canal")); 63 68 } 64 69 65 private StringgetLayer(final String assertion) {66 return AutoFilterManager.get TagValuesForPrimitive("layer", OsmUtils.createPrimitive(assertion))67 . findFirst()68 . orElse(null);70 private OptionalInt getLayer(final String assertion) { 71 return AutoFilterManager.getInstance() 72 .getTagValuesForPrimitive("layer", OsmUtils.createPrimitive(assertion)) 73 .findFirst(); 69 74 } 70 75 }
Note:
See TracChangeset
for help on using the changeset viewer.