Automatically refactor more exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178911894
This commit is contained in:
mcilwain
2017-12-27 10:42:36 -05:00
committed by Ben McIlwain
parent 36ad38e5df
commit 7dc224627f
125 changed files with 1970 additions and 1982 deletions
@@ -17,6 +17,7 @@ package google.registry.export;
import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -33,7 +34,6 @@ import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -41,9 +41,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class DatastoreBackupServiceTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule
public final InjectRule inject = new InjectRule();
@@ -119,13 +116,11 @@ public class DatastoreBackupServiceTest {
@Test
public void testFailure_findByName_multipleMatchingBackups() throws Exception {
thrown.expect(IllegalArgumentException.class);
backupService.findByName("backupA");
assertThrows(IllegalArgumentException.class, () -> backupService.findByName("backupA"));
}
@Test
public void testFailure_findByName_noMatchingBackups() throws Exception {
thrown.expect(IllegalArgumentException.class);
backupService.findByName("backupX");
assertThrows(IllegalArgumentException.class, () -> backupService.findByName("backupX"));
}
}