Changeset 36064 in osm for applications/editors/josm/plugins/graphview/test
- Timestamp:
- 2023-03-21T14:49:10+01:00 (22 months ago)
- Location:
- applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/FullGraphCreationTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core; 3 3 4 import static org.junit.Assert.assertSame; 4 5 import static org.junit.jupiter.api.Assertions.assertSame; 5 6 6 7 import java.util.Arrays; 7 8 import java.util.Collection; 9 import java.util.Collections; 8 10 import java.util.HashMap; 9 11 import java.util.Iterator; … … 12 14 import java.util.Map; 13 15 14 import org.junit. Test;16 import org.junit.jupiter.api.Test; 15 17 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestNode; 16 18 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestRelation; … … 33 35 import org.openstreetmap.josm.plugins.graphview.plugin.preferences.VehiclePropertyStringParser.PropertyValueSyntaxException; 34 36 35 publicclass FullGraphCreationTest {37 class FullGraphCreationTest { 36 38 37 39 private static final AccessParameters ACCESS_PARAMS; … … 44 46 ACCESS_PARAMS = new PreferenceAccessParameters( 45 47 "test_vehicle", 46 Arrays.asList(AccessType.UNDEFINED),48 Collections.singletonList(AccessType.UNDEFINED), 47 49 vehiclePropertyValues); 48 50 } catch (PropertyValueSyntaxException e) { … … 54 56 @Override 55 57 public java.util.List<String> getAccessHierarchyAncestors(String transportMode) { 56 return Arrays.asList(transportMode);58 return Collections.singletonList(transportMode); 57 59 } 58 60 59 61 @Override 60 62 public Collection<Tag> getBaseTags() { 61 return Arrays.asList(new Tag("highway", "test"));63 return Collections.singletonList(new Tag("highway", "test")); 62 64 } 63 65 … … 69 71 70 72 @Test 71 publicvoid testTJunction() {73 void testTJunction() { 72 74 73 75 TestDataSource ds = new TestDataSource(); … … 125 127 126 128 @Test 127 publicvoid testBarrier() {129 void testBarrier() { 128 130 129 131 TestDataSource ds = new TestDataSource(); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReaderTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.access; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertSame;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 10 import java.io.FileInputStream; … … 15 15 import java.util.Map; 16 16 17 import org.junit. Test;17 import org.junit.jupiter.api.Test; 18 18 import org.openstreetmap.josm.TestUtils; 19 19 import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup; … … 21 21 import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup; 22 22 23 publicclass AccessRulesetReaderTest {23 class AccessRulesetReaderTest { 24 24 25 25 @Test 26 public void testReadAccessRuleset_valid_classes() throws IOException {26 void testReadAccessRulesetValidClasses() throws IOException { 27 27 28 28 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); … … 50 50 51 51 @Test 52 public void testReadAccessRuleset_valid_basetags() throws IOException {52 void testReadAccessRulesetValidBasetags() throws IOException { 53 53 54 54 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); … … 66 66 67 67 @Test 68 public void testReadAccessRuleset_valid_implications() throws IOException {68 void testReadAccessRulesetValidImplications() throws IOException { 69 69 70 70 InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadInclineTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import org.junit. Test;4 import org.junit.jupiter.api.Test; 5 5 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 6 6 7 public class RoadInclineTest extends RoadPropertyTest {7 class RoadInclineTest implements RoadPropertyTest { 8 8 9 9 private static void testIncline(Float expectedInclineForward, Float expectedInclineBackward, 10 10 String inclineString) { 11 11 12 testEvaluateW(new RoadIncline(),12 RoadPropertyTest.testEvaluateW(new RoadIncline(), 13 13 expectedInclineForward, expectedInclineBackward, 14 14 new Tag("incline", inclineString)); … … 16 16 17 17 @Test 18 publicvoid testEvaluate() {18 void testEvaluate() { 19 19 testIncline(5f, -5f, "5 %"); 20 20 testIncline(9.5f, -9.5f, "9.5 %"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeedTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import org.junit. Test;4 import org.junit.jupiter.api.Test; 5 5 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 6 6 7 public class RoadMaxspeedTest extends RoadPropertyTest {7 class RoadMaxspeedTest implements RoadPropertyTest { 8 8 9 9 private static void testMaxspeed(float expectedMaxspeed, String maxspeedString) { 10 testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));10 RoadPropertyTest.testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString)); 11 11 } 12 12 13 13 @Test 14 public void testEvaluate_numeric() {14 void testEvaluateNumeric() { 15 15 testMaxspeed(30, "30"); 16 16 testMaxspeed(48.3f, "48.3"); … … 18 18 19 19 @Test 20 public void testEvaluate_kmh() {20 void testEvaluateKmh() { 21 21 testMaxspeed(50, "50 km/h"); 22 22 testMaxspeed(120, "120km/h"); … … 25 25 26 26 @Test 27 public void testEvaluate_mph() {27 void testEvaluateMph() { 28 28 testMaxspeed(72.42048f, "45 mph"); 29 29 testMaxspeed(64.373764f, "40mph"); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.property; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import org.junit.Ignore;7 6 import org.openstreetmap.josm.plugins.graphview.core.TestDataSource; 8 7 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 9 8 10 @Ignore("no test") 11 public abstract class RoadPropertyTest { 9 public interface RoadPropertyTest { 12 10 13 protectedstatic <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {11 static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) { 14 12 15 13 TestDataSource ds = new TestDataSource(); … … 25 23 } 26 24 27 protectedstatic <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {25 static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) { 28 26 29 27 TestDataSource ds = new TestDataSource(); … … 40 38 } 41 39 42 protectedstatic <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {40 static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) { 43 41 testEvaluateW(property, expected, expected, nodeTags); 44 42 testEvaluateN(property, expected, nodeTags); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogicTest.java
r32620 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.graphview.core.util; 3 import static org.junit.Assert.assertFalse; 4 import static org.junit.Assert.assertTrue; 3 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 7 import java.util.Arrays; 8 import java.util.Collections; 7 9 import java.util.HashMap; 8 10 import java.util.Map; 9 11 10 import org.junit. Before;11 import org.junit. Test;12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Test; 12 14 import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup; 13 15 import org.openstreetmap.josm.plugins.graphview.core.data.Tag; 14 16 import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup; 15 17 16 publicclass TagConditionLogicTest {18 class TagConditionLogicTest { 17 19 18 20 TagGroup groupA; 19 21 TagGroup groupB; 20 22 21 @Before 22 publicvoid setUp() {23 @BeforeEach 24 void setUp() { 23 25 Map<String, String> mapA = new HashMap<>(); 24 26 mapA.put("key1", "value1"); … … 34 36 35 37 @Test 36 publicvoid testTag() {38 void testTag() { 37 39 TagCondition condition = TagConditionLogic.tag(new Tag("key3", "value1")); 38 40 assertTrue(condition.matches(groupA)); … … 41 43 42 44 @Test 43 publicvoid testKey() {45 void testKey() { 44 46 TagCondition condition = TagConditionLogic.key("key3"); 45 47 assertTrue(condition.matches(groupA)); … … 48 50 49 51 @Test 50 publicvoid testAnd() {52 void testAnd() { 51 53 TagCondition condition1 = TagConditionLogic.tag(new Tag("key2", "value2")); 52 54 TagCondition conditionAnd1a = TagConditionLogic.and(condition1); 53 TagCondition conditionAnd1b = TagConditionLogic.and( Arrays.asList(condition1));55 TagCondition conditionAnd1b = TagConditionLogic.and(Collections.singletonList(condition1)); 54 56 55 57 assertTrue(conditionAnd1a.matches(groupA)); … … 78 80 79 81 @Test 80 publicvoid testOr() {82 void testOr() { 81 83 TagCondition condition1 = TagConditionLogic.tag(new Tag("key42", "value42")); 82 84 TagCondition conditionOr1a = TagConditionLogic.or(condition1); 83 TagCondition conditionOr1b = TagConditionLogic.or( Arrays.asList(condition1));85 TagCondition conditionOr1b = TagConditionLogic.or(Collections.singletonList(condition1)); 84 86 85 87 assertFalse(conditionOr1a.matches(groupA)); … … 108 110 109 111 @Test 110 publicvoid testNot() {112 void testNot() { 111 113 TagCondition condition = TagConditionLogic.not(TagConditionLogic.key("key3")); 112 114 assertFalse(condition.matches(groupA)); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParserTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.util; 3 3 4 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertNull; 5 5 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseMeasure; 6 6 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseSpeed; 7 7 import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseWeight; 8 8 9 import org.junit. Test;9 import org.junit.jupiter.api.Test; 10 10 11 public class ValueStringParserTest { 11 12 class ValueStringParserTest { 12 13 13 14 /* speed */ 14 15 15 16 @Test 16 publicvoid testParseSpeedDefault() {17 void testParseSpeedDefault() { 17 18 assertClose(50, parseSpeed("50")); 18 19 } 19 20 20 21 @Test 21 publicvoid testParseSpeedKmh() {22 void testParseSpeedKmh() { 22 23 assertClose(30, parseSpeed("30 km/h")); 23 24 assertClose(100, parseSpeed("100km/h")); … … 25 26 26 27 @Test 27 publicvoid testParseSpeedMph() {28 void testParseSpeedMph() { 28 29 assertClose(40.234f, parseSpeed("25mph")); 29 30 assertClose(40.234f, parseSpeed("25 mph")); … … 31 32 32 33 @Test 33 publicvoid testParseSpeedInvalid() {34 void testParseSpeedInvalid() { 34 35 assertNull(parseSpeed("lightspeed")); 35 36 } … … 38 39 39 40 @Test 40 publicvoid testParseMeasureDefault() {41 void testParseMeasureDefault() { 41 42 assertClose(3.5f, parseMeasure("3.5")); 42 43 } 43 44 44 45 @Test 45 publicvoid testParseMeasureM() {46 void testParseMeasureM() { 46 47 assertClose(2, parseMeasure("2m")); 47 48 assertClose(5.5f, parseMeasure("5.5 m")); … … 49 50 50 51 @Test 51 publicvoid testParseMeasureKm() {52 void testParseMeasureKm() { 52 53 assertClose(1000, parseMeasure("1 km")); 53 54 assertClose(7200, parseMeasure("7.2km")); … … 55 56 56 57 @Test 57 publicvoid testParseMeasureMi() {58 void testParseMeasureMi() { 58 59 assertClose(1609.344f, parseMeasure("1 mi")); 59 60 } 60 61 61 62 @Test 62 publicvoid testParseMeasureFeetInches() {63 void testParseMeasureFeetInches() { 63 64 assertClose(3.6576f, parseMeasure("12'0\"")); 64 65 assertClose(1.9812f, parseMeasure("6' 6\"")); … … 66 67 67 68 @Test 68 publicvoid testParseMeasureInvalid() {69 void testParseMeasureInvalid() { 69 70 assertNull(parseMeasure("very long")); 70 71 assertNull(parseMeasure("6' 16\"")); … … 74 75 75 76 @Test 76 publicvoid testParseWeightDefault() {77 void testParseWeightDefault() { 77 78 assertClose(3.6f, parseWeight("3.6")); 78 79 } 79 80 80 81 @Test 81 publicvoid testParseWeightT() {82 void testParseWeightT() { 82 83 assertClose(30, parseWeight("30t")); 83 84 assertClose(3.5f, parseWeight("3.5 t")); … … 85 86 86 87 @Test 87 publicvoid testParseWeightInvalid() {88 void testParseWeightInvalid() { 88 89 assertNull(parseWeight("heavy")); 89 90 } -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorSchemeTest.java
r32620 r36064 2 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.Color; … … 8 8 import java.util.Map; 9 9 10 import org.junit. Before;11 import org.junit. Test;10 import org.junit.jupiter.api.BeforeEach; 11 import org.junit.jupiter.api.Test; 12 12 import org.openstreetmap.josm.plugins.graphview.core.property.RoadMaxweight; 13 13 14 publicclass FloatPropertyColorSchemeTest {14 class FloatPropertyColorSchemeTest { 15 15 16 16 private FloatPropertyColorScheme subject; 17 17 18 @Before 18 @BeforeEach 19 19 public void setUp() { 20 20 … … 28 28 29 29 @Test 30 public void testGetColorForValue_below() {30 void testGetColorForValueBelow() { 31 31 assertEquals(new Color(42, 42, 42), subject.getColorForValue(1f)); 32 32 assertEquals(new Color(42, 42, 42), subject.getColorForValue(5f)); … … 34 34 35 35 @Test 36 public void testGetColorForValue_above() {36 void testGetColorForValueAbove() { 37 37 assertEquals(new Color(200, 200, 200), subject.getColorForValue(25f)); 38 38 } 39 39 40 40 @Test 41 public void testGetColorForValue_value() {41 void testGetColorForValueValue() { 42 42 assertEquals(new Color(100, 100, 100), subject.getColorForValue(10f)); 43 43 } 44 44 45 45 @Test 46 public void testGetColorForValue_interpolate() {46 void testGetColorForValueInterpolate() { 47 47 assertEquals(new Color(150, 150, 150), subject.getColorForValue(15f)); 48 48 }
Note:
See TracChangeset
for help on using the changeset viewer.