Remove unnecessary type specifications

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179585680
This commit is contained in:
mcilwain 2017-12-19 12:03:43 -08:00 committed by Ben McIlwain
parent f1ae66d148
commit ed0670b614
52 changed files with 193 additions and 221 deletions

View file

@ -65,7 +65,7 @@ abstract class AugmentedDeleter implements Deleter {
// homogeneous iterables of a fixed Key<T> type, e.g. List<Key<Lock>>, and is convenient for
// callers) into the type Iterable<Key<?>> (a concrete type of heterogeneous keys, which is
// convenient for users).
handleDeletion(ImmutableList.<Key<?>>copyOf(keys));
handleDeletion(ImmutableList.copyOf(keys));
return delegate.keys(keys);
}

View file

@ -112,13 +112,13 @@ public class RestoreCommitLogsActionTest {
CommitLogManifest.create(
getBucketKey(1),
now.minusMinutes(3),
ImmutableSet.<Key<?>>of(Key.create(TestObject.create("previous to delete")))),
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))),
CommitLogMutation.create(manifest1aKey, TestObject.create("a")),
CommitLogMutation.create(manifest1aKey, TestObject.create("b")),
CommitLogManifest.create(
getBucketKey(2),
now.minusMinutes(2),
ImmutableSet.<Key<?>>of(Key.create(TestObject.create("a")))),
ImmutableSet.of(Key.create(TestObject.create("a")))),
CommitLogMutation.create(manifest1bKey, TestObject.create("c")),
CommitLogMutation.create(manifest1bKey, TestObject.create("d")));
Iterable<ImmutableObject> file2CommitLogs = saveDiffFile(
@ -126,7 +126,7 @@ public class RestoreCommitLogsActionTest {
CommitLogManifest.create(
getBucketKey(1),
now.minusMinutes(1),
ImmutableSet.<Key<?>>of(Key.create(TestObject.create("c")))),
ImmutableSet.of(Key.create(TestObject.create("c")))),
CommitLogMutation.create(manifest2Key, TestObject.create("e")),
CommitLogMutation.create(manifest2Key, TestObject.create("f")));
action.fromTime = now.minusMinutes(1).minusMillis(1);
@ -150,7 +150,7 @@ public class RestoreCommitLogsActionTest {
assertExpectedIds("previous to keep");
assertInDatastore(commitLogs);
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
assertCommitLogBuckets(ImmutableMap.<Integer, DateTime>of());
assertCommitLogBuckets(ImmutableMap.of());
}
@Test
@ -183,7 +183,7 @@ public class RestoreCommitLogsActionTest {
CommitLogManifest.create(
getBucketKey(1),
now,
ImmutableSet.<Key<?>>of(Key.create(TestObject.create("previous to delete")))));
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
action.run();
ofy().clearSessionCache();
assertExpectedIds("previous to keep");
@ -236,7 +236,7 @@ public class RestoreCommitLogsActionTest {
CommitLogManifest.create(
getBucketKey(1),
now,
ImmutableSet.<Key<?>>of(Key.create(TestObject.create("previous to delete")))));
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
action.run();
ofy().clearSessionCache();
assertExpectedIds("previous to keep");
@ -252,7 +252,7 @@ public class RestoreCommitLogsActionTest {
private Iterable<ImmutableObject> saveDiffFile(
CommitLogCheckpoint checkpoint, ImmutableObject... entities) throws IOException {
DateTime now = checkpoint.getCheckpointTime();
List<ImmutableObject> allEntities = Lists.<ImmutableObject>asList(checkpoint, entities);
List<ImmutableObject> allEntities = Lists.asList(checkpoint, entities);
ByteArrayOutputStream output = new ByteArrayOutputStream();
for (ImmutableObject entity : allEntities) {
serializeEntity(entity, output);

View file

@ -86,7 +86,7 @@ public class CheckSnapshotActionTest {
new DatastoreBackupInfo(
backupInfo.getName(),
backupInfo.getStartTime(),
Optional.<DateTime>empty(),
Optional.empty(),
backupInfo.getKinds(),
backupInfo.getGcsFilename());

View file

@ -96,10 +96,12 @@ public class ExportReservedTermsActionTest {
@Test
public void test_uploadFileToDrive_doesNothingIfReservedListsNotConfigured() throws Exception {
persistResource(Registry.get("tld").asBuilder()
.setReservedLists(ImmutableSet.<ReservedList>of())
.setDriveFolderId(null)
.build());
persistResource(
Registry.get("tld")
.asBuilder()
.setReservedLists(ImmutableSet.of())
.setDriveFolderId(null)
.build());
runAction("tld");
verify(response).setStatus(SC_OK);
verify(response).setPayload("No reserved lists configured");

View file

@ -154,11 +154,11 @@ public class SyncGroupMembersActionTest {
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
when(connection.getMembersOfGroup("newregistrar-marketing-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.<String> of());
.thenReturn(ImmutableSet.of());
when(connection.getMembersOfGroup("theregistrar-technical-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.<String> of());
.thenReturn(ImmutableSet.of());
when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.<String> of());
.thenReturn(ImmutableSet.of());
persistResource(
new RegistrarContact.Builder()
.setParent(loadRegistrar("NewRegistrar"))
@ -200,7 +200,7 @@ public class SyncGroupMembersActionTest {
@Test
public void test_doPost_gracefullyHandlesExceptionForSingleRegistrar() throws Exception {
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.<String> of());
.thenReturn(ImmutableSet.of());
when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example"))
.thenThrow(new IOException("Internet was deleted"));
runAction();

View file

@ -101,8 +101,7 @@ public class EppControllerTest extends ShardableTestCase {
loggerToIntercept.addHandler(logHandler);
when(sessionMetadata.getClientId()).thenReturn("some-client");
when(flowComponentBuilder.flowModule(Matchers.<FlowModule>any()))
.thenReturn(flowComponentBuilder);
when(flowComponentBuilder.flowModule(Matchers.any())).thenReturn(flowComponentBuilder);
when(flowComponentBuilder.build()).thenReturn(flowComponent);
when(flowComponent.flowRunner()).thenReturn(flowRunner);
when(eppOutput.isResponse()).thenReturn(true);

View file

@ -86,7 +86,7 @@ public class EppLifecycleContactTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"contact_create_sh8013.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
DateTime.parse("2000-06-01T00:00:00Z"));

View file

@ -52,7 +52,7 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase {
DateTime startTime = DateTime.parse("2000-06-01T00:00:00Z");
assertCommandAndResponse(
"contact_create_sh8013.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
startTime);

View file

@ -53,7 +53,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
DateTime startTime = DateTime.parse("2000-06-01T00:00:00Z");
assertCommandAndResponse(
"contact_create_sh8013.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
startTime);

View file

@ -49,7 +49,7 @@ public class EppLifecycleHostTest extends EppTestCase {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertCommandAndResponse(
"hello.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"greeting.xml",
ImmutableMap.of("DATE", "2000-06-02T00:00:00Z"),
DateTime.parse("2000-06-02T00:00:00Z"));
@ -78,7 +78,7 @@ public class EppLifecycleHostTest extends EppTestCase {
"host_info.xml",
ImmutableMap.of("HOSTNAME", "ns1.example.tld"),
"host_info_response.xml",
ImmutableMap.<String, String>of(
ImmutableMap.of(
"HOSTNAME", "ns1.example.tld", "ROID", "1-ROID", "CRDATE", "2000-06-02T00:01:00Z"),
DateTime.parse("2000-06-02T00:02:00Z"));
assertThat(getRecordedEppMetric())
@ -93,7 +93,7 @@ public class EppLifecycleHostTest extends EppTestCase {
"host_delete.xml",
ImmutableMap.of("HOSTNAME", "ns1.example.tld"),
"generic_success_action_pending_response.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
DateTime.parse("2000-06-02T00:03:00Z"));
assertThat(getRecordedEppMetric())
.hasClientId("NewRegistrar")
@ -113,7 +113,7 @@ public class EppLifecycleHostTest extends EppTestCase {
// Create the fakesite domain.
assertCommandAndResponse(
"contact_create_sh8013.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
DateTime.parse("2000-06-01T00:00:00Z"));
@ -164,7 +164,7 @@ public class EppLifecycleHostTest extends EppTestCase {
assertCommandAndResponse(
"contact_create_sh8013.xml",
ImmutableMap.<String, String>of(),
ImmutableMap.of(),
"contact_create_response_sh8013.xml",
ImmutableMap.of("CRDATE", "2000-06-01T00:00:00Z"),
DateTime.parse("2000-06-01T00:00:00Z"));

View file

@ -137,7 +137,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test
public void testRecordToLogs_metadata_notResourceFlow_noResourceTypeOrTld() throws Exception {
when(flowReporter.eppInput.isDomainResourceType()).thenReturn(false);
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.<String>empty());
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.empty());
flowReporter.recordToLogs();
Map<String, Object> json =
parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-METADATA: "));
@ -177,7 +177,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test
public void testRecordToLogs_metadata_multipleTargetIds_uniqueTldSet() throws Exception {
when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true);
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.<String>empty());
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.empty());
when(flowReporter.eppInput.getTargetIds())
.thenReturn(ImmutableList.of("target.co.uk", "foo.uk", "bar.uk", "baz.com"));
flowReporter.recordToLogs();

View file

@ -79,7 +79,7 @@ public class FlowRunnerTest extends ShardableTestCase {
flowRunner.isSuperuser = false;
flowRunner.isTransactional = false;
flowRunner.sessionMetadata =
new StatelessRequestSessionMetadata("TheRegistrar", ImmutableSet.<String>of());
new StatelessRequestSessionMetadata("TheRegistrar", ImmutableSet.of());
flowRunner.trid = Trid.create("client-123", "server-456");
flowRunner.flowReporter = Mockito.mock(FlowReporter.class);
}

View file

@ -116,7 +116,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
}
protected void setEppInput(String inputFilename) {
eppLoader = new EppLoader(this, inputFilename, ImmutableMap.<String, String>of());
eppLoader = new EppLoader(this, inputFilename, ImmutableMap.of());
}
protected void setEppInput(String inputFilename, Map<String, String> substitutions) {

View file

@ -158,7 +158,7 @@ public class ChildEntityInputTest {
setupSecondDomainResources();
Set<ImmutableObject> seen = new HashSet<>();
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
.createReaders().get(0);
@ -188,16 +188,14 @@ public class ChildEntityInputTest {
@Test
public void testSuccess_childEntityInput_polymorphicBaseType() throws Exception {
createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(BillingEvent.class));
createChildEntityInput(ImmutableSet.of(EppResource.class), ImmutableSet.of(BillingEvent.class));
}
@Test
public void testSuccess_childEntityReader_multipleChildTypes() throws Exception {
setupResources();
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
.createReaders().get(0);
@ -235,7 +233,7 @@ public class ChildEntityInputTest {
public void testSuccess_childEntityReader_polymorphicChildFiltering() throws Exception {
setupResources();
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(BillingEvent.OneTime.class))
.createReaders().get(0);
assertThat(getAllFromReader(reader)).containsExactly(oneTimeA);
@ -245,7 +243,7 @@ public class ChildEntityInputTest {
public void testSuccess_childEntityReader_polymorphicChildClass() throws Exception {
setupResources();
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(BillingEvent.class))
.createReaders().get(0);
assertThat(getAllFromReader(reader)).containsExactly(oneTimeA, recurringA);
@ -303,11 +301,13 @@ public class ChildEntityInputTest {
public void testSuccess_childEntityReader_survivesAcrossSerialization() throws Exception {
setupResources();
Set<ImmutableObject> seen = new HashSet<>();
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
.createReaders().get(0);
InputReader<ImmutableObject> reader =
EppResourceInputs.createChildEntityInput(
ImmutableSet.of(EppResource.class),
ImmutableSet.<Class<? extends ImmutableObject>>of(
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
.createReaders()
.get(0);
reader.beginShard();
reader.beginSlice();
seen.add(reader.next());

View file

@ -269,7 +269,7 @@ public class ImmutableObjectTest {
assertThat((List<?>) diffableFieldMap.get("array")).containsExactly((Object) null);
assertThat((List<?>) diffableFieldMap.get("list")).containsExactly((Object) null);
assertThat((Set<?>) diffableFieldMap.get("set")).containsExactly((Object) null);
assertThat((Map<?, ?>) diffableFieldMap.get("map")).containsExactly("a", (Object) null);
assertThat((Map<?, ?>) diffableFieldMap.get("map")).containsExactly("a", null);
}
/** Subclass of ImmutableObject with keys to other objects. */

View file

@ -86,7 +86,7 @@ public class ModelUtilsTest {
@Test
public void testGetAllFields() throws Exception {
Map<String, Field> expected = ImmutableMap.<String, Field>of(
Map<String, Field> expected = ImmutableMap.of(
"id", TestClass.class.getDeclaredField("id"),
"a", TestClass.class.getDeclaredField("a"),
"b", TestClass.class.getDeclaredField("b"));

View file

@ -124,7 +124,7 @@ public class RegistrarCreditBalanceTest extends EntityTestCase {
@Test
public void testSuccess_balanceMap_getActiveBalance_emptyMap() throws Exception {
BalanceMap map = new BalanceMap(ImmutableMap.<DateTime, Map<DateTime, Money>>of());
BalanceMap map = new BalanceMap(ImmutableMap.of());
assertThat(map.getActiveBalanceAtTime(START_OF_TIME)).isEmpty();
assertThat(map.getActiveBalanceAtTime(clock.nowUtc())).isEmpty();
assertThat(map.getActiveBalanceAtTime(END_OF_TIME)).isEmpty();

View file

@ -63,7 +63,7 @@ public class TimeOfYearTest {
DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z");
DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z");
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z"));
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
ImmutableSet<DateTime> expected = ImmutableSet.of(
DateTime.parse("2012-05-01T00:00:00Z"),
DateTime.parse("2013-05-01T00:00:00Z"),
DateTime.parse("2014-05-01T00:00:00Z"),
@ -78,7 +78,7 @@ public class TimeOfYearTest {
DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z");
DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z");
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z"));
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
ImmutableSet<DateTime> expected = ImmutableSet.of(
DateTime.parse("2013-05-01T00:00:00Z"),
DateTime.parse("2014-05-01T00:00:00Z"),
DateTime.parse("2015-05-01T00:00:00Z"),
@ -92,7 +92,7 @@ public class TimeOfYearTest {
DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z");
DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z");
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z"));
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
ImmutableSet<DateTime> expected = ImmutableSet.of(
DateTime.parse("2012-05-01T00:00:00Z"),
DateTime.parse("2013-05-01T00:00:00Z"),
DateTime.parse("2014-05-01T00:00:00Z"),
@ -106,7 +106,7 @@ public class TimeOfYearTest {
DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z");
DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z");
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z"));
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
ImmutableSet<DateTime> expected = ImmutableSet.of(
DateTime.parse("2013-05-01T00:00:00Z"),
DateTime.parse("2014-05-01T00:00:00Z"),
DateTime.parse("2015-05-01T00:00:00Z"));
@ -117,10 +117,8 @@ public class TimeOfYearTest {
@Test
public void testSuccess_getInstancesInRange_normalizedLowerBound() {
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(START_OF_TIME);
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
START_OF_TIME,
START_OF_TIME.plusYears(1),
START_OF_TIME.plusYears(2));
ImmutableSet<DateTime> expected =
ImmutableSet.of(START_OF_TIME, START_OF_TIME.plusYears(1), START_OF_TIME.plusYears(2));
assertThat(timeOfYear.getInstancesInRange(Range.atMost(START_OF_TIME.plusYears(2))))
.containsExactlyElementsIn(expected);
}
@ -128,10 +126,8 @@ public class TimeOfYearTest {
@Test
public void testSuccess_getInstancesInRange_normalizedUpperBound() {
TimeOfYear timeOfYear = TimeOfYear.fromDateTime(END_OF_TIME);
ImmutableSet<DateTime> expected = ImmutableSet.<DateTime>of(
END_OF_TIME.minusYears(2),
END_OF_TIME.minusYears(1),
END_OF_TIME);
ImmutableSet<DateTime> expected =
ImmutableSet.of(END_OF_TIME.minusYears(2), END_OF_TIME.minusYears(1), END_OF_TIME);
assertThat(timeOfYear.getInstancesInRange(Range.atLeast(END_OF_TIME.minusYears(2))))
.containsExactlyElementsIn(expected);
}

View file

@ -148,7 +148,7 @@ public class TimedTransitionPropertyTest {
IllegalArgumentException.class,
() ->
TimedTransitionProperty.fromValueMap(
ImmutableSortedMap.<DateTime, String>of(), StringTimedTransition.class));
ImmutableSortedMap.of(), StringTimedTransition.class));
}
@Test

View file

@ -35,7 +35,6 @@ import google.registry.model.eppcommon.PresenceMarker;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.model.transfer.TransferStatus;
import org.junit.Before;
import org.junit.Test;
@ -101,8 +100,7 @@ public class ContactResourceTest extends EntityTestCase {
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(BillingEvent.OneTime.class, 1)))
ImmutableSet.of(Key.create(BillingEvent.OneTime.class, 1)))
.setTransferRequestTime(clock.nowUtc())
.setTransferStatus(TransferStatus.SERVER_APPROVED)
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))

View file

@ -37,7 +37,6 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.smd.EncodedSignedMark;
import org.joda.money.Money;
import org.junit.Before;
@ -123,16 +122,13 @@ public class DomainApplicationTest extends EntityTestCase {
@Test
public void testEmptySetsAndArraysBecomeNull() {
assertThat(emptyBuilder().setNameservers(null).build().nsHosts).isNull();
assertThat(emptyBuilder()
.setNameservers(ImmutableSet.<Key<HostResource>>of())
.build()
.nsHosts)
.isNull();
assertThat(emptyBuilder()
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
.build()
.nsHosts)
.isNotNull();
assertThat(emptyBuilder().setNameservers(ImmutableSet.of()).build().nsHosts).isNull();
assertThat(
emptyBuilder()
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
.build()
.nsHosts)
.isNotNull();
// This behavior should also hold true for ImmutableObjects nested in collections.
assertThat(emptyBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, null)))

View file

@ -50,7 +50,6 @@ import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.model.transfer.TransferStatus;
import java.util.stream.Stream;
import org.joda.money.Money;
@ -124,10 +123,7 @@ public class DomainResourceTest extends EntityTestCase {
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
oneTimeBillKey,
recurringBillKey,
autorenewPollKey))
ImmutableSet.of(oneTimeBillKey, recurringBillKey, autorenewPollKey))
.setServerApproveBillingEvent(oneTimeBillKey)
.setServerApproveAutorenewEvent(recurringBillKey)
.setServerApproveAutorenewPollMessage(autorenewPollKey)
@ -186,11 +182,15 @@ public class DomainResourceTest extends EntityTestCase {
@Test
public void testEmptySetsAndArraysBecomeNull() {
assertThat(newDomainResource("example.com").asBuilder()
.setNameservers(null).build().nsHosts).isNull();
assertThat(newDomainResource("example.com").asBuilder()
.setNameservers(ImmutableSet.<Key<HostResource>>of()).build().nsHosts)
.isNull();
assertThat(newDomainResource("example.com").asBuilder().setNameservers(null).build().nsHosts)
.isNull();
assertThat(
newDomainResource("example.com")
.asBuilder()
.setNameservers(ImmutableSet.of())
.build()
.nsHosts)
.isNull();
assertThat(newDomainResource("example.com").asBuilder()
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
.build().nsHosts)
@ -292,22 +292,27 @@ public class DomainResourceTest extends EntityTestCase {
.setPeriodYears(1)
.setParent(historyEntry)
.build());
domain = domain.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
.setTransferData(domain.getTransferData().asBuilder()
.setTransferStatus(TransferStatus.PENDING)
.setTransferRequestTime(clock.nowUtc().minusDays(4))
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
.setGainingClientId("winner")
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(transferBillingEvent)))
.build())
.addGracePeriod(
// Okay for billing event to be null since the point of this grace period is just
// to check that the transfer will clear all existing grace periods.
GracePeriod.create(GracePeriodStatus.ADD, clock.nowUtc().plusDays(100), "foo", null))
.build();
domain =
domain
.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
.setTransferData(
domain
.getTransferData()
.asBuilder()
.setTransferStatus(TransferStatus.PENDING)
.setTransferRequestTime(clock.nowUtc().minusDays(4))
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
.setGainingClientId("winner")
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
.setServerApproveEntities(ImmutableSet.of(Key.create(transferBillingEvent)))
.build())
.addGracePeriod(
// Okay for billing event to be null since the point of this grace period is just
// to check that the transfer will clear all existing grace periods.
GracePeriod.create(
GracePeriodStatus.ADD, clock.nowUtc().plusDays(100), "foo", null))
.build();
DomainResource afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1));
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
Key<BillingEvent.Recurring> serverApproveAutorenewEvent =

View file

@ -32,9 +32,7 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.model.transfer.TransferStatus;
import java.net.InetAddress;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
@ -52,21 +50,23 @@ public class HostResourceTest extends EntityTestCase {
public void setUp() throws Exception {
createTld("com");
// Set up a new persisted registrar entity.
domain = persistResource(
newDomainResource("example.com").asBuilder()
.setRepoId("1-COM")
.setTransferData(new TransferData.Builder()
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(BillingEvent.OneTime.class, 1)))
.setTransferRequestTime(clock.nowUtc())
.setTransferStatus(TransferStatus.SERVER_APPROVED)
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
.build())
.build());
domain =
persistResource(
newDomainResource("example.com")
.asBuilder()
.setRepoId("1-COM")
.setTransferData(
new TransferData.Builder()
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
.setServerApproveEntities(
ImmutableSet.of(Key.create(BillingEvent.OneTime.class, 1)))
.setTransferRequestTime(clock.nowUtc())
.setTransferStatus(TransferStatus.SERVER_APPROVED)
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
.build())
.build());
host =
persistResource(
cloneAndSetAutoTimestamps(
@ -119,9 +119,8 @@ public class HostResourceTest extends EntityTestCase {
@Test
public void testEmptySetsBecomeNull() throws Exception {
assertThat(new HostResource.Builder().setInetAddresses(null).build().inetAddresses).isNull();
assertThat(new HostResource.Builder()
.setInetAddresses(ImmutableSet.<InetAddress>of()).build().inetAddresses)
.isNull();
assertThat(new HostResource.Builder().setInetAddresses(ImmutableSet.of()).build().inetAddresses)
.isNull();
assertThat(
new HostResource.Builder()
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))

View file

@ -56,7 +56,7 @@ public class DomainApplicationIndexTest extends EntityTestCase {
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
() -> createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of()));
() -> createWithSpecifiedKeys("blah.com", ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("Keys must not be null or empty.");
}

View file

@ -159,7 +159,7 @@ public class OfyCommitLogTest {
@Test
public void testTransactNew_deleteNotBackedUpKind_throws() throws Exception {
final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.of());
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
@ -170,7 +170,7 @@ public class OfyCommitLogTest {
@Test
public void testTransactNew_saveNotBackedUpKind_throws() throws Exception {
final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.of());
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,

View file

@ -143,7 +143,7 @@ public class RegistryTest extends EntityTestCase {
.asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build();
assertThat(r.getReservedLists().stream().map(Key::getName).collect(toImmutableList()))
.containsExactly("tld-reserved5", "tld-reserved6");
r = Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.<ReservedList> of()).build();
r = Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of()).build();
assertThat(r.getReservedLists()).isEmpty();
}
@ -164,7 +164,7 @@ public class RegistryTest extends EntityTestCase {
.build();
assertThat(r.getReservedLists().stream().map(Key::getName).collect(toImmutableList()))
.containsExactly("tld-reserved24", "tld-reserved25");
r = Registry.get("tld").asBuilder().setReservedListsByName(ImmutableSet.<String> of()).build();
r = Registry.get("tld").asBuilder().setReservedListsByName(ImmutableSet.of()).build();
assertThat(r.getReservedLists()).isEmpty();
}

View file

@ -62,8 +62,7 @@ public class SignedMarkRevocationListTest {
public void testEmpty() throws Exception {
// When Datastore is empty, it should give us an empty thing.
assertThat(SignedMarkRevocationList.get())
.isEqualTo(SignedMarkRevocationList.create(
START_OF_TIME, ImmutableMap.<String, DateTime>of()));
.isEqualTo(SignedMarkRevocationList.create(START_OF_TIME, ImmutableMap.of()));
}
@Test
@ -114,7 +113,7 @@ public class SignedMarkRevocationListTest {
assertThrows(
NullPointerException.class,
() ->
SignedMarkRevocationList.create(START_OF_TIME, ImmutableMap.<String, DateTime>of())
SignedMarkRevocationList.create(START_OF_TIME, ImmutableMap.of())
.isSmdRevoked(null, clock.nowUtc()));
}

View file

@ -23,7 +23,6 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PollMessage;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.testing.AppEngineRule;
import org.joda.time.DateTime;
import org.junit.Before;
@ -74,7 +73,7 @@ public class TransferDataTest {
.setPendingTransferExpirationTime(now)
.setTransferStatus(TransferStatus.PENDING)
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
ImmutableSet.of(
transferBillingEventKey,
otherServerApproveBillingEventKey,
recurringBillingEventKey,

View file

@ -31,7 +31,6 @@ import google.registry.model.host.HostInfoData;
import google.registry.testing.AppEngineRule;
import google.registry.testing.EppLoader;
import google.registry.xml.ValidationMode;
import java.net.InetAddress;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -58,7 +57,7 @@ public class StatusValueAdapterTest {
.setCreationTime(START_OF_TIME)
.setCurrentSponsorClientId("")
.setFullyQualifiedHostName("")
.setInetAddresses(ImmutableSet.<InetAddress>of())
.setInetAddresses(ImmutableSet.of())
.setRepoId("")
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build())

View file

@ -26,11 +26,11 @@ import org.junit.runners.JUnit4;
/** Tests for {@link CustomFitter}. */
@RunWith(JUnit4.class)
public class CustomFitterTest {
@Test
public void testCreateCustomFitter_emptyBounds_throwsException() throws Exception {
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class, () -> CustomFitter.create(ImmutableSet.<Double>of()));
expectThrows(IllegalArgumentException.class, () -> CustomFitter.create(ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("boundaries must not be empty");
}
@ -45,7 +45,6 @@ public class CustomFitterTest {
@Test
public void testCreateCustomFitter_hasGivenBounds() {
CustomFitter fitter = CustomFitter.create(ImmutableSortedSet.of(1.0, 2.0));
assertThat(fitter.boundaries()).containsExactly(1.0, 2.0).inOrder();
}
}

View file

@ -43,20 +43,19 @@ public class MetricReporterTest {
@Test
public void testRunOneIteration_enqueuesBatch() throws Exception {
Metric<?> metric =
new Counter("/name", "description", "vdn", ImmutableSet.<LabelDescriptor>of());
Metric<?> metric = new Counter("/name", "description", "vdn", ImmutableSet.of());
when(registry.getRegisteredMetrics()).thenReturn(ImmutableList.of(metric, metric));
MetricReporter reporter = new MetricReporter(writer, 10L, threadFactory, registry, writeQueue);
reporter.runOneIteration();
verify(writeQueue).offer(Optional.of(ImmutableList.<MetricPoint<?>>of()));
verify(writeQueue).offer(Optional.of(ImmutableList.of()));
}
@Test
public void testShutDown_enqueuesBatchAndPoisonPill() throws Exception {
// Set up a registry with no metrics.
when(registry.getRegisteredMetrics()).thenReturn(ImmutableList.<Metric<?>>of());
when(registry.getRegisteredMetrics()).thenReturn(ImmutableList.of());
MetricReporter reporter =
spy(new MetricReporter(writer, 10L, threadFactory, registry, writeQueue));
@ -64,7 +63,7 @@ public class MetricReporterTest {
verify(reporter).runOneIteration();
InOrder interactions = Mockito.inOrder(writeQueue);
interactions.verify(writeQueue).offer(Optional.of(ImmutableList.<MetricPoint<?>>of()));
interactions.verify(writeQueue).offer(Optional.<ImmutableList<MetricPoint<?>>>empty());
interactions.verify(writeQueue).offer(Optional.of(ImmutableList.of()));
interactions.verify(writeQueue).offer(Optional.empty());
}
}

View file

@ -38,7 +38,7 @@ public class MetricSchemaTest {
"description",
"valueDisplayName",
Kind.GAUGE,
ImmutableSet.<LabelDescriptor>of()));
ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("Name must not be blank");
}
@ -49,11 +49,7 @@ public class MetricSchemaTest {
IllegalArgumentException.class,
() ->
MetricSchema.create(
"/name",
"",
"valueDisplayName",
Kind.GAUGE,
ImmutableSet.<LabelDescriptor>of()));
"/name", "", "valueDisplayName", Kind.GAUGE, ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("Description must not be blank");
}
@ -62,9 +58,7 @@ public class MetricSchemaTest {
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
() ->
MetricSchema.create(
"/name", "description", "", Kind.GAUGE, ImmutableSet.<LabelDescriptor>of()));
() -> MetricSchema.create("/name", "description", "", Kind.GAUGE, ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("Value Display Name must not be empty");
}
@ -75,11 +69,7 @@ public class MetricSchemaTest {
IllegalArgumentException.class,
() ->
MetricSchema.create(
"foo",
"description",
"valueDisplayName",
Kind.GAUGE,
ImmutableSet.<LabelDescriptor>of()));
"foo", "description", "valueDisplayName", Kind.GAUGE, ImmutableSet.of()));
assertThat(thrown).hasMessageThat().contains("Name must be URL-like and start with a '/'");
}
}

View file

@ -31,8 +31,7 @@ public class StoredMetricTest {
@Test
public void testGetCardinality_reflectsCurrentCardinality() {
StoredMetric<Boolean> smallMetric =
new StoredMetric<>(
"/metric", "description", "vdn", ImmutableSet.<LabelDescriptor>of(), Boolean.class);
new StoredMetric<>("/metric", "description", "vdn", ImmutableSet.of(), Boolean.class);
assertThat(smallMetric.getCardinality()).isEqualTo(0);
smallMetric.set(true);

View file

@ -113,7 +113,7 @@ public final class SheepCounterExample {
"/is_sleeping",
"Tracks sleep state.",
"Sleeping?",
ImmutableSet.<LabelDescriptor>of(),
ImmutableSet.of(),
Boolean.class);
/**
@ -128,8 +128,8 @@ public final class SheepCounterExample {
"/sleep_quality",
"Quality of the sleep.",
"Quality",
ImmutableSet.<LabelDescriptor>of(),
() -> ImmutableMap.of(ImmutableList.<String>of(), new Random().nextDouble()),
ImmutableSet.of(),
() -> ImmutableMap.of(ImmutableList.of(), new Random().nextDouble()),
Double.class);
/**

View file

@ -70,7 +70,7 @@ public class EppMetricTest {
public void test_zeroTlds_areRecordedAsAbsent() throws Exception {
EppMetric metric =
EppMetric.builderForRequest("request-id-1", new FakeClock())
.setTlds(ImmutableSet.<String>of())
.setTlds(ImmutableSet.of())
.build();
assertThat(metric.getTld()).isEmpty();
}

View file

@ -104,7 +104,7 @@ public class MetricsExportActionTest {
@Test
public void testSuccess_emptyErrors() throws Exception {
when(insertAll.execute()).thenReturn(response);
response.setInsertErrors(ImmutableList.<InsertErrors>of());
response.setInsertErrors(ImmutableList.of());
action.run();
verify(insertAll).execute();
}

View file

@ -211,7 +211,7 @@ public final class RequestHandlerTest {
@Before
public void before() throws Exception {
// Initialize here, not inline, so that we pick up the mocked UserService.
handler = RequestHandler.<Component>createForTest(
handler = RequestHandler.createForTest(
Component.class,
Providers.<Builder>of(new Builder() {
@Override
@ -421,7 +421,7 @@ public final class RequestHandlerTest {
when(req.getMethod()).thenReturn("GET");
when(req.getRequestURI()).thenReturn("/auth/adminUser");
when(requestAuthenticator.authorize(AUTH_INTERNAL_OR_ADMIN.authSettings(), req))
.thenReturn(Optional.<AuthResult>empty());
.thenReturn(Optional.empty());
handler.handleRequest(req, rsp);

View file

@ -74,7 +74,7 @@ public class RequestAuthenticatorTest {
UserPolicy.ADMIN);
private static final AuthSettings AUTH_NO_METHODS = AuthSettings.create(
ImmutableList.<AuthMethod>of(),
ImmutableList.of(),
AuthLevel.APP,
UserPolicy.IGNORED);
@ -120,7 +120,7 @@ public class RequestAuthenticatorTest {
private RequestAuthenticator createRequestAuthenticator(UserService userService) {
return new RequestAuthenticator(
new AppEngineInternalAuthenticationMechanism(),
ImmutableList.<AuthenticationMechanism>of(
ImmutableList.of(
new OAuthAuthenticationMechanism(
fakeOAuthService,
ImmutableSet.of("test-scope1", "test-scope2", "test-scope3"),

View file

@ -170,9 +170,7 @@ public class DriveConnectionTest {
.setParents(ImmutableList.of(new ParentReference().setId("driveFolderId")))),
argThat(hasByteArrayContent(DATA))))
.thenReturn(insert);
ChildList emptyChildList = new ChildList()
.setItems(ImmutableList.<ChildReference> of())
.setNextPageToken(null);
ChildList emptyChildList = new ChildList().setItems(ImmutableList.of()).setNextPageToken(null);
when(childrenList.execute()).thenReturn(emptyChildList);
assertThat(driveConnection.createOrUpdateFile(
"title",

View file

@ -95,7 +95,6 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.smd.EncodedSignedMark;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.Builder;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.model.transfer.TransferStatus;
import google.registry.tmch.LordnTask;
import java.util.Arrays;
@ -513,7 +512,7 @@ public class DatastoreHelper {
.setTransferData(createTransferDataBuilder(requestTime, expirationTime)
.setPendingTransferExpirationTime(now.plus(getContactAutomaticTransferLength()))
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
ImmutableSet.of(
// Pretend it's 3 days since the request
Key.create(persistResource(
createPollMessageForImplicitTransfer(
@ -600,7 +599,7 @@ public class DatastoreHelper {
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
.setServerApproveAutorenewEvent(Key.create(gainingClientAutorenewEvent))
.setServerApproveAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage))
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
.setServerApproveEntities(ImmutableSet.of(
Key.create(transferBillingEvent),
Key.create(gainingClientAutorenewEvent),
Key.create(gainingClientAutorenewPollMessage),
@ -646,14 +645,14 @@ public class DatastoreHelper {
}
private static Iterable<BillingEvent> getBillingEvents() {
return Iterables.<BillingEvent>concat(
return Iterables.concat(
ofy().load().type(BillingEvent.OneTime.class),
ofy().load().type(BillingEvent.Recurring.class),
ofy().load().type(BillingEvent.Cancellation.class));
}
private static Iterable<BillingEvent> getBillingEvents(EppResource resource) {
return Iterables.<BillingEvent>concat(
return Iterables.concat(
ofy().load().type(BillingEvent.OneTime.class).ancestor(resource),
ofy().load().type(BillingEvent.Recurring.class).ancestor(resource),
ofy().load().type(BillingEvent.Cancellation.class).ancestor(resource));

View file

@ -29,7 +29,7 @@ public class EppLoader {
private String eppXml;
public EppLoader(Object context, String eppXmlFilename) {
this(context, eppXmlFilename, ImmutableMap.<String, String>of());
this(context, eppXmlFilename, ImmutableMap.of());
}
public EppLoader(Object context, String eppXmlFilename, Map<String, String> substitutions) {

View file

@ -59,7 +59,7 @@ public class FakeOAuthService implements OAuthService {
}
public void setAuthorizedScopes(String... scopes) {
this.authorizedScopes = ImmutableList.<String>copyOf(scopes);
this.authorizedScopes = ImmutableList.copyOf(scopes);
}
@Override

View file

@ -14,7 +14,6 @@
package google.registry.testing;
import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
@ -42,8 +41,7 @@ public class FakeURLFetchService extends ForwardingURLFetchService {
if (backingMap.containsKey(requestURL)) {
return backingMap.get(requestURL);
} else {
return new HTTPResponse(
HttpURLConnection.HTTP_NOT_FOUND, null, null, ImmutableList.<HTTPHeader>of());
return new HTTPResponse(HttpURLConnection.HTTP_NOT_FOUND, null, null, ImmutableList.of());
}
}
}

View file

@ -51,7 +51,7 @@ public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
};
private List<String> getMessagesAtLevel(Level level) {
ImmutableList.Builder<String> builder = ImmutableList.<String>builder();
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
for (LogRecord log : actual().getStoredLogRecords()) {
if (log.getLevel().equals(level)) {
builder.add(log.getMessage());

View file

@ -213,7 +213,7 @@ public class TaskQueueHelper {
public static void assertTasksEnqueued(String queueName, Iterable<TaskStateInfo> taskStateInfos)
throws Exception {
ImmutableList.Builder<TaskMatcher> taskMatchers = ImmutableList.builder();
ImmutableList.Builder<TaskMatcher> taskMatchers = new ImmutableList.Builder<>();
for (TaskStateInfo taskStateInfo : taskStateInfos) {
taskMatchers.add(new TaskMatcher(taskStateInfo));
}

View file

@ -88,8 +88,7 @@ public abstract class MapreduceTestCase<T> extends ShardableTestCase {
}
protected MapreduceRunner makeDefaultRunner() {
return new MapreduceRunner(
Optional.<Integer>of(getEppResourceIndexBucketCount()), Optional.<Integer>of(1));
return new MapreduceRunner(Optional.of(getEppResourceIndexBucketCount()), Optional.of(1));
}
protected List<QueueStateInfo.TaskStateInfo> getTasks(String queueName) {
@ -178,7 +177,7 @@ public abstract class MapreduceTestCase<T> extends ShardableTestCase {
*/
protected void executeTasksUntilEmpty(String queueName, @Nullable FakeClock clock)
throws Exception {
executeTasks(queueName, clock, Optional.<Integer>empty());
executeTasks(queueName, clock, Optional.empty());
}
/**

View file

@ -29,7 +29,7 @@ import org.junit.runners.JUnit4;
public class IdnTableTest {
@Test
public void testDigits() {
ImmutableList<String> of = ImmutableList.<String>of(
ImmutableList<String> of = ImmutableList.of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html",
"U+0030",
@ -42,8 +42,7 @@ public class IdnTableTest {
"U+0037",
"U+0038",
"U+0039");
IdnTable idnTable =
IdnTable.createFrom("lolcatattack", of, Optional.<LanguageValidator>empty());
IdnTable idnTable = IdnTable.createFrom("lolcatattack", of, Optional.empty());
assertThat(idnTable.isValidLabel("0123456789")).isTrue();
assertThat(idnTable.isValidLabel("54321a")).isFalse();
assertThat(idnTable.isValidLabel("AAA000")).isFalse();
@ -51,7 +50,7 @@ public class IdnTableTest {
@Test
public void testIgnoreCommentAndEmptyLines() {
IdnTable idnTable = IdnTable.createFrom("lolcatattack", ImmutableList.<String>of(
IdnTable idnTable = IdnTable.createFrom("lolcatattack", ImmutableList.of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html",
"U+0030",
@ -65,21 +64,25 @@ public class IdnTableTest {
"U+0036",
"U+0037",
"U+0038",
"U+0039"), Optional.<LanguageValidator>empty());
"U+0039"), Optional.empty());
assertThat(idnTable.isValidLabel("0123456789")).isFalse();
assertThat(idnTable.isValidLabel("023456789")).isTrue(); // Works when you remove 1
}
@Test
public void testSurrogates() {
IdnTable idnTable = IdnTable.createFrom("lolcatattack", ImmutableList.<String>of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html",
"U+0035",
"U+0036",
"U+0037",
"U+2070E",
"U+20731"), Optional.<LanguageValidator>empty());
IdnTable idnTable =
IdnTable.createFrom(
"lolcatattack",
ImmutableList.of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html",
"U+0035",
"U+0036",
"U+0037",
"U+2070E",
"U+20731"),
Optional.empty());
assertThat(idnTable.getName()).isEqualTo("lolcatattack");
assertThat(idnTable.isValidLabel("𠜎")).isTrue();
assertThat(idnTable.isValidLabel("𠜱")).isTrue();
@ -90,34 +93,31 @@ public class IdnTableTest {
@Test
public void testSpecialComments_getParsed() {
ImmutableList<String> of = ImmutableList.<String>of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html");
ImmutableList<String> of =
ImmutableList.of(
"# URL: https://love.example/lolcatattack.txt",
"# Policy: https://love.example/policy.html");
IdnTable idnTable =
IdnTable.createFrom("lolcatattack", of, Optional.<LanguageValidator>empty());
IdnTable.createFrom("lolcatattack", of, Optional.empty());
assertThat(idnTable.getUrl()).isEqualTo(URI.create("https://love.example/lolcatattack.txt"));
assertThat(idnTable.getPolicy()).isEqualTo(URI.create("https://love.example/policy.html"));
}
@Test
public void testMissingUrl_throwsNpe() {
ImmutableList<String> of = ImmutableList.<String>of(
"# Policy: https://love.example/policy.html");
ImmutableList<String> of = ImmutableList.of("# Policy: https://love.example/policy.html");
NullPointerException thrown =
expectThrows(
NullPointerException.class,
() -> IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty()));
NullPointerException.class, () -> IdnTable.createFrom("sloth", of, Optional.empty()));
assertThat(thrown).hasMessageThat().contains("sloth missing '# URL:");
}
@Test
public void testMissingPolicy_throwsNpe() {
ImmutableList<String> of = ImmutableList.<String>of(
"# URL: https://love.example/sloth.txt");
ImmutableList<String> of = ImmutableList.of("# URL: https://love.example/sloth.txt");
NullPointerException thrown =
expectThrows(
NullPointerException.class,
() -> IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty()));
NullPointerException.class, () -> IdnTable.createFrom("sloth", of, Optional.empty()));
assertThat(thrown).hasMessageThat().contains("sloth missing '# Policy:");
}
}

View file

@ -78,7 +78,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
.doThrow(fakeException)
.doCallRealMethod()
.when(spyCommand)
.saveTokens(Mockito.<ImmutableSet<LrpTokenEntity>>any());
.saveTokens(Mockito.any());
runCommand("--assignee=domain.tld", "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));

View file

@ -168,7 +168,7 @@ public class EppToolVerifier {
ArgumentCaptor<byte[]> params = ArgumentCaptor.forClass(byte[].class);
verify(connection, atLeast(0)).send(
eq("/_dr/epptool"),
eq(ImmutableMap.<String, Object>of()),
eq(ImmutableMap.of()),
eq(MediaType.FORM_DATA),
params.capture());
capturedParams = ImmutableList.copyOf(params.getAllValues());

View file

@ -52,7 +52,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
* The TLD to be used (for those subclasses that use TLDs; defaults to empty).
*/
protected List<String> getTlds() {
return ImmutableList.<String>of();
return ImmutableList.of();
}
/**
@ -101,7 +101,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand(tldsParameter);
}
verifySent(null, Optional.<Boolean>empty(), Optional.<Boolean>empty());
verifySent(null, Optional.empty(), Optional.empty());
}
@Test
@ -111,7 +111,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", tldsParameter);
}
verifySent("fieldName", Optional.<Boolean>empty(), Optional.<Boolean>empty());
verifySent("fieldName", Optional.empty(), Optional.empty());
}
@Test
@ -121,7 +121,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=*", tldsParameter);
}
verifySent("*", Optional.<Boolean>empty(), Optional.<Boolean>empty());
verifySent("*", Optional.empty(), Optional.empty());
}
@Test
@ -131,7 +131,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--header=true", tldsParameter);
}
verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.<Boolean>empty());
verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.empty());
}
@Test
@ -141,7 +141,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--header=false", tldsParameter);
}
verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.<Boolean>empty());
verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.empty());
}
@Test
@ -151,7 +151,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--full_field_names", tldsParameter);
}
verifySent("fieldName", Optional.<Boolean>empty(), Optional.of(Boolean.TRUE));
verifySent("fieldName", Optional.empty(), Optional.of(Boolean.TRUE));
}
@Test

View file

@ -36,7 +36,7 @@ public class PublishDetailReportCommandTest extends CommandTestCase<PublishDetai
public void init() throws Exception {
command.setConnection(connection);
when(connection.sendJson(anyString(), anyMapOf(String.class, Object.class)))
.thenReturn(ImmutableMap.<String, Object>of("driveId", "some123id"));
.thenReturn(ImmutableMap.of("driveId", "some123id"));
}
@Test

View file

@ -41,10 +41,9 @@ public class VerifyOteCommandTest extends CommandTestCase<VerifyOteCommand> {
public void init() throws Exception {
command.setConnection(connection);
ImmutableMap<String, Object> response =
ImmutableMap.<String, Object>of(
"blobio", "Num actions: 19 - Reqs passed: 19/19 - Overall: PASS");
ImmutableMap.of("blobio", "Num actions: 19 - Reqs passed: 19/19 - Overall: PASS");
when(connection.sendJson(anyString(), anyMapOf(String.class, Object.class)))
.thenReturn(ImmutableMap.<String, Object>of("blobio", response));
.thenReturn(ImmutableMap.of("blobio", response));
}
@Test