mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 00:42:12 +02:00
Get rid of custom ExceptionRule methods
The only remaining methods on ExceptionRule after this are methods that also exist on ExpectedException, which will allow us to, in the next CL, swap out the one for the other and then run the automated refactoring to turn it all into assertThrows/expectThrows. Note that there were some assertions about root causes that couldn't easily be turned into ExpectedException invocations, so I simply converted them directly to usages of assertThrows/expectThrows. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178623431
This commit is contained in:
parent
68a26f5b6e
commit
b825a2b5a8
144 changed files with 1176 additions and 894 deletions
|
@ -120,7 +120,8 @@ public class DateTimeParameterTest {
|
|||
|
||||
@Test
|
||||
public void testValidate_sillyString_throwsParameterException() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--time=foo not an ISO");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--time=foo not an ISO");
|
||||
instance.validate("--time", "foo");
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@ public class DurationParameterTest {
|
|||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--time=foo not an");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--time=foo not an");
|
||||
instance.validate("--time", "foo");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ public class EnumParameterTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_badValue() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"No enum constant google.registry.model.registry.Registry.TldState.GENERAL_SUNRUSH");
|
||||
instance.convert("GENERAL_SUNRUSH");
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ public class IntervalParameterTest {
|
|||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--time=foo not an");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--time=foo not an");
|
||||
instance.validate("--time", "foo");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,8 @@ public class KeyValueMapParameterTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badType() throws Exception {
|
||||
thrown.expect(IllegalCurrencyException.class, "XYZ");
|
||||
thrown.expect(IllegalCurrencyException.class);
|
||||
thrown.expectMessage("XYZ");
|
||||
currencyUnitToStringMap.convert("USD=123abc,XYZ=xyz789");
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ public class MoneyParameterTest {
|
|||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--money=foo not valid");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--money=foo not valid");
|
||||
instance.validate("--money", "foo");
|
||||
}
|
||||
|
||||
|
|
|
@ -101,13 +101,15 @@ public class PathParameterTest {
|
|||
|
||||
@Test
|
||||
public void testInputFileValidate_missingFile_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "not found");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not found");
|
||||
inputFile.validate("input", new File(folder.getRoot(), "foo").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInputFileValidate_directory_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "is a directory");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("is a directory");
|
||||
inputFile.validate("input", folder.getRoot().toString());
|
||||
}
|
||||
|
||||
|
@ -115,7 +117,8 @@ public class PathParameterTest {
|
|||
public void testInputFileValidate_unreadableFile_throws() throws Exception {
|
||||
Path file = Paths.get(folder.newFile().toString());
|
||||
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("-w-------"));
|
||||
thrown.expect(ParameterException.class, "not readable");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not readable");
|
||||
inputFile.validate("input", file.toString());
|
||||
}
|
||||
|
||||
|
@ -141,7 +144,8 @@ public class PathParameterTest {
|
|||
|
||||
@Test
|
||||
public void testOutputFileValidate_directory_throws() throws Exception {
|
||||
thrown.expect(ParameterException.class, "is a directory");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("is a directory");
|
||||
outputFile.validate("input", folder.getRoot().toString());
|
||||
}
|
||||
|
||||
|
@ -149,21 +153,24 @@ public class PathParameterTest {
|
|||
public void testOutputFileValidate_notWritable_throws() throws Exception {
|
||||
Path file = Paths.get(folder.newFile().toString());
|
||||
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("r--------"));
|
||||
thrown.expect(ParameterException.class, "not writable");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not writable");
|
||||
outputFile.validate("input", file.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutputFileValidate_parentDirMissing_throws() throws Exception {
|
||||
Path file = Paths.get(folder.getRoot().toString(), "MISSINGNO", "foo.txt");
|
||||
thrown.expect(ParameterException.class, "parent dir doesn't exist");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("parent dir doesn't exist");
|
||||
outputFile.validate("input", file.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutputFileValidate_parentDirIsFile_throws() throws Exception {
|
||||
Path file = Paths.get(folder.newFile().toString(), "foo.txt");
|
||||
thrown.expect(ParameterException.class, "parent is non-directory");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("parent is non-directory");
|
||||
outputFile.validate("input", file.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ public class YearMonthParameterTest {
|
|||
|
||||
@Test
|
||||
public void testValidate_sillyString_throwsParameterException() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--time=foo not a valid");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--time=foo not a valid");
|
||||
instance.validate("--time", "foo");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue