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