Changeset 15764 in josm for trunk/test/unit
- Timestamp:
- 2020-01-26T00:18:32+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/autofilter/AutoFilterManagerTest.java
r12407 r15764 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNull; 5 6 6 7 import java.util.Arrays; 7 import java.util.Set;8 8 import java.util.TreeSet; 9 import java.util.function.Consumer; 9 import java.util.stream.Collectors; 10 import java.util.stream.Stream; 10 11 11 12 import org.junit.Rule; 12 13 import org.junit.Test; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive;14 14 import org.openstreetmap.josm.data.osm.OsmUtils; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 30 30 31 31 /** 32 * Unit test of {@link AutoFilterManager#getTagValues Consumer}.32 * Unit test of {@link AutoFilterManager#getTagValuesForPrimitive}. 33 33 */ 34 34 @Test 35 public void testTagValuesConsumer() { 36 Set<String> values = new TreeSet<>(); 37 Consumer<OsmPrimitive> consumer = AutoFilterManager.getTagValuesConsumer("level", values); 38 Arrays.asList( 35 public void testTagValuesForPrimitive() { 36 final TreeSet<String> values = Stream.of( 39 37 OsmUtils.createPrimitive("way level=-4--5"), 40 38 OsmUtils.createPrimitive("way level=-2"), … … 43 41 OsmUtils.createPrimitive("way level=2;3"), 44 42 OsmUtils.createPrimitive("way level=6-9"), 45 OsmUtils.createPrimitive("way level=10;12-13") 46 ).forEach(consumer); 43 OsmUtils.createPrimitive("way level=10;12-13")) 44 .flatMap(o -> AutoFilterManager.getTagValuesForPrimitive("level", o)) 45 .collect(Collectors.toCollection(TreeSet::new)); 47 46 assertEquals(new TreeSet<>(Arrays.asList("-5", "-4", "-2", "0", "1", "2", "3", "6", "7", "8", "9", "10", "12", "13")), values); 47 48 } 49 50 /** 51 * Unit test of {@link AutoFilterManager#getTagValuesForPrimitive} provides sensible defaults, see #17496. 52 */ 53 @Test 54 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")); 63 } 64 65 private String getLayer(final String assertion) { 66 return AutoFilterManager.getTagValuesForPrimitive("layer", OsmUtils.createPrimitive(assertion)) 67 .findFirst() 68 .orElse(null); 48 69 } 49 70 }
Note:
See TracChangeset
for help on using the changeset viewer.