source: josm/trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactoryTest.java@ 17758

Last change on this file since 17758 was 17758, checked in by simon04, 3 years ago

fix #20744 - Evaluate MapCSS expression without array creation

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.mapcss;
3
4import org.junit.jupiter.api.extension.RegisterExtension;
5import org.junit.jupiter.api.Test;
6import org.openstreetmap.josm.testutils.JOSMTestRules;
7
8import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
9import net.trajano.commons.testing.UtilityClassTestUtil;
10
11import java.lang.reflect.Method;
12import java.lang.reflect.Modifier;
13
14/**
15 * Unit tests of {@link ExpressionFactory}.
16 */
17class ExpressionFactoryTest {
18
19 /**
20 * Setup rule
21 */
22 @RegisterExtension
23 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
24 public JOSMTestRules test = new JOSMTestRules();
25
26 /**
27 * Tests that {@code Functions} satisfies utility class criteria.
28 * @throws ReflectiveOperationException if an error occurs
29 */
30 @Test
31 void testUtilityClass() throws ReflectiveOperationException {
32 UtilityClassTestUtil.assertUtilityClassWellDefined(Functions.class);
33 }
34
35 /**
36 * Tests that all functions have been registered to {@link ExpressionFactory#FACTORY_MAP}
37 *
38 * For instance to register {@link Functions#osm_id}, {@code FACTORY_MAP.put("osm_id", Factory.ofEnv(Functions::osm_id))}
39 */
40 @Test
41 void testNoUnregisteredFunctions() {
42 for (Method m : Functions.class.getDeclaredMethods()) {
43 if (!Modifier.isPrivate(m.getModifiers()) && !ExpressionFactory.FACTORY_MAP.containsKey(m.getName())) {
44 throw new AssertionError(m + " has not registered in ExpressionFactory.FACTORY_MAP");
45 }
46 }
47 }
48}
Note: See TracBrowser for help on using the repository browser.