AlgorithmSwitch { public static String getAlgoResult(String algoName, String algoPara, String colValue) { BlockingKeyAlgorithmEnum typeBySavedValue = BlockingKeyAlgorithmEnum.getTypeBySavedValue(algoName); if (typeBySavedValue == null) { return StringUtils.EMPTY; } switch (typeBySavedValue) { case COLOGNEPHONETIC: return AlgoBox.colognePhonetic(colValue); case D_METAPHONE: return AlgoBox.doublemetaphone(colValue); case EXACT: return AlgoBox.exact(colValue); case FINGERPRINTKEY: return AlgoBox.fingerPrintKey(colValue); case FIRST_CHAR_EW: return AlgoBox.first_Char_EW(colValue); case FIRST_N_CHAR: return AlgoBox.first_N_Char(colValue, Integer.parseInt(algoPara)); case FIRST_N_CHAR_EW: return AlgoBox.first_N_Char_EW(colValue, Integer.parseInt(algoPara)); case FIRST_N_CONSONANTS: return AlgoBox.first_N_Consonants(colValue, Integer.parseInt(algoPara)); case FIRST_N_VOWELS: return AlgoBox.first_N_Vowels(colValue, Integer.parseInt(algoPara)); case LAST_N_CHAR: return AlgoBox.last_N_Char(colValue, Integer.parseInt(algoPara)); case METAPHONE: return AlgoBox.metaphone(colValue); case NGRAMKEY: return AlgoBox.nGramKey(colValue); case PICK_CHAR: return AlgoBox.pick_Char(colValue, algoPara); case SOUNDEX: return AlgoBox.soundex(colValue); case SUBSTR: return AlgoBox.subStr(colValue, algoPara); default: return StringUtils.EMPTY; } } private  AlgorithmSwitch(); static String getPreAlgoResult(String algoName, String algoPara, String colValue); static String getAlgoResult(String algoName, String algoPara, String colValue); static String getPostAlgoResult(String algoName, String algoPara, String colValue);  }
@Test public void testGetAlgoResult() { assertEquals(null, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.COLOGNEPHONETIC.getComponentValueName(), null, null)); assertEquals("282", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.COLOGNEPHONETIC.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.COLOGNEPHONETIC.getComponentValueName(), null, BLANK_STR)); assertEquals("65", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.COLOGNEPHONETIC.getComponentValueName(), null, NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.COLOGNEPHONETIC.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.D_METAPHONE.getComponentValueName(), null, null)); assertEquals("TST", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.D_METAPHONE.getComponentValueName(), null, TEST_STR)); assertEquals(null, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.D_METAPHONE.getComponentValueName(), null, BLANK_STR)); assertEquals("NL", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.D_METAPHONE.getComponentValueName(), null, NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.D_METAPHONE.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.EXACT.getComponentValueName(), null, null)); assertEquals(TEST_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.EXACT.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.EXACT.getComponentValueName(), null, BLANK_STR)); assertEquals(NULL_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.EXACT.getComponentValueName(), null, NULL_STR)); assertEquals(QUO_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.EXACT.getComponentValueName(), null, QUO_STR)); assertEquals(null, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FINGERPRINTKEY.getComponentValueName(), null, null)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FINGERPRINTKEY.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FINGERPRINTKEY.getComponentValueName(), null, BLANK_STR)); assertEquals(NULL_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FINGERPRINTKEY.getComponentValueName(), null, NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FINGERPRINTKEY.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_CHAR_EW.getComponentValueName(), null, null)); assertEquals("t", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_CHAR_EW.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_CHAR_EW.getComponentValueName(), null, BLANK_STR)); assertEquals("n", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_CHAR_EW.getComponentValueName(), null, NULL_STR)); assertEquals(QUO_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_CHAR_EW.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "1", null)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "4", TEST_STR)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "5", TEST_STR)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "-1", TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "1", BLANK_STR)); assertEquals("n", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "1", NULL_STR)); assertEquals(QUO_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR.getComponentValueName(), "1", QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "1", null)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "4", TEST_STR)); assertEquals(TEST_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "5", TEST_STR)); assertEquals("tt", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "1", "test\ntest")); assertEquals("tete", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "2", "test\ttest")); assertEquals("testes", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "3", "test\ftest")); assertEquals("tete", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "2", "test test")); assertEquals("testtest", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "4", "test\rtest")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "1", BLANK_STR)); assertEquals("n", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "1", NULL_STR)); assertEquals(QUO_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CHAR_EW.getComponentValueName(), "1", QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", null)); assertEquals("tst", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "2000", TEST_STR)); assertEquals("t", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", "test\ntest")); assertEquals("ts", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "2", "test\ttest")); assertEquals("tstts", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "5", "test test")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", BLANK_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", SPACE_STR)); assertEquals("n", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_CONSONANTS.getComponentValueName(), "1", QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", null)); assertEquals("e", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "2000", TEST_STR)); assertEquals("e", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", "test\ntest")); assertEquals("ee", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "2", "test\ttest")); assertEquals("ee", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "5", "test test")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", BLANK_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", SPACE_STR)); assertEquals("u", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.FIRST_N_VOWELS.getComponentValueName(), "1", QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", null)); assertEquals("test", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "2000", TEST_STR)); assertEquals("t", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", "test\ntest")); assertEquals("st", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "2", "test\ttest")); assertEquals(" test", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "5", "test test")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", BLANK_STR)); assertEquals(SPACE_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", SPACE_STR)); assertEquals("l", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", NULL_STR)); assertEquals(QUO_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.LAST_N_CHAR.getComponentValueName(), "1", QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, null)); assertEquals("TST", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, TEST_STR)); assertEquals("TSTT", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, "Test\ntest")); assertEquals("TSTT", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, "Test\ttest")); assertEquals("TSTT", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, "Test test123t")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, BLANK_STR)); assertEquals(SPACE_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, SPACE_STR)); assertEquals("NL", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, "Null")); assertEquals(QUO_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.METAPHONE.getComponentValueName(), null, QUO_STR)); assertEquals(null, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, null)); assertEquals("esstte", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, TEST_STR)); assertEquals("essttett", AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, "Test\ntest")); assertEquals("essttett", AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, "Test\ttest")); assertEquals("122aabbcesstt1tett", AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, "Test test12abc")); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, BLANK_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, SPACE_STR)); assertEquals("llnuul", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, NULL_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.NGRAMKEY.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), BLANK_STR, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "test", BLANK_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "test", null)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "test", TEST_STR)); assertEquals("etest", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "1-2;40;0-5", TEST_STR)); assertEquals("e", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "1-2", "Test test")); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), BLANK_STR, SPACE_STR)); assertEquals(BLANK_STR, AlgorithmSwitch .getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), SPACE_STR, TEST_STR)); AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.PICK_CHAR.getComponentValueName(), "1", QUO_STR); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, null)); assertEquals("T230", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, BLANK_STR)); assertEquals("T232", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, "Test test")); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, SPACE_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SOUNDEX.getComponentValueName(), null, QUO_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), BLANK_STR, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), null, TEST_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), TEST_STR, BLANK_STR)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), TEST_STR, null)); assertEquals(BLANK_STR, AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), SPACE_STR, TEST_STR)); assertEquals("est", AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), "1;100", TEST_STR)); AlgorithmSwitch.getAlgoResult(BlockingKeyAlgorithmEnum.SUBSTR.getComponentValueName(), "1;100", TEST_STR); }