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

@ -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())