TrailingWhitespaceIntegrityChecker extends RegexIntegrityChecker { @Override public void check(String sourceContent, String targetContent) throws TrailingWhitespaceIntegrityCheckerException { logger.debug("Get trailing whitespaces of the target"); String sourceTrailingWhiteSpaces = getTrailingWhiteSpaces(sourceContent); logger.debug("Source trailing whitespaces: {}", sourceTrailingWhiteSpaces); logger.debug("Get trailing whitespaces of the source"); String targetTrailingWhiteSpaces = getTrailingWhiteSpaces(targetContent); logger.debug("Target trailing whitespaces: {}", targetTrailingWhiteSpaces); logger.debug("Make sure the target has the same trailing whitespaces as the source"); if (!StringUtils.equals(sourceTrailingWhiteSpaces, targetTrailingWhiteSpaces)) { throw new TrailingWhitespaceIntegrityCheckerException("Trailing whitespaces in source and target are different"); } }  @Override String getRegex(); @Override void check(String sourceContent, String targetContent);  }
@Test public void testTrailingWhitespaceCheckWorks() { String source = "There are %1 files and %2 folders \n"; String target = "Il y a %1 fichiers et %2 dossiers \n"; checker.check(source, target); }
@Test public void testTrailingWhitespaceCheckWorksWithoutTrailingWhitespaces() { String source = "There are %1 files and %2 folders"; String target = "Il y a %1 fichiers et %2 dossiers"; checker.check(source, target); }
@Test(expected = TrailingWhitespaceIntegrityCheckerException.class) public void testTrailingWhitespaceCheckCatchesRemovedNewline() { String source = "There are %1 files and %2 folders\n"; String target = "Il y a %1 fichiers et %2 dossiers"; checker.check(source, target); }
@Test(expected = TrailingWhitespaceIntegrityCheckerException.class) public void testTrailingWhitespaceCheckCatchesRemovedSpace() { String source = "There are %1 files and %2 folders "; String target = "Il y a %1 fichiers et %2 dossiers"; checker.check(source, target); }
@Test(expected = TrailingWhitespaceIntegrityCheckerException.class) public void testTrailingWhitespaceCheckCatchesDifferentTrailingWhitespaces() { String source = "There are %1 files and %2 folders \n"; String target = "Il y a %1 fichiers et %2 dossiers\n "; checker.check(source, target); }