CompositeFormatIntegrityChecker extends RegexIntegrityChecker { @Override public void check(String sourceContent, String targetContent) throws CompositeFormatIntegrityCheckerException { try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { throw new CompositeFormatIntegrityCheckerException(rce); } }  @Override String getRegex(); @Override void check(String sourceContent, String targetContent);  }
@Test public void testNoPlaceholder() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "No placeholder"; String target = "Pas de placholder"; checker.check(source, target); }
@Test public void testBase() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "Failed to grant {0} access to {1}"; String target = "Echec en donnant {0} accès à {1}"; checker.check(source, target); }
@Test public void testMustache() { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "A {{mustache}} template"; String target = "Un modėle {{mustache}}"; checker.check(source, target); }
@Test(expected = CompositeFormatIntegrityCheckerException.class) public void testMustacheInvalidMissingCurlyBraces() { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "A {{mustache}} template"; String target = "Un modėle {mustache}"; checker.check(source, target); }
@Test(expected = CompositeFormatIntegrityCheckerException.class) public void testMustacheInvalidMissingPlaceholder() { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "A {{mustache}} template"; String target = "Un modėle"; checker.check(source, target); }
@Test(expected = CompositeFormatIntegrityCheckerException.class) public void testMissingPlaceholder() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "{1}"; String target = ""; checker.check(source, target); }
@Test public void testInvertedPlaceholder() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "{0} {1}"; String target = "{1} {0}"; checker.check(source, target); }
@Test public void testCharactersAroundPlaceholder() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "'{0}' copied"; String target = "\"{0}\" copiado"; checker.check(source, target); }
@Test public void testCurlyBraces() throws CompositeFormatIntegrityCheckerException { CompositeFormatIntegrityChecker checker = new CompositeFormatIntegrityChecker(); String source = "{0:0.00}% used"; String target = "{0:0.00}% usados"; checker.check(source, target); }