1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.lookup;
17
18 import org.junit.Assert;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.kuali.rice.core.api.search.SearchOperator;
22
23 import java.util.Map;
24 import java.util.HashMap;
25
26
27
28
29
30
31 public class LookupUtilsTest {
32
33 @Test
34 public void testScrubQueryCharacters() {
35
36 Map<String, String> queryCharacterSamples = new HashMap<String, String>();
37 queryCharacterSamples.put(null, null);
38 queryCharacterSamples.put("", "");
39 queryCharacterSamples.put("this is a string with no query characters", "this is a string with no query characters");
40 queryCharacterSamples.put("this is a string with one.. query character", "this is a string with one query character");
41 queryCharacterSamples.put("..test...test", "testtest");
42 StringBuilder allQueryCharacters = new StringBuilder();
43 for (SearchOperator operator : SearchOperator.QUERY_CHARACTERS) {
44 allQueryCharacters.append(operator.op());
45 }
46 queryCharacterSamples.put(allQueryCharacters.toString(), "");
47
48
49 for (String input : queryCharacterSamples.keySet()) {
50 String output = queryCharacterSamples.get(input);
51 Assert.assertEquals("Check failed for input: " + input, output, LookupUtils.scrubQueryCharacters(input));
52 }
53 }
54
55
56
57 }