Run automatic Java 8 conversion over codebase

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171174380
This commit is contained in:
mcilwain 2017-10-05 10:48:38 -07:00 committed by Ben McIlwain
parent 44df5da771
commit 5edb7935ed
190 changed files with 2312 additions and 3096 deletions

View file

@ -20,7 +20,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.common.base.Function;
import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource;
@ -46,12 +45,7 @@ public class ResaveEntitiesCommandTest extends CommandTestCase<ResaveEntitiesCom
Iterable<ImmutableObject> savedEntities =
transform(
ofy().load().type(CommitLogMutation.class).list(),
new Function<CommitLogMutation, ImmutableObject>() {
@Override
public ImmutableObject apply(CommitLogMutation mutation) {
return ofy().load().fromEntity(mutation.getEntity());
}
});
mutation -> ofy().load().fromEntity(mutation.getEntity()));
// Reload the contacts before asserting, since their update times will have changed.
ofy().clearSessionCache();
assertThat(savedEntities)

View file

@ -21,7 +21,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.loadRegistrar;
import com.google.common.base.Function;
import google.registry.model.ImmutableObject;
import google.registry.model.ofy.CommitLogManifest;
import google.registry.model.ofy.CommitLogMutation;
@ -62,12 +61,7 @@ public class ResaveEnvironmentEntitiesCommandTest
Iterable<ImmutableObject> savedEntities =
transform(
ofy().load().type(CommitLogMutation.class).list(),
new Function<CommitLogMutation, ImmutableObject>() {
@Override
public ImmutableObject apply(CommitLogMutation mutation) {
return ofy().load().fromEntity(mutation.getEntity());
}
});
mutation -> ofy().load().fromEntity(mutation.getEntity()));
assertThat(savedEntities)
.containsExactly(
// The Registrars and RegistrarContacts are created by AppEngineRule.

View file

@ -30,7 +30,6 @@ import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntr
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.Assert.fail;
import com.google.common.collect.FluentIterable;
import google.registry.model.domain.DomainApplication;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
@ -123,8 +122,9 @@ public class UpdateApplicationStatusCommandTest
PollMessage pollMessage = getFirstPollMessage();
assertThat(pollMessage.getMsg()).isEqualTo("Application rejected");
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
DomainPendingActionNotificationResponse response =
(DomainPendingActionNotificationResponse)
pollMessage.getResponseData().stream().findFirst().get();
assertThat(response.getTrid()).isEqualTo(creationTrid);
assertThat(response.getActionResult()).isFalse();
}
@ -161,8 +161,9 @@ public class UpdateApplicationStatusCommandTest
PollMessage pollMessage = getFirstPollMessage();
assertThat(pollMessage.getMsg()).isEqualTo("Application allocated");
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
DomainPendingActionNotificationResponse response =
(DomainPendingActionNotificationResponse)
pollMessage.getResponseData().stream().findFirst().get();
assertThat(response.getTrid()).isEqualTo(creationTrid);
assertThat(response.getActionResult()).isTrue();
}
@ -225,8 +226,9 @@ public class UpdateApplicationStatusCommandTest
assertThat(getPollMessageCount()).isEqualTo(1);
PollMessage pollMessage = getFirstPollMessage();
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
DomainPendingActionNotificationResponse response =
(DomainPendingActionNotificationResponse)
pollMessage.getResponseData().stream().findFirst().get();
assertThat(response.getTrid()).isEqualTo(Trid.create("ABC123", "server-trid"));
}

View file

@ -16,6 +16,7 @@ package google.registry.tools.server;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
@ -27,10 +28,9 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Arrays.asList;
import com.google.appengine.api.datastore.Entity;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Streams;
import google.registry.model.ImmutableObject;
import google.registry.model.ofy.CommitLogBucket;
import google.registry.model.ofy.CommitLogCheckpoint;
@ -81,13 +81,10 @@ public class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommit
for (Class<?> clazz : AFFECTED_TYPES) {
assertThat(ofy().load().type(clazz)).named("entities of type " + clazz).isNotEmpty();
}
ImmutableList<?> otherStuff = FluentIterable.from(ofy().load())
.filter(new Predicate<Object>() {
@Override
public boolean apply(Object obj) {
return !AFFECTED_TYPES.contains(obj.getClass());
}})
.toList();
ImmutableList<?> otherStuff =
Streams.stream(ofy().load())
.filter(obj -> !AFFECTED_TYPES.contains(obj.getClass()))
.collect(toImmutableList());
assertThat(otherStuff).isNotEmpty();
runMapreduce();
for (Class<?> clazz : AFFECTED_TYPES) {

View file

@ -17,6 +17,7 @@ package google.registry.tools.server;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.Multimaps.filterKeys;
import static com.google.common.collect.Sets.difference;
import static com.google.common.truth.Truth.assertThat;
@ -32,7 +33,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Arrays.asList;
import com.google.appengine.api.datastore.Entity;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@ -53,6 +53,7 @@ import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.FakeResponse;
import google.registry.testing.mapreduce.MapreduceTestCase;
import java.util.stream.Stream;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.junit.Test;
@ -64,22 +65,21 @@ import org.junit.runners.JUnit4;
public class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppResourcesAction> {
static final ImmutableSet<String> AFFECTED_KINDS =
FluentIterable.from(
asList(
EppResourceIndex.class,
ForeignKeyContactIndex.class,
ForeignKeyDomainIndex.class,
ForeignKeyHostIndex.class,
DomainApplicationIndex.class,
DomainBase.class,
ContactResource.class,
HostResource.class,
HistoryEntry.class,
PollMessage.class,
BillingEvent.OneTime.class,
BillingEvent.Recurring.class))
.transform(CLASS_TO_KIND_FUNCTION)
.toSet();
Stream.of(
EppResourceIndex.class,
ForeignKeyContactIndex.class,
ForeignKeyDomainIndex.class,
ForeignKeyHostIndex.class,
DomainApplicationIndex.class,
DomainBase.class,
ContactResource.class,
HostResource.class,
HistoryEntry.class,
PollMessage.class,
BillingEvent.OneTime.class,
BillingEvent.Recurring.class)
.map(CLASS_TO_KIND_FUNCTION)
.collect(toImmutableSet());
private void runMapreduce() throws Exception {
action = new KillAllEppResourcesAction();