mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 17:28:25 +02:00
Remove unnecessary "throws" declarations
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=201058582
This commit is contained in:
parent
a7256f5edd
commit
5d80f124ca
377 changed files with 2297 additions and 2373 deletions
|
@ -29,59 +29,59 @@ public class DateParameterTest {
|
|||
private final DateParameter instance = new DateParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_onlyDate() throws Exception {
|
||||
public void testConvert_onlyDate() {
|
||||
String exampleDate = "2014-01-01";
|
||||
assertThat(instance.convert(exampleDate)).isEqualTo(DateTime.parse("2014-01-01T00:00:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_numeric_throwsException() throws Exception {
|
||||
public void testConvert_numeric_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("1234"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_validDateAndTime_throwsException() throws Exception {
|
||||
public void testConvert_validDateAndTime_throwsException() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> instance.convert("2014-01-01T01:02:03.004Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_invalidDate_throwsException() throws Exception {
|
||||
public void testConvert_invalidDate_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-13-33"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throwsException() throws Exception {
|
||||
public void testConvert_null_throwsException() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throwsException() throws Exception {
|
||||
public void testConvert_empty_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throwsException() throws Exception {
|
||||
public void testConvert_sillyString_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_partialDate_throwsException() throws Exception {
|
||||
public void testConvert_partialDate_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_onlyTime_throwsException() throws Exception {
|
||||
public void testConvert_onlyTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("T01:02:03"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_partialDateAndPartialTime_throwsException() throws Exception {
|
||||
public void testConvert_partialDateAndPartialTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("9T9"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_dateAndPartialTime_throwsException() throws Exception {
|
||||
public void testConvert_dateAndPartialTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01-01T01:02"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,88 +30,88 @@ public class DateTimeParameterTest {
|
|||
private final DateTimeParameter instance = new DateTimeParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_numeric_returnsMillisFromEpochUtc() throws Exception {
|
||||
public void testConvert_numeric_returnsMillisFromEpochUtc() {
|
||||
assertThat(instance.convert("1234")).isEqualTo(new DateTime(1234L, UTC));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_iso8601_returnsSameAsDateTimeParse() throws Exception {
|
||||
public void testConvert_iso8601_returnsSameAsDateTimeParse() {
|
||||
String exampleDate = "2014-01-01T01:02:03.004Z";
|
||||
assertThat(instance.convert(exampleDate))
|
||||
.isEqualTo(DateTime.parse(exampleDate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_isoDateTimeWithMillis_returnsSameAsDateTimeParse() throws Exception {
|
||||
public void testConvert_isoDateTimeWithMillis_returnsSameAsDateTimeParse() {
|
||||
String exampleDate = "2014-01-01T01:02:03.004Z";
|
||||
assertThat(instance.convert(exampleDate)).isEqualTo(DateTime.parse(exampleDate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_weirdTimezone_convertsToUtc() throws Exception {
|
||||
public void testConvert_weirdTimezone_convertsToUtc() {
|
||||
assertThat(instance.convert("1984-12-18T00:00:00-0520"))
|
||||
.isEqualTo(DateTime.parse("1984-12-18T05:20:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throwsException() throws Exception {
|
||||
public void testConvert_null_throwsException() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throwsException() throws Exception {
|
||||
public void testConvert_empty_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throwsException() throws Exception {
|
||||
public void testConvert_sillyString_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_partialDate_throwsException() throws Exception {
|
||||
public void testConvert_partialDate_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_onlyDate_throwsException() throws Exception {
|
||||
public void testConvert_onlyDate_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01-01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_partialTime_throwsException() throws Exception {
|
||||
public void testConvert_partialTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("T01:02"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_onlyTime_throwsException() throws Exception {
|
||||
public void testConvert_onlyTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("T01:02:03"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_partialDateAndPartialTime_throwsException() throws Exception {
|
||||
public void testConvert_partialDateAndPartialTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("9T9"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_dateAndPartialTime_throwsException() throws Exception {
|
||||
public void testConvert_dateAndPartialTime_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01-01T01:02"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_noTimeZone_throwsException() throws Exception {
|
||||
public void testConvert_noTimeZone_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2014-01-01T01:02:03"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_sillyString_throwsParameterException() throws Exception {
|
||||
public void testValidate_sillyString_throwsParameterException() {
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("--time=foo not an ISO");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_correctInput_doesntThrow() throws Exception {
|
||||
public void testValidate_correctInput_doesntThrow() {
|
||||
instance.validate("--time", "123");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,57 +30,57 @@ public class DurationParameterTest {
|
|||
private final DurationParameter instance = new DurationParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_isoHours() throws Exception {
|
||||
public void testConvert_isoHours() {
|
||||
assertThat(instance.convert("PT36H")).isEqualTo(Duration.standardHours(36));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_isoDaysAndHours() throws Exception {
|
||||
public void testConvert_isoDaysAndHours() {
|
||||
assertThat(instance.convert("P1DT12H")).isEqualTo(Duration.standardHours(36));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_isoLowercase_isAllowed() throws Exception {
|
||||
public void testConvert_isoLowercase_isAllowed() {
|
||||
assertThat(instance.convert("pt36h")).isEqualTo(Duration.standardHours(36));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsoMissingP_notAllowed() throws Exception {
|
||||
public void testIsoMissingP_notAllowed() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Period.parse("T36H"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsoMissingPT_notAllowed() throws Exception {
|
||||
public void testIsoMissingPT_notAllowed() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Period.parse("36H"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_isoMissingP_notAllowed() throws Exception {
|
||||
public void testConvert_isoMissingP_notAllowed() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("T36H"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throws() throws Exception {
|
||||
public void testConvert_null_throws() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throws() throws Exception {
|
||||
public void testConvert_empty_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_numeric_throws() throws Exception {
|
||||
public void testConvert_numeric_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("1234"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throws() throws Exception {
|
||||
public void testConvert_sillyString_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
public void testValidate_sillyString_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("--time=foo not an");
|
||||
|
|
|
@ -31,12 +31,12 @@ public class EnumParameterTest {
|
|||
private final TldStateParameter instance = new TldStateParameter();
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertEnum() throws Exception {
|
||||
public void testSuccess_convertEnum() {
|
||||
assertThat(instance.convert("PREDELEGATION")).isEqualTo(TldState.PREDELEGATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badValue() throws Exception {
|
||||
public void testFailure_badValue() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("GENERAL_SUNRUSH"));
|
||||
assertThat(thrown)
|
||||
|
|
|
@ -27,25 +27,25 @@ public class HostAndPortParameterTest {
|
|||
private final HostAndPortParameter instance = new HostAndPortParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_hostOnly() throws Exception {
|
||||
public void testConvert_hostOnly() {
|
||||
assertThat(instance.convert("foo.bar").getHost()).isEqualTo("foo.bar");
|
||||
assertThat(instance.convert("foo.bar").getPortOrDefault(31337)).isEqualTo(31337);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_hostAndPort() throws Exception {
|
||||
public void testConvert_hostAndPort() {
|
||||
assertThat(instance.convert("foo.bar:1234").getHost()).isEqualTo("foo.bar");
|
||||
assertThat(instance.convert("foo.bar:1234").getPortOrDefault(31337)).isEqualTo(1234);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_ipv6_hostOnly() throws Exception {
|
||||
public void testConvert_ipv6_hostOnly() {
|
||||
assertThat(instance.convert("[feed:a:bee]").getHost()).isEqualTo("feed:a:bee");
|
||||
assertThat(instance.convert("[feed:a:bee]").getPortOrDefault(31337)).isEqualTo(31337);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_ipv6_hostAndPort() throws Exception {
|
||||
public void testConvert_ipv6_hostAndPort() {
|
||||
assertThat(instance.convert("[feed:a:bee]:1234").getHost()).isEqualTo("feed:a:bee");
|
||||
assertThat(instance.convert("[feed:a:bee]:1234").getPortOrDefault(31337)).isEqualTo(1234);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class IntervalParameterTest {
|
|||
private final IntervalParameter instance = new IntervalParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert() throws Exception {
|
||||
public void testConvert() {
|
||||
assertThat(instance.convert("2004-06-09T12:30:00Z/2004-07-10T13:30:00Z"))
|
||||
.isEqualTo(new Interval(
|
||||
DateTime.parse("2004-06-09T12:30:00Z"),
|
||||
|
@ -38,34 +38,34 @@ public class IntervalParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_singleDate() throws Exception {
|
||||
public void testConvert_singleDate() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("2004-06-09T12:30:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_backwardsInterval() throws Exception {
|
||||
public void testConvert_backwardsInterval() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> instance.convert("2004-07-10T13:30:00Z/2004-06-09T12:30:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throws() throws Exception {
|
||||
public void testConvert_empty_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throws() throws Exception {
|
||||
public void testConvert_null_throws() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throws() throws Exception {
|
||||
public void testConvert_sillyString_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
public void testValidate_sillyString_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("--time=foo not an");
|
||||
|
|
|
@ -35,64 +35,64 @@ public class KeyValueMapParameterTest {
|
|||
private final CurrencyUnitToStringMap currencyUnitToStringMap = new CurrencyUnitToStringMap();
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString_singleEntry() throws Exception {
|
||||
public void testSuccess_convertStringToString_singleEntry() {
|
||||
assertThat(stringToStringInstance.convert("key=foo"))
|
||||
.isEqualTo(ImmutableMap.of("key", "foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToInteger_singleEntry() throws Exception {
|
||||
public void testSuccess_convertStringToInteger_singleEntry() {
|
||||
assertThat(stringToIntegerInstance.convert("key=1"))
|
||||
.isEqualTo(ImmutableMap.of("key", 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString_singleEntry() throws Exception {
|
||||
public void testSuccess_convertCurrencyUnitToString_singleEntry() {
|
||||
assertThat(currencyUnitToStringMap.convert("USD=123abc"))
|
||||
.isEqualTo(ImmutableMap.of(CurrencyUnit.USD, "123abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString() throws Exception {
|
||||
public void testSuccess_convertStringToString() {
|
||||
assertThat(stringToStringInstance.convert("key=foo,key2=bar"))
|
||||
.isEqualTo(ImmutableMap.of("key", "foo", "key2", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToInteger() throws Exception {
|
||||
public void testSuccess_convertStringToInteger() {
|
||||
assertThat(stringToIntegerInstance.convert("key=1,key2=2"))
|
||||
.isEqualTo(ImmutableMap.of("key", 1, "key2", 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString() throws Exception {
|
||||
public void testSuccess_convertCurrencyUnitToString() {
|
||||
assertThat(currencyUnitToStringMap.convert("USD=123abc,JPY=xyz789"))
|
||||
.isEqualTo(ImmutableMap.of(CurrencyUnit.USD, "123abc", CurrencyUnit.JPY, "xyz789"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString_empty() throws Exception {
|
||||
public void testSuccess_convertStringToString_empty() {
|
||||
assertThat(stringToStringInstance.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToInteger_empty() throws Exception {
|
||||
public void testSuccess_convertStringToInteger_empty() {
|
||||
assertThat(stringToIntegerInstance.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString_empty() throws Exception {
|
||||
public void testSuccess_convertCurrencyUnitToString_empty() {
|
||||
assertThat(currencyUnitToStringMap.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToInteger_badType() throws Exception {
|
||||
public void testFailure_convertStringToInteger_badType() {
|
||||
assertThrows(
|
||||
NumberFormatException.class, () -> stringToIntegerInstance.convert("key=1,key2=foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badType() throws Exception {
|
||||
public void testFailure_convertCurrencyUnitToString_badType() {
|
||||
IllegalCurrencyException thrown =
|
||||
assertThrows(
|
||||
IllegalCurrencyException.class,
|
||||
|
@ -101,36 +101,36 @@ public class KeyValueMapParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToString_badSeparator() throws Exception {
|
||||
public void testFailure_convertStringToString_badSeparator() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> stringToStringInstance.convert("key=foo&key2=bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToInteger_badSeparator() throws Exception {
|
||||
public void testFailure_convertStringToInteger_badSeparator() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> stringToIntegerInstance.convert("key=1&key2=2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badSeparator() throws Exception {
|
||||
public void testFailure_convertCurrencyUnitToString_badSeparator() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> currencyUnitToStringMap.convert("USD=123abc&JPY=xyz789"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToString_badFormat() throws Exception {
|
||||
public void testFailure_convertStringToString_badFormat() {
|
||||
assertThrows(IllegalArgumentException.class, () -> stringToStringInstance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToInteger_badFormat() throws Exception {
|
||||
public void testFailure_convertStringToInteger_badFormat() {
|
||||
assertThrows(IllegalArgumentException.class, () -> stringToIntegerInstance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badFormat() throws Exception {
|
||||
public void testFailure_convertCurrencyUnitToString_badFormat() {
|
||||
assertThrows(IllegalArgumentException.class, () -> currencyUnitToStringMap.convert("foo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,54 +29,54 @@ public class MoneyParameterTest {
|
|||
private final MoneyParameter instance = new MoneyParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_withCurrency() throws Exception {
|
||||
public void testConvert_withCurrency() {
|
||||
assertThat(instance.convert("USD 777.99")).isEqualTo(Money.parse("USD 777.99"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_negative() throws Exception {
|
||||
public void testConvert_negative() {
|
||||
assertThat(instance.convert("USD -777.99")).isEqualTo(Money.parse("USD -777.99"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_missingSpace_isForgiving() throws Exception {
|
||||
public void testConvert_missingSpace_isForgiving() {
|
||||
assertThat(instance.convert("USD777.99")).isEqualTo(Money.parse("USD 777.99"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_lowercase_isForgiving() throws Exception {
|
||||
public void testConvert_lowercase_isForgiving() {
|
||||
assertThat(instance.convert("usd777.99")).isEqualTo(Money.parse("USD 777.99"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_badCurrency_throws() throws Exception {
|
||||
public void testConvert_badCurrency_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("FOO 1337"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throws() throws Exception {
|
||||
public void testConvert_null_throws() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throws() throws Exception {
|
||||
public void testConvert_empty_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throws() throws Exception {
|
||||
public void testConvert_sillyString_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_sillyString_throws() throws Exception {
|
||||
public void testValidate_sillyString_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> instance.validate("--money", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("--money=foo not valid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_correctInput() throws Exception {
|
||||
public void testValidate_correctInput() {
|
||||
instance.validate("--money", "USD 777");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,17 +47,17 @@ public class PathParameterTest {
|
|||
private final PathParameter vanilla = new PathParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_etcPasswd_returnsPath() throws Exception {
|
||||
public void testConvert_etcPasswd_returnsPath() {
|
||||
assertThat((Object) vanilla.convert("/etc/passwd")).isEqualTo(Paths.get("/etc/passwd"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throws() throws Exception {
|
||||
public void testConvert_null_throws() {
|
||||
assertThrows(NullPointerException.class, () -> vanilla.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throws() throws Exception {
|
||||
public void testConvert_empty_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> vanilla.convert(""));
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class PathParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_uriNotProvided() throws Exception {
|
||||
public void testConvert_uriNotProvided() {
|
||||
assertThrows(FileSystemNotFoundException.class, () -> vanilla.convert("bog://bucket/lolcat"));
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class PathParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInputFileValidate_missingFile_throws() throws Exception {
|
||||
public void testInputFileValidate_missingFile_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
|
@ -102,7 +102,7 @@ public class PathParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInputFileValidate_directory_throws() throws Exception {
|
||||
public void testInputFileValidate_directory_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
|
@ -129,18 +129,18 @@ public class PathParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInputFileValidate_characterDeviceBehindSymbolicLinks_works() throws Exception {
|
||||
public void testInputFileValidate_characterDeviceBehindSymbolicLinks_works() {
|
||||
assumeTrue(Files.exists(Paths.get("/dev/stdin")));
|
||||
outputFile.validate("input", "/dev/stdin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutputFileValidate_missingFile_works() throws Exception {
|
||||
public void testOutputFileValidate_missingFile_works() {
|
||||
outputFile.validate("input", new File(folder.getRoot(), "foo").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutputFileValidate_directory_throws() throws Exception {
|
||||
public void testOutputFileValidate_directory_throws() {
|
||||
ParameterException thrown =
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
|
@ -158,7 +158,7 @@ public class PathParameterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOutputFileValidate_parentDirMissing_throws() throws Exception {
|
||||
public void testOutputFileValidate_parentDirMissing_throws() {
|
||||
Path file = Paths.get(folder.getRoot().toString(), "MISSINGNO", "foo.txt");
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
|
||||
|
|
|
@ -27,22 +27,22 @@ public class PhoneNumberParameterTest {
|
|||
private final OptionalPhoneNumberParameter instance = new OptionalPhoneNumberParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_e164() throws Exception {
|
||||
public void testConvert_e164() {
|
||||
assertThat(instance.convert("+1.2125550777")).hasValue("+1.2125550777");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throws() throws Exception {
|
||||
public void testConvert_sillyString_throws() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_returnsAbsent() throws Exception {
|
||||
public void testConvert_empty_returnsAbsent() {
|
||||
assertThat(instance.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_nullString_returnsAbsent() throws Exception {
|
||||
public void testConvert_nullString_returnsAbsent() {
|
||||
assertThat(instance.convert("null")).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,44 +29,44 @@ public class YearMonthParameterTest {
|
|||
private final YearMonthParameter instance = new YearMonthParameter();
|
||||
|
||||
@Test
|
||||
public void testConvert_awfulMonth() throws Exception {
|
||||
public void testConvert_awfulMonth() {
|
||||
assertThat(instance.convert("1984-12")).isEqualTo(new YearMonth(1984, 12));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_null_throwsException() throws Exception {
|
||||
public void testConvert_null_throwsException() {
|
||||
assertThrows(NullPointerException.class, () -> instance.convert(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_empty_throwsException() throws Exception {
|
||||
public void testConvert_empty_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_sillyString_throwsException() throws Exception {
|
||||
public void testConvert_sillyString_throwsException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_wrongOrder() throws Exception {
|
||||
public void testConvert_wrongOrder() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("12-1984"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_noHyphen() throws Exception {
|
||||
public void testConvert_noHyphen() {
|
||||
assertThrows(IllegalArgumentException.class, () -> instance.convert("198412"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_sillyString_throwsParameterException() throws Exception {
|
||||
public void testValidate_sillyString_throwsParameterException() {
|
||||
ParameterException thrown =
|
||||
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("--time=foo not a valid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidate_correctInput_doesntThrow() throws Exception {
|
||||
public void testValidate_correctInput_doesntThrow() {
|
||||
instance.validate("--time", "1984-12");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue