1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.mapcss;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.Test;
|
---|
7 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
8 | import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context;
|
---|
9 | import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
|
---|
10 | import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.PseudoClasses;
|
---|
11 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
12 |
|
---|
13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
14 | import net.trajano.commons.testing.UtilityClassTestUtil;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests of {@link ConditionFactory}.
|
---|
18 | */
|
---|
19 | class ConditionFactoryTest {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Setup rule
|
---|
23 | */
|
---|
24 | @RegisterExtension
|
---|
25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
26 | public JOSMTestRules test = new JOSMTestRules().preferences();
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14368">#14368</a>.
|
---|
30 | */
|
---|
31 | @Test
|
---|
32 | void testTicket14368() {
|
---|
33 | assertThrows(MapCSSException.class,
|
---|
34 | () -> ConditionFactory.createKeyValueCondition("name", "Rodovia ([A-Z]{2,3}-[0-9]{2,4}", Op.REGEX, Context.PRIMITIVE, false));
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Tests that {@code PseudoClasses} satisfies utility class criteria.
|
---|
39 | * @throws ReflectiveOperationException if an error occurs
|
---|
40 | */
|
---|
41 | @Test
|
---|
42 | void testUtilityClass() throws ReflectiveOperationException {
|
---|
43 | UtilityClassTestUtil.assertUtilityClassWellDefined(PseudoClasses.class);
|
---|
44 | }
|
---|
45 | }
|
---|