1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.view;
17
18 import org.junit.Test;
19
20 import java.util.Arrays;
21 import java.util.List;
22 import java.util.regex.Matcher;
23
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26
27 public class DefaultExpressionEvaluatorTest {
28 @Test
29 public void testServerEvaluationPattern() {
30 List<String> shouldMatch = Arrays.asList(
31 "(getSomething() || isSomething())",
32 "(getThis())", "(#getService('test'))");
33
34 for (String input: shouldMatch) {
35 Matcher matcher = DefaultExpressionEvaluator.SERVER_EVALUATION_PATTERN.matcher(input);
36 assertTrue("Should match server evaluation pattern. input: " + input, matcher.find());
37 }
38
39
40 List<String> shouldNotMatch = Arrays.asList(
41 "(newCollectionLines['listOfItems'].id == null) or (newCollectionLines['listOfItems'].id == '')",
42 "(newCollectionLines['budgetItems'].id == null) or (newCollectionLines['budgetItems'].id == '')",
43 "(listOfItems.id == null)",
44 "(budgetItems.id == null)",
45 "(setThis())");
46 for (String input: shouldNotMatch) {
47 Matcher matcher = DefaultExpressionEvaluator.SERVER_EVALUATION_PATTERN.matcher(input);
48 assertFalse("Should not match server evaluation pattern. input: " + input, matcher.find());
49 }
50 }
51 }
52