Merge JUnitBackport's expectThrows into assertThrows

More information: https://github.com/junit-team/junit5/issues/531

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187034408
This commit is contained in:
cushon 2018-02-26 09:38:17 -08:00 committed by jianglai
parent f96a0b7da9
commit 606b470cd0
180 changed files with 1325 additions and 1381 deletions

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
@ -107,7 +106,7 @@ public class DateTimeParameterTest {
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
ParameterException thrown =
expectThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThat(thrown).hasMessageThat().contains("--time=foo not an ISO");
}

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.beust.jcommander.ParameterException;
import org.joda.time.Duration;
@ -83,7 +82,7 @@ public class DurationParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
ParameterException thrown =
expectThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThat(thrown).hasMessageThat().contains("--time=foo not an");
}
}

View file

@ -15,7 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.model.registry.Registry.TldState;
import org.junit.Test;
@ -38,7 +38,7 @@ public class EnumParameterTest {
@Test
public void testFailure_badValue() throws Exception {
IllegalArgumentException thrown =
expectThrows(IllegalArgumentException.class, () -> instance.convert("GENERAL_SUNRUSH"));
assertThrows(IllegalArgumentException.class, () -> instance.convert("GENERAL_SUNRUSH"));
assertThat(thrown)
.hasMessageThat()
.contains(

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
@ -68,7 +67,7 @@ public class IntervalParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
ParameterException thrown =
expectThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThat(thrown).hasMessageThat().contains("--time=foo not an");
}
}

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableMap;
import google.registry.tools.params.KeyValueMapParameter.CurrencyUnitToStringMap;
@ -95,7 +94,7 @@ public class KeyValueMapParameterTest {
@Test
public void testFailure_convertCurrencyUnitToString_badType() throws Exception {
IllegalCurrencyException thrown =
expectThrows(
assertThrows(
IllegalCurrencyException.class,
() -> currencyUnitToStringMap.convert("USD=123abc,XYZ=xyz789"));
assertThat(thrown).hasMessageThat().contains("XYZ");

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.beust.jcommander.ParameterException;
import org.joda.money.Money;
@ -72,7 +71,7 @@ public class MoneyParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
ParameterException thrown =
expectThrows(ParameterException.class, () -> instance.validate("--money", "foo"));
assertThrows(ParameterException.class, () -> instance.validate("--money", "foo"));
assertThat(thrown).hasMessageThat().contains("--money=foo not valid");
}

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@ -96,7 +95,7 @@ public class PathParameterTest {
@Test
public void testInputFileValidate_missingFile_throws() throws Exception {
ParameterException thrown =
expectThrows(
assertThrows(
ParameterException.class,
() -> inputFile.validate("input", new File(folder.getRoot(), "foo").toString()));
assertThat(thrown).hasMessageThat().contains("not found");
@ -105,7 +104,7 @@ public class PathParameterTest {
@Test
public void testInputFileValidate_directory_throws() throws Exception {
ParameterException thrown =
expectThrows(
assertThrows(
ParameterException.class,
() -> inputFile.validate("input", folder.getRoot().toString()));
assertThat(thrown).hasMessageThat().contains("is a directory");
@ -116,7 +115,7 @@ public class PathParameterTest {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("-w-------"));
ParameterException thrown =
expectThrows(ParameterException.class, () -> inputFile.validate("input", file.toString()));
assertThrows(ParameterException.class, () -> inputFile.validate("input", file.toString()));
assertThat(thrown).hasMessageThat().contains("not readable");
}
@ -143,7 +142,7 @@ public class PathParameterTest {
@Test
public void testOutputFileValidate_directory_throws() throws Exception {
ParameterException thrown =
expectThrows(
assertThrows(
ParameterException.class,
() -> outputFile.validate("input", folder.getRoot().toString()));
assertThat(thrown).hasMessageThat().contains("is a directory");
@ -154,7 +153,7 @@ public class PathParameterTest {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("r--------"));
ParameterException thrown =
expectThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThat(thrown).hasMessageThat().contains("not writable");
}
@ -162,7 +161,7 @@ public class PathParameterTest {
public void testOutputFileValidate_parentDirMissing_throws() throws Exception {
Path file = Paths.get(folder.getRoot().toString(), "MISSINGNO", "foo.txt");
ParameterException thrown =
expectThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThat(thrown).hasMessageThat().contains("parent dir doesn't exist");
}
@ -170,7 +169,7 @@ public class PathParameterTest {
public void testOutputFileValidate_parentDirIsFile_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString(), "foo.txt");
ParameterException thrown =
expectThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThrows(ParameterException.class, () -> outputFile.validate("input", file.toString()));
assertThat(thrown).hasMessageThat().contains("parent is non-directory");
}
}

View file

@ -16,7 +16,6 @@ package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.beust.jcommander.ParameterException;
import org.joda.time.YearMonth;
@ -62,7 +61,7 @@ public class YearMonthParameterTest {
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
ParameterException thrown =
expectThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThrows(ParameterException.class, () -> instance.validate("--time", "foo"));
assertThat(thrown).hasMessageThat().contains("--time=foo not a valid");
}