Changeset 13489 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2018-03-03T20:33:09+01:00 (7 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r13413 r13489 260 260 261 261 /** 262 * Makes sure the given primitive belongs to a data set. 263 * @param <T> OSM primitive type 264 * @param osm OSM primitive 265 * @return OSM primitive, attached to a new {@code DataSet} 266 */ 267 public static <T extends OsmPrimitive> T addFakeDataSet(T osm) { 268 new DataSet(osm); 269 return osm; 270 } 271 272 /** 262 273 * Creates a new node with the given tags (see {@link OsmUtils#createPrimitive(java.lang.String)}) 263 274 * -
trunk/test/unit/org/openstreetmap/josm/command/MoveCommandTest.java
r13079 r13489 247 247 @Test 248 248 public void testDescription() { 249 Node node = new Node(LatLon.ZERO);249 Node node = TestUtils.addFakeDataSet(new Node(LatLon.ZERO)); 250 250 node.put("name", "xy"); 251 new DataSet(node);252 251 List<OsmPrimitive> nodeList = Arrays.<OsmPrimitive>asList(node); 253 252 assertTrue(new MoveCommand(nodeList, 1, 2).getDescriptionText().matches("Move 1 node")); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java
r10945 r13489 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertNotNull; 5 6 import static org.junit.Assert.assertNull; 7 import static org.openstreetmap.josm.tools.I18n.tr; 6 8 7 9 import org.junit.Rule; 8 10 import org.junit.Test; 9 import org.openstreetmap.josm. data.osm.OsmUtils;11 import org.openstreetmap.josm.TestUtils; 10 12 import org.openstreetmap.josm.data.validation.TestError; 11 13 import org.openstreetmap.josm.data.validation.routines.AbstractValidator; … … 75 77 } 76 78 77 private static void testKey(String key, String value, boolean valid, AbstractValidator validator, int code) { 78 TestError error = TEST.validateTag(OsmUtils.createPrimitive("node "+key+"="+value+""), key, validator, code); 79 /** 80 * Test of invalid slashes. 81 */ 82 @Test 83 public void testInvalidSlashes() { 84 TestError error = testUrl("website", "http:\\\\www.sjoekurs.no", false); 85 assertEquals(tr("''{0}'': {1}", "website", tr("URL contains backslashes instead of slashes")), error.getDescription()); 86 assertNotNull(error.getFix()); 87 } 88 89 private static TestError testKey(String key, String value, boolean valid, AbstractValidator validator, int code) { 90 TestError error = TEST.validateTag(TestUtils.addFakeDataSet(TestUtils.newNode(key+"="+value+"")), key, validator, code); 79 91 if (valid) { 80 92 assertNull(error != null ? error.getMessage() : null, error); … … 82 94 assertNotNull(error); 83 95 } 96 return error; 84 97 } 85 98 86 private static voidtestUrl(String key, String value, boolean valid) {87 testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL);99 private static TestError testUrl(String key, String value, boolean valid) { 100 return testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL); 88 101 } 89 102 90 private static voidtestEmail(String key, String value, boolean valid) {91 testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL);103 private static TestError testEmail(String key, String value, boolean valid) { 104 return testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL); 92 105 } 93 106 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r13195 r13489 102 102 @Test 103 103 public void testTicket10913() throws ParseException { 104 final OsmPrimitive p = OsmUtils.createPrimitive("way highway=tertiary construction=yes");104 final OsmPrimitive p = TestUtils.addFakeDataSet(TestUtils.newWay("highway=tertiary construction=yes")); 105 105 final TagCheck check = TagCheck.readMapCSS(new StringReader("way {" + 106 106 "throwError: \"error\";" + … … 108 108 "fixAdd: \"highway=construction\";\n" + 109 109 "}")).parseChecks.get(0); 110 new DataSet(p);111 110 final Command command = check.fixPrimitive(p); 112 111 assertTrue(command instanceof SequenceCommand); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r13435 r13489 12 12 import org.junit.Rule; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm. data.osm.DataSet;14 import org.openstreetmap.josm.TestUtils; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.data.osm.OsmUtils; … … 34 34 35 35 List<TestError> test(OsmPrimitive primitive) throws IOException { 36 new DataSet(primitive);37 36 final TagChecker checker = new TagChecker(); 38 37 checker.initialize(); 39 38 checker.startTest(null); 40 checker.check( primitive);39 checker.check(TestUtils.addFakeDataSet(primitive)); 41 40 return checker.getErrors(); 42 41 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r12933 r13489 11 11 import org.junit.Rule; 12 12 import org.junit.Test; 13 import org.openstreetmap.josm.TestUtils; 13 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.Node; … … 91 92 @Test 92 93 public void testAddPrimitivesToRelation() { 93 Relation r = new Relation(1); 94 new DataSet(r); 94 Relation r = TestUtils.addFakeDataSet(new Relation(1)); 95 95 assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.<OsmPrimitive>emptyList())); 96 96 assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(1))));
Note:
See TracChangeset
for help on using the changeset viewer.