Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/tools/template_engine
- Timestamp:
- 2020-10-28T20:41:00+01:00 (5 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/tools/template_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEntryTest.java
r14100 r17275 5 5 6 6 import org.junit.Assert; 7 import org.junit. Rule;8 import org.junit.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension; 8 import org.junit.jupiter.api.Test; 9 9 import org.openstreetmap.josm.TestUtils; 10 10 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 18 18 * Unit tests of {@link TemplateEntry} class. 19 19 */ 20 publicclass TemplateEntryTest {20 class TemplateEntryTest { 21 21 22 22 /** 23 23 * Setup rule. 24 24 */ 25 @R ule25 @RegisterExtension 26 26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 27 27 public JOSMTestRules test = new JOSMTestRules(); … … 31 31 */ 32 32 @Test 33 publicvoid testEqualsContract() {33 void testEqualsContract() { 34 34 TestUtils.assumeWorkingEqualsVerifier(); 35 35 Set<Class<? extends TemplateEntry>> templates = TestUtils.getJosmSubtypes(TemplateEntry.class); -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java
r14093 r17275 2 2 package org.openstreetmap.josm.tools.template_engine; 3 3 4 import static org.junit.Assert.assertEquals; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 5 6 6 7 import java.util.Arrays; … … 8 9 9 10 import org.junit.Assert; 10 import org.junit. BeforeClass;11 import org.junit.Test; 11 import org.junit.jupiter.api.BeforeAll; 12 import org.junit.jupiter.api.Test; 12 13 import org.openstreetmap.josm.JOSMFixture; 13 14 import org.openstreetmap.josm.data.osm.Node; … … 22 23 * Unit tests of {@link TemplateParser} class. 23 24 */ 24 publicclass TemplateParserTest {25 class TemplateParserTest { 25 26 26 27 /** 27 28 * Setup test. 28 29 */ 29 @Before Class30 @BeforeAll 30 31 public static void setUp() { 31 32 JOSMFixture.createUnitTestFixture().init(); … … 37 38 */ 38 39 @Test 39 publicvoid testEmpty() throws ParseError {40 void testEmpty() throws ParseError { 40 41 TemplateParser parser = new TemplateParser(""); 41 42 assertEquals(new StaticText(""), parser.parse()); … … 47 48 */ 48 49 @Test 49 publicvoid testVariable() throws ParseError {50 void testVariable() throws ParseError { 50 51 TemplateParser parser = new TemplateParser("abc{var}\\{ef\\$\\{g"); 51 52 assertEquals(CompoundTemplateEntry.fromArray(new StaticText("abc"), … … 58 59 */ 59 60 @Test 60 publicvoid testConditionWhitespace() throws ParseError {61 void testConditionWhitespace() throws ParseError { 61 62 TemplateParser parser = new TemplateParser("?{ '{name} {desc}' | '{name}' | '{desc}' }"); 62 63 Condition condition = new Condition(Arrays.asList( … … 72 73 */ 73 74 @Test 74 publicvoid testConditionNoWhitespace() throws ParseError {75 void testConditionNoWhitespace() throws ParseError { 75 76 TemplateParser parser = new TemplateParser("?{'{name} {desc}'|'{name}'|'{desc}'}"); 76 77 Condition condition = new Condition(Arrays.asList( … … 91 92 */ 92 93 @Test 93 publicvoid testConditionSearchExpression() throws ParseError, SearchParseError {94 void testConditionSearchExpression() throws ParseError, SearchParseError { 94 95 TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | '{admin_level}'}"); 95 96 Condition condition = new Condition(Arrays.asList( … … 139 140 */ 140 141 @Test 141 publicvoid testFilling() throws ParseError {142 void testFilling() throws ParseError { 142 143 TemplateParser parser = new TemplateParser("{name} u{unknown}u i{number}i"); 143 144 TemplateEntry entry = parser.parse(); … … 152 153 */ 153 154 @Test 154 publicvoid testFillingSearchExpression() throws ParseError {155 void testFillingSearchExpression() throws ParseError { 155 156 TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | '{admin_level}'}"); 156 157 TemplateEntry templateEntry = parser.parse(); … … 173 174 */ 174 175 @Test 175 publicvoid testPrintAll() throws ParseError {176 void testPrintAll() throws ParseError { 176 177 TemplateParser parser = new TemplateParser("{special:everything}"); 177 178 TemplateEntry entry = parser.parse(); … … 187 188 */ 188 189 @Test 189 publicvoid testPrintMultiline() throws ParseError {190 void testPrintMultiline() throws ParseError { 190 191 TemplateParser parser = new TemplateParser("{name}\\n{number}"); 191 192 TemplateEntry entry = parser.parse(); … … 200 201 */ 201 202 @Test 202 publicvoid testSpecialVariable() throws ParseError {203 void testSpecialVariable() throws ParseError { 203 204 TemplateParser parser = new TemplateParser("{name}u{special:localName}u{special:special:key}"); 204 205 TemplateEntry templateEntry = parser.parse(); … … 210 211 211 212 @Test 212 publicvoid testSearchExpression() throws Exception {213 void testSearchExpression() throws Exception { 213 214 compile("(parent type=type1 type=parent1) | (parent type=type2 type=parent2)"); 214 215 //"parent(type=type1,type=parent1) | (parent(type=type2,type=parent2)" … … 221 222 */ 222 223 @Test 223 publicvoid testSwitchContext() throws ParseError {224 void testSwitchContext() throws ParseError { 224 225 TemplateParser parser = new TemplateParser("!{parent() type=parent2 '{name}'}"); 225 226 DatasetFactory ds = new DatasetFactory(); … … 242 243 243 244 @Test 244 publicvoid testSetAnd() throws ParseError {245 void testSetAnd() throws ParseError { 245 246 TemplateParser parser = new TemplateParser("!{(parent(type=child) type=parent) & (parent type=child subtype=parent) '{name}'}"); 246 247 DatasetFactory ds = new DatasetFactory(); … … 261 262 262 263 @Test 263 publicvoid testSetOr() throws ParseError {264 void testSetOr() throws ParseError { 264 265 TemplateParser parser = new TemplateParser("!{(parent(type=type1) type=parent1) | (parent type=type2 type=parent2) '{name}'}"); 265 266 DatasetFactory ds = new DatasetFactory(); … … 288 289 289 290 @Test 290 publicvoid testMultilevel() throws ParseError {291 void testMultilevel() throws ParseError { 291 292 TemplateParser parser = new TemplateParser( 292 293 "!{(parent(parent(type=type1)) type=grandparent) | (parent type=type2 type=parent2) '{name}'}"); … … 320 321 } 321 322 322 @Test (expected = ParseError.class)323 publicvoid testErrorsNot()throws ParseError{323 @Test 324 void testErrorsNot() { 324 325 TemplateParser parser = new TemplateParser("!{-parent() '{name}'}"); 325 parser.parse(); 326 } 327 328 @Test (expected = ParseError.class)329 publicvoid testErrorOr()throws ParseError{326 assertThrows(ParseError.class, () -> parser.parse()); 327 } 328 329 @Test 330 void testErrorOr() { 330 331 TemplateParser parser = new TemplateParser("!{parent() | type=type1 '{name}'}"); 331 parser.parse(); 332 } 333 334 @Test 335 publicvoid testChild() throws ParseError {332 assertThrows(ParseError.class, () -> parser.parse()); 333 } 334 335 @Test 336 void testChild() throws ParseError { 336 337 TemplateParser parser = new TemplateParser("!{((child(type=type1) type=child1) | (child type=type2 type=child2)) type=child2 '{name}'}"); 337 338 DatasetFactory ds = new DatasetFactory(); … … 351 352 parent2.addMember(new RelationMember("", child2)); 352 353 353 354 354 StringBuilder sb = new StringBuilder(); 355 355 TemplateEntry entry = parser.parse(); … … 360 360 361 361 @Test 362 publicvoid testToStringCanBeParsedAgain() throws Exception {362 void testToStringCanBeParsedAgain() throws Exception { 363 363 final String s1 = "?{ '{name} ({desc})' | '{name} ({cmt})' | '{name}' | '{desc}' | '{cmt}' }"; 364 364 final String s2 = new TemplateParser(s1).parse().toString();
Note:
See TracChangeset
for help on using the changeset viewer.