From 842689f0c1b64523830302b611e4932acd5a3797 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Tue, 19 Dec 2017 12:06:12 -0800 Subject: [PATCH] Use method references when possible ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179586059 --- .../tools/server/ListObjectsAction.java | 3 +- ...xpandRecurringBillingEventsActionTest.java | 4 +- .../domain/DomainTransferApproveFlowTest.java | 4 +- .../groups/DirectoryGroupsConnectionTest.java | 4 +- .../registry/rde/imports/RdeParserTest.java | 19 +-- .../google/registry/tools/AuthModuleTest.java | 2 +- .../tools/CreateContactCommandTest.java | 2 +- .../tools/CreatePremiumListCommandTest.java | 2 +- .../registry/tools/CreateTldCommandTest.java | 2 +- .../tools/GenerateAuctionDataCommandTest.java | 2 +- .../tools/GetApplicationCommandTest.java | 2 +- .../tools/GetApplicationIdsCommandTest.java | 2 +- .../registry/tools/GetContactCommandTest.java | 2 +- .../registry/tools/GetDomainCommandTest.java | 2 +- .../registry/tools/GetHostCommandTest.java | 2 +- .../tools/GetLrpTokenCommandTest.java | 2 +- .../tools/GetRegistrarCommandTest.java | 2 +- .../tools/GetResourceByKeyCommandTest.java | 2 +- .../registry/tools/GetTldCommandTest.java | 2 +- .../registry/tools/MutatingCommandTest.java | 122 +++++++++--------- .../tools/RegistryToolEnvironmentTest.java | 2 +- .../registry/tools/UpdateTldCommandTest.java | 2 +- 22 files changed, 90 insertions(+), 98 deletions(-) diff --git a/java/google/registry/tools/server/ListObjectsAction.java b/java/google/registry/tools/server/ListObjectsAction.java index 1438b4dd8..d8e456e3c 100644 --- a/java/google/registry/tools/server/ListObjectsAction.java +++ b/java/google/registry/tools/server/ListObjectsAction.java @@ -185,8 +185,7 @@ public abstract class ListObjectsAction implements Ru fieldMap.putAll(getFieldOverrides(object)); // Next, add to the mapping all the aliases, with their values defined as whatever was in the // map under the aliased field's original name. - fieldMap.putAll( - new HashMap<>(Maps.transformValues(getFieldAliases(), value -> fieldMap.get(value)))); + fieldMap.putAll(new HashMap<>(Maps.transformValues(getFieldAliases(), fieldMap::get))); Set expectedFields = ImmutableSortedSet.copyOf(fieldMap.keySet()); for (String field : fields) { checkArgument(fieldMap.containsKey(field), diff --git a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java index dc7cdae34..c395af52a 100644 --- a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java +++ b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java @@ -646,7 +646,7 @@ public class ExpandRecurringBillingEventsActionTest public void testFailure_cursorAfterExecutionTime() throws Exception { action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1)); IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> runMapreduce()); + expectThrows(IllegalArgumentException.class, this::runMapreduce); assertThat(thrown) .hasMessageThat() .contains("Cursor time must be earlier than execution time."); @@ -657,7 +657,7 @@ public class ExpandRecurringBillingEventsActionTest // The clock advances one milli on runMapreduce. action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1)); IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> runMapreduce()); + expectThrows(IllegalArgumentException.class, this::runMapreduce); assertThat(thrown) .hasMessageThat() .contains("Cursor time must be earlier than execution time."); diff --git a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java index a87ac7511..8ea2deec7 100644 --- a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -276,7 +276,7 @@ public class DomainTransferApproveFlowTest .setEventTime(domain.getRegistrationExpirationTime()) .setParent(historyEntryTransferApproved) .build())) - .toArray(size -> new BillingEvent[size])); + .toArray(BillingEvent[]::new)); // There should be a grace period for the new transfer billing event. assertGracePeriods( domain.getGracePeriods(), @@ -311,7 +311,7 @@ public class DomainTransferApproveFlowTest .setEventTime(domain.getRegistrationExpirationTime()) .setParent(historyEntryTransferApproved) .build())) - .toArray(size -> new BillingEvent[size])); + .toArray(BillingEvent[]::new)); // There should be no grace period. assertGracePeriods(domain.getGracePeriods(), ImmutableMap.of()); } diff --git a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java index 515ba4647..9e4b16482 100644 --- a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java +++ b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java @@ -114,7 +114,7 @@ public class DirectoryGroupsConnectionTest { public void test_addMemberToGroup_handlesExceptionThrownByDirectoryService() throws Exception { when(membersInsert.execute()).thenThrow( makeResponseException(SC_INTERNAL_SERVER_ERROR, "Could not contact Directory server.")); - assertThrows(GoogleJsonResponseException.class, () -> runAddMemberTest()); + assertThrows(GoogleJsonResponseException.class, this::runAddMemberTest); } @Test @@ -178,7 +178,7 @@ public class DirectoryGroupsConnectionTest { public void test_createGroup_handlesExceptionThrownByDirectoryService() throws Exception { when(groupsInsert.execute()).thenThrow( makeResponseException(SC_INTERNAL_SERVER_ERROR, "Could not contact Directory server.")); - assertThrows(GoogleJsonResponseException.class, () -> runCreateGroupTest()); + assertThrows(GoogleJsonResponseException.class, this::runCreateGroupTest); } @Test diff --git a/javatests/google/registry/rde/imports/RdeParserTest.java b/javatests/google/registry/rde/imports/RdeParserTest.java index 7a40d43e3..5c9f5f516 100644 --- a/javatests/google/registry/rde/imports/RdeParserTest.java +++ b/javatests/google/registry/rde/imports/RdeParserTest.java @@ -74,8 +74,7 @@ public class RdeParserTest { @Test public void testGetContactNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getContact()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getContact); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeContact-1.0:contact"); @@ -159,8 +158,7 @@ public class RdeParserTest { @Test public void testGetDomainNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getDomain()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getDomain); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeDomain-1.0:domain"); @@ -272,8 +270,7 @@ public class RdeParserTest { @Test public void testGetHostNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getHost()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getHost); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeHost-1.0:host"); @@ -387,7 +384,7 @@ public class RdeParserTest { public void testGetRegistrarNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getRegistrar()); + expectThrows(IllegalStateException.class, parser::getRegistrar); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeRegistrar-1.0:registrar"); @@ -426,8 +423,7 @@ public class RdeParserTest { @Test public void testGetNndnNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getNndn()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getNndn); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeNNDN-1.0:NNDN"); @@ -465,8 +461,7 @@ public class RdeParserTest { @Test public void testGetIdnNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getIdn()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, parser::getIdn); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeIDN-1.0:idnTableRef"); @@ -507,7 +502,7 @@ public class RdeParserTest { public void testGetEppParamsNotAtElement_throwsIllegalStateException() throws Exception { try (RdeParser parser = new RdeParser(xml)) { IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> parser.getEppParams()); + expectThrows(IllegalStateException.class, parser::getEppParams); assertThat(thrown) .hasMessageThat() .contains("Not at element urn:ietf:params:xml:ns:rdeEppParams-1.0:eppParams"); diff --git a/javatests/google/registry/tools/AuthModuleTest.java b/javatests/google/registry/tools/AuthModuleTest.java index a817c67b3..390b8b59d 100644 --- a/javatests/google/registry/tools/AuthModuleTest.java +++ b/javatests/google/registry/tools/AuthModuleTest.java @@ -127,6 +127,6 @@ public class AuthModuleTest { public void test_provideCredential_notStored() { // Doing this without the mock setup should cause us to throw an exception because the // credential has not been stored. - assertThrows(AuthModule.LoginRequiredException.class, () -> getCredential()); + assertThrows(AuthModule.LoginRequiredException.class, this::getCredential); } } diff --git a/javatests/google/registry/tools/CreateContactCommandTest.java b/javatests/google/registry/tools/CreateContactCommandTest.java index e277db2e1..023eed385 100644 --- a/javatests/google/registry/tools/CreateContactCommandTest.java +++ b/javatests/google/registry/tools/CreateContactCommandTest.java @@ -60,7 +60,7 @@ public class CreateContactCommandTest extends EppToolCommandTestCase runCommandForced()); + assertThrows(ParameterException.class, this::runCommandForced); } @Test diff --git a/javatests/google/registry/tools/CreatePremiumListCommandTest.java b/javatests/google/registry/tools/CreatePremiumListCommandTest.java index 1dfdb9e91..3c511deae 100644 --- a/javatests/google/registry/tools/CreatePremiumListCommandTest.java +++ b/javatests/google/registry/tools/CreatePremiumListCommandTest.java @@ -102,7 +102,7 @@ public class CreatePremiumListCommandTest @Test public void testRun_noInputFileSpecified_throwsException() throws Exception { - ParameterException thrown = expectThrows(ParameterException.class, () -> runCommand()); + ParameterException thrown = expectThrows(ParameterException.class, this::runCommand); assertThat(thrown).hasMessageThat().contains("The following option is required"); } diff --git a/javatests/google/registry/tools/CreateTldCommandTest.java b/javatests/google/registry/tools/CreateTldCommandTest.java index c59f49b05..6592a8194 100644 --- a/javatests/google/registry/tools/CreateTldCommandTest.java +++ b/javatests/google/registry/tools/CreateTldCommandTest.java @@ -434,7 +434,7 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testFailure_noTldName() throws Exception { - ParameterException thrown = expectThrows(ParameterException.class, () -> runCommandForced()); + ParameterException thrown = expectThrows(ParameterException.class, this::runCommandForced); assertThat(thrown) .hasMessageThat() .contains("Main parameters are required (\"Names of the TLDs\")"); diff --git a/javatests/google/registry/tools/GenerateAuctionDataCommandTest.java b/javatests/google/registry/tools/GenerateAuctionDataCommandTest.java index 1a9c91da1..a08945052 100644 --- a/javatests/google/registry/tools/GenerateAuctionDataCommandTest.java +++ b/javatests/google/registry/tools/GenerateAuctionDataCommandTest.java @@ -321,7 +321,7 @@ public class GenerateAuctionDataCommandTest extends CommandTestCase runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/GetApplicationCommandTest.java b/javatests/google/registry/tools/GetApplicationCommandTest.java index 13841b2e6..de73e8952 100644 --- a/javatests/google/registry/tools/GetApplicationCommandTest.java +++ b/javatests/google/registry/tools/GetApplicationCommandTest.java @@ -88,7 +88,7 @@ public class GetApplicationCommandTest extends CommandTestCase runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/GetApplicationIdsCommandTest.java b/javatests/google/registry/tools/GetApplicationIdsCommandTest.java index 64f38720e..5b5b18408 100644 --- a/javatests/google/registry/tools/GetApplicationIdsCommandTest.java +++ b/javatests/google/registry/tools/GetApplicationIdsCommandTest.java @@ -78,7 +78,7 @@ public class GetApplicationIdsCommandTest extends CommandTestCase runCommand()); + assertThrows(ParameterException.class, this::runCommand); } private void persistDomainApplication(String domainName, String repoId) { diff --git a/javatests/google/registry/tools/GetContactCommandTest.java b/javatests/google/registry/tools/GetContactCommandTest.java index b7b22f4e2..4542f392e 100644 --- a/javatests/google/registry/tools/GetContactCommandTest.java +++ b/javatests/google/registry/tools/GetContactCommandTest.java @@ -80,7 +80,7 @@ public class GetContactCommandTest extends CommandTestCase { @Test public void testFailure_noContact() throws Exception { - assertThrows(ParameterException.class, () -> runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/GetDomainCommandTest.java b/javatests/google/registry/tools/GetDomainCommandTest.java index 3e9503dab..6a4c2241b 100644 --- a/javatests/google/registry/tools/GetDomainCommandTest.java +++ b/javatests/google/registry/tools/GetDomainCommandTest.java @@ -96,7 +96,7 @@ public class GetDomainCommandTest extends CommandTestCase { @Test public void testFailure_noDomainName() throws Exception { - assertThrows(ParameterException.class, () -> runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/GetHostCommandTest.java b/javatests/google/registry/tools/GetHostCommandTest.java index 50e7b50e6..30e9bf215 100644 --- a/javatests/google/registry/tools/GetHostCommandTest.java +++ b/javatests/google/registry/tools/GetHostCommandTest.java @@ -107,6 +107,6 @@ public class GetHostCommandTest extends CommandTestCase { @Test public void testFailure_noHostName() throws Exception { - assertThrows(ParameterException.class, () -> runCommand()); + assertThrows(ParameterException.class, this::runCommand); } } diff --git a/javatests/google/registry/tools/GetLrpTokenCommandTest.java b/javatests/google/registry/tools/GetLrpTokenCommandTest.java index a1174bcef..89d67ff32 100644 --- a/javatests/google/registry/tools/GetLrpTokenCommandTest.java +++ b/javatests/google/registry/tools/GetLrpTokenCommandTest.java @@ -82,7 +82,7 @@ public class GetLrpTokenCommandTest extends CommandTestCase @Test public void testFailure_noArgs() throws Exception { IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> runCommand()); + expectThrows(IllegalArgumentException.class, this::runCommand); assertThat(thrown) .hasMessageThat() .contains("Exactly one of either token or assignee must be specified."); diff --git a/javatests/google/registry/tools/GetRegistrarCommandTest.java b/javatests/google/registry/tools/GetRegistrarCommandTest.java index 5213061d6..7e26e9259 100644 --- a/javatests/google/registry/tools/GetRegistrarCommandTest.java +++ b/javatests/google/registry/tools/GetRegistrarCommandTest.java @@ -45,7 +45,7 @@ public class GetRegistrarCommandTest extends CommandTestCase runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/GetResourceByKeyCommandTest.java b/javatests/google/registry/tools/GetResourceByKeyCommandTest.java index 33c80dae7..6cba7581c 100644 --- a/javatests/google/registry/tools/GetResourceByKeyCommandTest.java +++ b/javatests/google/registry/tools/GetResourceByKeyCommandTest.java @@ -224,6 +224,6 @@ public class GetResourceByKeyCommandTest extends CommandTestCase runCommand()); + assertThrows(ParameterException.class, this::runCommand); } } diff --git a/javatests/google/registry/tools/GetTldCommandTest.java b/javatests/google/registry/tools/GetTldCommandTest.java index 2297db4b9..7bfff2849 100644 --- a/javatests/google/registry/tools/GetTldCommandTest.java +++ b/javatests/google/registry/tools/GetTldCommandTest.java @@ -44,7 +44,7 @@ public class GetTldCommandTest extends CommandTestCase { @Test public void testFailure_noTldName() throws Exception { - assertThrows(ParameterException.class, () -> runCommand()); + assertThrows(ParameterException.class, this::runCommand); } @Test diff --git a/javatests/google/registry/tools/MutatingCommandTest.java b/javatests/google/registry/tools/MutatingCommandTest.java index 4a69c312b..6df0cd25a 100644 --- a/javatests/google/registry/tools/MutatingCommandTest.java +++ b/javatests/google/registry/tools/MutatingCommandTest.java @@ -295,22 +295,21 @@ public class MutatingCommandTest { stageEntityChange(null, null); } }; - assertThrows(IllegalArgumentException.class, () -> command.init()); + assertThrows(IllegalArgumentException.class, command::init); } @Test public void testFailure_updateSameEntityTwice() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - protected void init() { - stageEntityChange(host1, newHost1); - stageEntityChange(host1, host1.asBuilder() - .setLastEppUpdateTime(DateTime.now(UTC)) - .build()); - } - }; - IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> command.init()); + MutatingCommand command = + new MutatingCommand() { + @Override + protected void init() { + stageEntityChange(host1, newHost1); + stageEntityChange( + host1, host1.asBuilder().setLastEppUpdateTime(DateTime.now(UTC)).build()); + } + }; + IllegalArgumentException thrown = expectThrows(IllegalArgumentException.class, command::init); assertThat(thrown) .hasMessageThat() .contains("Cannot apply multiple changes for the same entity"); @@ -324,8 +323,7 @@ public class MutatingCommandTest { stageEntityChange(host1, host2); } }; - IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> command.init()); + IllegalArgumentException thrown = expectThrows(IllegalArgumentException.class, command::init); assertThat(thrown) .hasMessageThat() .contains("Both entity versions in an update must have the same Key."); @@ -333,14 +331,14 @@ public class MutatingCommandTest { @Test public void testFailure_updateDifferentStringId() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - public void init() { - stageEntityChange(registrar1, registrar2); - } - }; - IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> command.init()); + MutatingCommand command = + new MutatingCommand() { + @Override + public void init() { + stageEntityChange(registrar1, registrar2); + } + }; + IllegalArgumentException thrown = expectThrows(IllegalArgumentException.class, command::init); assertThat(thrown) .hasMessageThat() .contains("Both entity versions in an update must have the same Key."); @@ -348,14 +346,14 @@ public class MutatingCommandTest { @Test public void testFailure_updateDifferentKind() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - public void init() { - stageEntityChange(host1, registrar1); - } - }; - IllegalArgumentException thrown = - expectThrows(IllegalArgumentException.class, () -> command.init()); + MutatingCommand command = + new MutatingCommand() { + @Override + public void init() { + stageEntityChange(host1, registrar1); + } + }; + IllegalArgumentException thrown = expectThrows(IllegalArgumentException.class, command::init); assertThat(thrown) .hasMessageThat() .contains("Both entity versions in an update must have the same Key."); @@ -363,61 +361,61 @@ public class MutatingCommandTest { @Test public void testFailure_updateModifiedEntity() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - public void init() { - stageEntityChange(host1, newHost1); - } - }; + MutatingCommand command = + new MutatingCommand() { + @Override + public void init() { + stageEntityChange(host1, newHost1); + } + }; command.init(); persistResource(newHost1); - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> command.execute()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, command::execute); assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called."); } @Test public void testFailure_createExistingEntity() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - protected void init() { - stageEntityChange(null, newHost1); - } - }; + MutatingCommand command = + new MutatingCommand() { + @Override + protected void init() { + stageEntityChange(null, newHost1); + } + }; command.init(); persistResource(newHost1); - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> command.execute()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, command::execute); assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called."); } @Test public void testFailure_deleteChangedEntity() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - protected void init() { - stageEntityChange(host1, null); - } - }; + MutatingCommand command = + new MutatingCommand() { + @Override + protected void init() { + stageEntityChange(host1, null); + } + }; command.init(); persistResource(newHost1); - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> command.execute()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, command::execute); assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called."); } @Test public void testFailure_deleteRemovedEntity() throws Exception { - MutatingCommand command = new MutatingCommand() { - @Override - protected void init() { - stageEntityChange(host1, null); - } - }; + MutatingCommand command = + new MutatingCommand() { + @Override + protected void init() { + stageEntityChange(host1, null); + } + }; command.init(); deleteResource(host1); - IllegalStateException thrown = - expectThrows(IllegalStateException.class, () -> command.execute()); + IllegalStateException thrown = expectThrows(IllegalStateException.class, command::execute); assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called."); } } diff --git a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java index 4ff23f349..de6597b36 100644 --- a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java +++ b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java @@ -27,7 +27,7 @@ public class RegistryToolEnvironmentTest { @Test public void testGet_withoutSetup_throws() throws Exception { - assertThrows(IllegalStateException.class, () -> RegistryToolEnvironment.get()); + assertThrows(IllegalStateException.class, RegistryToolEnvironment::get); } @Test diff --git a/javatests/google/registry/tools/UpdateTldCommandTest.java b/javatests/google/registry/tools/UpdateTldCommandTest.java index 535f41025..099a831e8 100644 --- a/javatests/google/registry/tools/UpdateTldCommandTest.java +++ b/javatests/google/registry/tools/UpdateTldCommandTest.java @@ -736,7 +736,7 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_noTldName() throws Exception { - ParameterException thrown = expectThrows(ParameterException.class, () -> runCommandForced()); + ParameterException thrown = expectThrows(ParameterException.class, this::runCommandForced); assertThat(thrown) .hasMessageThat() .contains("Main parameters are required (\"Names of the TLDs\")");