TextPatternUtil { public static List<Integer> replaceStringCodePoints(String stringToReplace, Random random) { List<Integer> codePoints = new ArrayList<>(); long numberCodePoints = stringToReplace.codePoints().count(); for (int i = 0; i < numberCodePoints; i++) { Integer codePoint = stringToReplace.codePointAt(i); codePoints.add(replaceCharacter(codePoint, random)); } return codePoints; } private  TextPatternUtil(); static String findPattern(String stringToRecognize); static Integer replaceCharacter(Integer codePointToReplace, Random random); static List<Integer> replaceStringCodePoints(String stringToReplace, Random random); static char[] replacePatternCharacter(Integer codePointToReplace, Random random); static Set<CharPattern> getCharPatterns(List<Integer> codePoints, List<Integer> filteredCodepoints); static CharPattern getCharPattern(Integer codepoint); static final int PROLONGED_SOUND_MARK; }
@Test public void replaceStringCodePointsWithMulticharacter() { Random random = new Random(123); String input = "abc"; String changedCharacter = "eom"; for (int i = 0; i < input.length(); i++) { String inputChar = input.substring(i, i + 1); String replaceChar = changedCharacter.substring(i, i + 1); Integer codePoint = replaceChar.codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(inputChar, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); } }
@Test public void replaceStringCodePointsWithoneCharacterFromMultiCharacter() { Random random = new Random(123); String input = "testFor@hooseOnecharater"; String replaceByCharacter = input.substring(7); if (replaceByCharacter == "@") { Integer codePoint = "9".codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(replaceByCharacter, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); } }
@Test public void replaceStringCodePointsWithInvalidReplace() { Random random = new Random(123); String input = "test@sina.com"; String replaceByCharacter = input.substring(4); if (replaceByCharacter == "@") { Integer codePoint = "9".codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(replaceByCharacter, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); } }
@Test public void replaceStringCodePointsFromMulticharacter() { Random random = new Random(123); String input = "b"; Integer codePoint = "feiop".codePointAt(1); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(input, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); }
@Test public void replaceStringCodePointsWithOnecharacter() { Random random = new Random(123); String input = "c"; Integer codePoint = "e".codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(input, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); }
@Test public void replaceStringCodePointsWithOneNumber() { Random random = new Random(123); String input = "8"; Integer codePoint = "2".codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(input, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); }
@Test public void replaceStringCodePointsWithOneCapital() { Random random = new Random(123); String input = "P"; Integer codePoint = "E".codePointAt(0); List<Integer> repalceStringCodePoint = TextPatternUtil.replaceStringCodePoints(input, random); assertEquals(codePoint, repalceStringCodePoint.get(0)); }