FieldModifier { public Date generateDuplicate(Date date, Function function, int modifCount, String extraParameter) { if (date == null || function == null) { return date; } Date newDate = new Date(date.getTime()); switch (function) { case SET_TO_NULL: return null; case MODIFY_DATE_VALUE: for (int i = 0; i < modifCount; i++) { dateChanger.modifyDateValue(newDate); } return newDate; case SWITCH_DAY_MONTH_VALUE: for (int i = 0; i < modifCount; i++) { dateChanger.switchDayMonthValue(newDate); } return newDate; case REPLACE_BY_RANDOM_DATE: for (int i = 0; i < modifCount; i++) { dateChanger.replaceWithRandomDate(newDate); } return newDate; default: break; } return date; }  void setSeed(long seed); Date generateDuplicate(Date date, Function function, int modifCount, String extraParameter); String generateDuplicateString(String str, Function function, int modifCount, String extraParameter); Object generateDuplicate(Object obj, Function function, int modifCount, String extraParameter); Random getRandom(); static final String US_ENGLISH_MAPPING_STRING; }
@Test public void testSetToNull() { Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.SET_TO_NULL, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNull(dup); }
@Test public void testSetToBlank() { Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.SET_TO_BLANK, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EMPTY_STRING, dup); }
@Test public void testReplaceLetters() { String EXPECTED_WORD = "SuPesKeZ"; Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.REPLACE_LETTER, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_WORD, dup); }
@Test public void testAddLetters() { String EXPECTED_WORD = "SuresPKneZs"; Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.ADD_LETTER, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_WORD, dup); }
@Test public void testRemoveLetters() { String EXPECTED_WORD = "Suese"; Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.REMOVE_LETTER, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_WORD, dup); }
@Test public void testReplaceDigits() { String EXPECTED_NUMBER = "12120"; Object dup = dataModifier.generateDuplicate(NUMBER_TO_TEST, Function.REPLACE_DIGIT, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_NUMBER, dup); }
@Test public void testAddDigits() { String EXPECTED_NUMBER = "92121510"; Object dup = dataModifier.generateDuplicate(NUMBER_TO_TEST, Function.ADD_DIGIT, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_NUMBER, dup); }
@Test public void testRemoveDigits() { String EXPECTED_NUMBER = "92"; Object dup = dataModifier.generateDuplicate(NUMBER_TO_TEST, Function.REMOVE_DIGIT, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_NUMBER, dup); }
@Test public void testExchageChars() { String EXPECTED_WORD = "Susernes"; Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.EXCHANGE_CHAR, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_WORD, dup); }
@Test public void testSoundexReplace() { String EXPECTED_WORD = "Suresmek"; Object dup = dataModifier.generateDuplicate(STRING_TO_TEST, Function.SOUNDEX_REPLACE, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(EXPECTED_WORD, dup); }
@Test public void testGenerateDuplicateDateFunctionIntStringCase1() { FieldModifier fieldModifier = new FieldModifier(); Date generateDuplicate = fieldModifier.generateDuplicate(null, null, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNull(generateDuplicate); }
@Test public void testGenerateDuplicateDateFunctionIntStringCase2() { FieldModifier fieldModifier = new FieldModifier(); Date date = new Date(); Date generateDuplicate = fieldModifier.generateDuplicate(date, null, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertEquals(generateDuplicate, date); }
@Test public void testGenerateDuplicateDateFunctionIntStringCase3() { FieldModifier fieldModifier = new FieldModifier(); for (Function function : Function.values()) { Date generateDuplicate = fieldModifier.generateDuplicate(null, function, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNull(generateDuplicate); } }
@Test public void testGenerateDuplicateDateFunctionIntStringCase4() { FieldModifier fieldModifier = new FieldModifier(); Date date = new Date(); Date generateDuplicate = fieldModifier.generateDuplicate(date, Function.REPLACE_BY_RANDOM_DATE, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNotEquals(date, generateDuplicate); }
@Test public void testGenerateDuplicateDateFunctionIntStringCase5() { FieldModifier fieldModifier = new FieldModifier(); Date date = new Date(); Date generateDuplicate = fieldModifier.generateDuplicate(date, Function.MODIFY_DATE_VALUE, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNotEquals(date, generateDuplicate); }
@Test public void testGenerateDuplicateDateFunctionIntStringCase6() { FieldModifier fieldModifier = new FieldModifier(); LocalDate localeDate = LocalDate.now(); if (localeDate.getDayOfMonth() == localeDate.getMonthValue()) { localeDate = localeDate.plusDays(1); } Date date = Date.from(localeDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); Date generateDuplicate = fieldModifier.generateDuplicate(date, Function.SWITCH_DAY_MONTH_VALUE, DEFAULT_MODIF_COUNT, EMPTY_STRING); assertNotEquals(date, generateDuplicate); }