Skip to content

Commit 666411c

Browse files
author
mbhatia
committed
added test for custom preprocessing
1 parent 97a2fc3 commit 666411c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/test/java/com/intuit/fuzzymatcher/function/PreProcessFunctionTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.text.ParseException;
99
import java.text.SimpleDateFormat;
1010
import java.util.Date;
11+
import java.util.function.Function;
1112

1213
import static com.intuit.fuzzymatcher.domain.ElementType.*;
1314

@@ -20,12 +21,27 @@ public void itShouldRemoveSuffixFromName_Success(){
2021
}
2122

2223
@Test
23-
public void itShouldNotRemoveNameSuffixFromAddress_Success(){
24+
public void itShouldPreprocessAddress(){
2425
String value = "123 XYZ Ltd st, TX";
2526
Element element = new Element.Builder().setType(ADDRESS).setValue(value).createElement();
2627
Assert.assertEquals("123 xyz ltd street texas", element.getPreProcessedValue());
2728
}
2829

30+
@Test
31+
public void itShouldCustomPreprocessAddress(){
32+
String value = "123_XYZ_Ltd_st, TX";
33+
Function<String, String> customPreProcessing = (str -> str.replaceAll("_", " "));
34+
customPreProcessing = customPreProcessing.andThen(PreProcessFunction.addressPreprocessing());
35+
36+
Element element = new Element.Builder().setType(ADDRESS)
37+
.setPreProcessingFunction(customPreProcessing)
38+
.setValue(value)
39+
.createElement();
40+
41+
Assert.assertEquals("123 xyz ltd street texas", element.getPreProcessedValue());
42+
}
43+
44+
2945
@Test
3046
public void itShouldGetNullString_Success(){
3147
String value = " ";

0 commit comments

Comments
 (0)