Skip to content

Commit

Permalink
Make integrity check messages more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-openai committed Aug 28, 2024
1 parent 67c0ec0 commit fd859f0
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand All @@ -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());
}
}

Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -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());
}
}

Expand All @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand All @@ -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.");
}
}

Expand Down

0 comments on commit fd859f0

Please sign in to comment.