From fd859f0520e418b27ac1a7adde73d04b3673d677 Mon Sep 17 00:00:00 2001 From: Jean Aurambault Date: Wed, 28 Aug 2024 11:43:28 -0700 Subject: [PATCH] Make integrity check messages more specific --- .../BackquoteIntegrityChecker.java | 3 ++- .../CompositeFormatIntegrityChecker.java | 3 ++- ...mpositeFormatIntegrityCheckerException.java | 6 +++--- .../MarkdownLinkIntegrityChecker.java | 2 +- .../PrintfLikeIntegrityChecker.java | 3 ++- ...PrintfLikeVariableTypeIntegrityChecker.java | 3 ++- .../PythonFStringIntegrityChecker.java | 3 ++- .../SimplePrintfLikeIntegrityChecker.java | 3 ++- .../integritychecker/URLIntegrityChecker.java | 2 +- .../URLIntegrityCheckerException.java | 6 +++--- ...ntLikeVariableTypeIntegrityCheckerTest.java | 18 ++++++++++++------ .../SimplePrintfLikeIntegrityCheckerTest.java | 6 ++++-- 12 files changed, 36 insertions(+), 22 deletions(-) diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/BackquoteIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/BackquoteIntegrityChecker.java index bccdd4dbbb..2cf281350a 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/BackquoteIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/BackquoteIntegrityChecker.java @@ -25,7 +25,8 @@ public void check(String sourceContent, String targetContent) try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { - throw new BackquoteIntegrityCheckerException((rce.getMessage())); + throw new BackquoteIntegrityCheckerException( + "Backquoted stings are different in source and target"); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityChecker.java index a69cf40eda..426be785e0 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityChecker.java @@ -18,7 +18,8 @@ public void check(String sourceContent, String targetContent) try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { - throw new CompositeFormatIntegrityCheckerException(rce); + throw new CompositeFormatIntegrityCheckerException( + "Composite Format placeholders in source and target are different"); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityCheckerException.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityCheckerException.java index 0349800d67..a2e6b4abe1 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityCheckerException.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/CompositeFormatIntegrityCheckerException.java @@ -3,9 +3,9 @@ /** * @author jaurambault */ -public class CompositeFormatIntegrityCheckerException extends RegexCheckerException { +public class CompositeFormatIntegrityCheckerException extends IntegrityCheckException { - public CompositeFormatIntegrityCheckerException(RegexCheckerException rce) { - super(rce.getMessage()); + public CompositeFormatIntegrityCheckerException(String message) { + super(message); } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/MarkdownLinkIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/MarkdownLinkIntegrityChecker.java index becdd96959..980dcc9f72 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/MarkdownLinkIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/MarkdownLinkIntegrityChecker.java @@ -29,7 +29,7 @@ public void check(String content, String target) { try { super.check(content, target); } catch (RegexCheckerException ex) { - throw new MarkdownLinkIntegrityCheckerException("Variable types do not match."); + throw new MarkdownLinkIntegrityCheckerException("Markdown Links do not match."); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeIntegrityChecker.java index 0031cc4ec2..61f5f36fa3 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeIntegrityChecker.java @@ -29,7 +29,8 @@ public void check(String sourceContent, String targetContent) try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { - throw new PrintfLikeIntegrityCheckerException((rce.getMessage())); + throw new PrintfLikeIntegrityCheckerException( + "PrintfLikeLike placeholders are different in source and target"); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeVariableTypeIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeVariableTypeIntegrityChecker.java index afe8dbc687..5fd2ebcca6 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeVariableTypeIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintfLikeVariableTypeIntegrityChecker.java @@ -22,7 +22,8 @@ public void check(String content, String target) { try { super.check(content, target); } catch (RegexCheckerException ex) { - throw new PrintfLikeVariableTypeIntegrityCheckerException("Variable types do not match."); + throw new PrintfLikeVariableTypeIntegrityCheckerException( + "PrintfLikeVariableType placeholder are different in source and target."); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PythonFStringIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PythonFStringIntegrityChecker.java index b4dea6bd3c..bbc216d483 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PythonFStringIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PythonFStringIntegrityChecker.java @@ -12,7 +12,8 @@ public void check(String content, String target) { try { super.check(content, target); } catch (RegexCheckerException ex) { - throw new PythonFStringIntegrityCheckerException("Variable types do not match."); + throw new PythonFStringIntegrityCheckerException( + "PythonFString placeholders are different in source and target."); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityChecker.java index df0f36e243..c6d19c264c 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityChecker.java @@ -22,7 +22,8 @@ public void check(String sourceContent, String targetContent) try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { - throw new SimplePrintfLikeIntegrityCheckerException((rce.getMessage())); + throw new SimplePrintfLikeIntegrityCheckerException( + "SimplePrintfLike placeholders are different in source and target."); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityChecker.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityChecker.java index 6d65594a06..e321906f7a 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityChecker.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityChecker.java @@ -23,7 +23,7 @@ public void check(String sourceContent, String targetContent) try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { - throw new URLIntegrityCheckerException(rce); + throw new URLIntegrityCheckerException("URLs in source and target are different"); } } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityCheckerException.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityCheckerException.java index d34c6e0c91..aa1a13948e 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityCheckerException.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/URLIntegrityCheckerException.java @@ -3,9 +3,9 @@ /** * @author jaurambault */ -public class URLIntegrityCheckerException extends RegexCheckerException { +public class URLIntegrityCheckerException extends IntegrityCheckException { - public URLIntegrityCheckerException(RegexCheckerException rce) { - super(rce.getMessage()); + public URLIntegrityCheckerException(String message) { + super(message); } } diff --git a/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintLikeVariableTypeIntegrityCheckerTest.java b/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintLikeVariableTypeIntegrityCheckerTest.java index 2f47fe968d..33a8f69fac 100644 --- a/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintLikeVariableTypeIntegrityCheckerTest.java +++ b/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/PrintLikeVariableTypeIntegrityCheckerTest.java @@ -27,7 +27,8 @@ public void testMissingVariableTypeCausesIntegrityViolation() checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } } @@ -42,7 +43,8 @@ public void testModifiedVariableTypeCausesIntegrityViolation() checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } } @@ -56,7 +58,8 @@ public void testVariableWithFormattingFlagChecked() { checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } source = "%(count) s view"; @@ -66,7 +69,8 @@ public void testVariableWithFormattingFlagChecked() { checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } source = "%(count).1f view"; @@ -76,7 +80,8 @@ public void testVariableWithFormattingFlagChecked() { checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } } @@ -90,7 +95,8 @@ public void testCurlyBracketsAreChecked() { checker.check(source, target); fail("PrintfLikeVariableTypeIntegrityCheckerException should have been thrown."); } catch (PrintfLikeVariableTypeIntegrityCheckerException e) { - assertEquals("Variable types do not match.", e.getMessage()); + assertEquals( + "PrintfLikeVariableType placeholder are different in source and target.", e.getMessage()); } } diff --git a/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityCheckerTest.java b/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityCheckerTest.java index ab514561ef..11cb8ed38d 100644 --- a/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityCheckerTest.java +++ b/webapp/src/test/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/SimplePrintfLikeIntegrityCheckerTest.java @@ -67,7 +67,8 @@ public void testPlaceholderCheckFailsIfDifferentPlaceholdersCount() checker.check(source, target); fail("SimplePrintfLikeIntegrityCheckerException must be thrown"); } catch (SimplePrintfLikeIntegrityCheckerException e) { - assertEquals(e.getMessage(), "Placeholders in source and target are different"); + assertEquals( + e.getMessage(), "SimplePrintfLike placeholders are different in source and target."); } } @@ -82,7 +83,8 @@ public void testPlaceholderCheckFailsIfSamePlaceholdersCountButSomeRepeatedOrMis checker.check(source, target); fail("SimplePrintfLikeIntegrityCheckerException must be thrown"); } catch (SimplePrintfLikeIntegrityCheckerException e) { - assertEquals(e.getMessage(), "Placeholders in source and target are different"); + assertEquals( + e.getMessage(), "SimplePrintfLike placeholders are different in source and target."); } }