diff --git a/java/google/registry/backup/DeleteOldCommitLogsAction.java b/java/google/registry/backup/DeleteOldCommitLogsAction.java index f9fb7fcb0..3b0d8c19f 100644 --- a/java/google/registry/backup/DeleteOldCommitLogsAction.java +++ b/java/google/registry/backup/DeleteOldCommitLogsAction.java @@ -27,7 +27,6 @@ import com.google.appengine.tools.mapreduce.Mapper; import com.google.appengine.tools.mapreduce.Reducer; import com.google.appengine.tools.mapreduce.ReducerInput; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultiset; import com.googlecode.objectify.Key; @@ -100,7 +99,7 @@ public final class DeleteOldCommitLogsAction implements Runnable { new DeleteOldCommitLogsMapper(), new DeleteOldCommitLogsReducer(deletionThreshold, isDryRun), ImmutableList.of( - new CommitLogManifestInput(Optional.of(deletionThreshold)), + new CommitLogManifestInput(deletionThreshold), EppResourceInputs.createKeyInput(EppResource.class))))); } diff --git a/java/google/registry/batch/BatchModule.java b/java/google/registry/batch/BatchModule.java index 425def5b3..4d4ebe6fd 100644 --- a/java/google/registry/batch/BatchModule.java +++ b/java/google/registry/batch/BatchModule.java @@ -19,13 +19,13 @@ import static google.registry.request.RequestParameters.extractOptionalIntParame import static google.registry.request.RequestParameters.extractOptionalParameter; import com.google.api.services.bigquery.model.TableFieldSchema; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import dagger.Module; import dagger.Provides; import dagger.multibindings.IntoMap; import dagger.multibindings.StringKey; import google.registry.request.Parameter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** diff --git a/java/google/registry/batch/ExpandRecurringBillingEventsAction.java b/java/google/registry/batch/ExpandRecurringBillingEventsAction.java index a47bb7f19..5fb8008ea 100644 --- a/java/google/registry/batch/ExpandRecurringBillingEventsAction.java +++ b/java/google/registry/batch/ExpandRecurringBillingEventsAction.java @@ -33,7 +33,6 @@ import static google.registry.util.PipelineUtils.createJobPath; import com.google.appengine.tools.mapreduce.Mapper; import com.google.appengine.tools.mapreduce.Reducer; import com.google.appengine.tools.mapreduce.ReducerInput; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; @@ -62,6 +61,7 @@ import google.registry.request.Response; import google.registry.request.auth.Auth; import google.registry.util.Clock; import google.registry.util.FormattingLogger; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; import org.joda.money.Money; @@ -97,7 +97,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable { Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now(); DateTime executeTime = clock.nowUtc(); DateTime persistedCursorTime = (cursor == null ? START_OF_TIME : cursor.getCursorTime()); - DateTime cursorTime = cursorTimeParam.or(persistedCursorTime); + DateTime cursorTime = cursorTimeParam.orElse(persistedCursorTime); checkArgument( cursorTime.isBefore(executeTime), "Cursor time must be earlier than execution time."); diff --git a/java/google/registry/batch/MapreduceEntityCleanupAction.java b/java/google/registry/batch/MapreduceEntityCleanupAction.java index 54d63e8a4..c22b27807 100644 --- a/java/google/registry/batch/MapreduceEntityCleanupAction.java +++ b/java/google/registry/batch/MapreduceEntityCleanupAction.java @@ -18,7 +18,6 @@ import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import com.google.appengine.api.datastore.DatastoreService; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import google.registry.batch.MapreduceEntityCleanupUtil.EligibleJobResults; import google.registry.mapreduce.MapreduceRunner; @@ -28,6 +27,7 @@ import google.registry.request.Response; import google.registry.request.auth.Auth; import google.registry.util.Clock; import google.registry.util.FormattingLogger; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; import org.joda.time.DateTime; @@ -164,7 +164,7 @@ public class MapreduceEntityCleanupAction implements Runnable { handleBadRequest(ERROR_NON_POSITIVE_JOBS_TO_DELETE); return; } - int defaultedDaysOld = daysOld.or(DEFAULT_DAYS_OLD); + int defaultedDaysOld = daysOld.orElse(DEFAULT_DAYS_OLD); // Only generate the detailed response payload if there aren't too many jobs involved. boolean verbose = numJobsToDelete.isPresent() && (numJobsToDelete.get() <= DEFAULT_MAX_NUM_JOBS_TO_DELETE); @@ -174,14 +174,14 @@ public class MapreduceEntityCleanupAction implements Runnable { // until we find enough, requesting deletion as we go. int numJobsProcessed = 0; DateTime cutoffDate = clock.nowUtc().minusDays(defaultedDaysOld); - Optional cursor = Optional.absent(); + Optional cursor = Optional.empty(); do { Optional numJobsToRequest = - Optional.fromNullable( + Optional.ofNullable( numJobsToDelete.isPresent() ? numJobsToDelete.get() - numJobsProcessed : null); EligibleJobResults batch = mapreduceEntityCleanupUtil.findEligibleJobsByJobName( - jobName.orNull(), cutoffDate, numJobsToRequest, force.or(false), cursor); + jobName.orElse(null), cutoffDate, numJobsToRequest, force.orElse(false), cursor); cursor = batch.cursor(); // Individual batches can come back empty if none of the returned jobs meet the requirements // or if all jobs have been exhausted. @@ -200,7 +200,7 @@ public class MapreduceEntityCleanupAction implements Runnable { if (numJobsProcessed == 0) { logger.infofmt( "No eligible jobs found with name '%s' older than %s days old.", - jobName.or("(any)"), defaultedDaysOld); + jobName.orElse("(any)"), defaultedDaysOld); payload.append("No eligible jobs found"); } else { logger.infofmt("A total of %s job(s) processed.", numJobsProcessed); @@ -211,19 +211,19 @@ public class MapreduceEntityCleanupAction implements Runnable { private String requestDeletion(Set actualJobIds, boolean verbose) { Optional payloadChunkBuilder = - verbose ? Optional.of(new StringBuilder()) : Optional.absent(); + verbose ? Optional.of(new StringBuilder()) : Optional.empty(); int errorCount = 0; for (String actualJobId : actualJobIds) { Optional error = - mapreduceEntityCleanupUtil.deleteJobAsync(datastore, actualJobId, force.or(false)); + mapreduceEntityCleanupUtil.deleteJobAsync(datastore, actualJobId, force.orElse(false)); if (error.isPresent()) { errorCount++; } - logger.infofmt("%s: %s", actualJobId, error.or("deletion requested")); + logger.infofmt("%s: %s", actualJobId, error.orElse("deletion requested")); if (payloadChunkBuilder.isPresent()) { payloadChunkBuilder .get() - .append(String.format("%s: %s\n", actualJobId, error.or("deletion requested"))); + .append(String.format("%s: %s\n", actualJobId, error.orElse("deletion requested"))); } } logger.infofmt( diff --git a/java/google/registry/batch/MapreduceEntityCleanupUtil.java b/java/google/registry/batch/MapreduceEntityCleanupUtil.java index 515d2b176..ac30aed20 100644 --- a/java/google/registry/batch/MapreduceEntityCleanupUtil.java +++ b/java/google/registry/batch/MapreduceEntityCleanupUtil.java @@ -22,9 +22,9 @@ import com.google.appengine.tools.pipeline.impl.PipelineManager; import com.google.appengine.tools.pipeline.impl.model.JobRecord; import com.google.appengine.tools.pipeline.util.Pair; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import java.util.HashSet; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import javax.inject.Inject; @@ -92,11 +92,11 @@ class MapreduceEntityCleanupUtil { boolean ignoreState, Optional cursor) { if (maxJobs.isPresent() && (maxJobs.get() <= 0)) { - return EligibleJobResults.create(ImmutableSet.of(), Optional.absent()); + return EligibleJobResults.create(ImmutableSet.of(), Optional.empty()); } Set eligibleJobs = new HashSet<>(); Pair, String> pair = - PipelineManager.queryRootPipelines(jobName, cursor.orNull(), getMaxNumberOfJobsPerSearch()); + PipelineManager.queryRootPipelines(jobName, cursor.orElse(null), getMaxNumberOfJobsPerSearch()); for (JobRecord jobRecord : pair.getFirst()) { if (((jobRecord.getStartTime() == null) || jobRecord.getStartTime().before(cutoffDate.toDate())) @@ -108,12 +108,12 @@ class MapreduceEntityCleanupUtil { eligibleJobs.add(jobRecord.getRootJobKey().getName()); if (maxJobs.isPresent() && (eligibleJobs.size() >= maxJobs.get())) { return EligibleJobResults.create( - ImmutableSet.copyOf(eligibleJobs), Optional.absent()); + ImmutableSet.copyOf(eligibleJobs), Optional.empty()); } } } return EligibleJobResults.create( - ImmutableSet.copyOf(eligibleJobs), Optional.fromNullable(pair.getSecond())); + ImmutableSet.copyOf(eligibleJobs), Optional.ofNullable(pair.getSecond())); } /** @@ -148,7 +148,7 @@ class MapreduceEntityCleanupUtil { // delete the pipeline-* entities as well. try { PipelineManager.deletePipelineRecords(jobId, force, true /* async */); - return Optional.absent(); + return Optional.empty(); } catch (NoSuchObjectException ex) { return Optional.of("No such pipeline job"); } catch (IllegalStateException ex) { diff --git a/java/google/registry/braintree/BraintreeRegistrarSyncer.java b/java/google/registry/braintree/BraintreeRegistrarSyncer.java index d724e3afe..1bac45154 100644 --- a/java/google/registry/braintree/BraintreeRegistrarSyncer.java +++ b/java/google/registry/braintree/BraintreeRegistrarSyncer.java @@ -22,10 +22,10 @@ import com.braintreegateway.Customer; import com.braintreegateway.CustomerRequest; import com.braintreegateway.Result; import com.braintreegateway.exceptions.NotFoundException; -import com.google.common.base.Optional; import com.google.common.base.VerifyException; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarContact; +import java.util.Optional; import javax.inject.Inject; /** Helper for creating Braintree customer entries for registrars. */ @@ -89,7 +89,7 @@ public class BraintreeRegistrarSyncer { return Optional.of(contact); } } - return Optional.absent(); + return Optional.empty(); } private boolean doesCustomerExist(String id) { diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java index 8b170220b..8989dd41c 100644 --- a/java/google/registry/config/RegistryConfig.java +++ b/java/google/registry/config/RegistryConfig.java @@ -19,7 +19,6 @@ import static google.registry.config.ConfigUtils.makeUrl; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -34,6 +33,7 @@ import java.net.URI; import java.net.URL; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Named; import javax.inject.Qualifier; @@ -333,13 +333,13 @@ public final class RegistryConfig { @Provides @Config("cloudDnsRootUrl") public static Optional getCloudDnsRootUrl(RegistryConfigSettings config) { - return Optional.fromNullable(config.cloudDns.rootUrl); + return Optional.ofNullable(config.cloudDns.rootUrl); } @Provides @Config("cloudDnsServicePath") public static Optional getCloudDnsServicePath(RegistryConfigSettings config) { - return Optional.fromNullable(config.cloudDns.servicePath); + return Optional.ofNullable(config.cloudDns.servicePath); } /** @@ -674,7 +674,7 @@ public final class RegistryConfig { @Provides @Config("sheetRegistrarId") public static Optional provideSheetRegistrarId(RegistryConfigSettings config) { - return Optional.fromNullable(config.misc.sheetExportId); + return Optional.ofNullable(config.misc.sheetExportId); } /** diff --git a/java/google/registry/config/YamlUtils.java b/java/google/registry/config/YamlUtils.java index b0100c6bd..eb6da2f3b 100644 --- a/java/google/registry/config/YamlUtils.java +++ b/java/google/registry/config/YamlUtils.java @@ -18,9 +18,9 @@ import static com.google.common.base.Ascii.toLowerCase; import static google.registry.util.FormattingLogger.getLoggerForCallerClass; import static google.registry.util.ResourceUtils.readResourceUtf8; -import com.google.common.base.Optional; import google.registry.util.FormattingLogger; import java.util.Map; +import java.util.Optional; import org.yaml.snakeyaml.Yaml; /** @@ -134,7 +134,7 @@ public final class YamlUtils { */ @SuppressWarnings("unchecked") private static Optional> loadAsMap(Yaml yaml, String yamlString) { - return Optional.fromNullable((Map) yaml.load(yamlString)); + return Optional.ofNullable((Map) yaml.load(yamlString)); } private YamlUtils() {} diff --git a/java/google/registry/cron/CommitLogFanoutAction.java b/java/google/registry/cron/CommitLogFanoutAction.java index 343bdf4ff..20188935b 100644 --- a/java/google/registry/cron/CommitLogFanoutAction.java +++ b/java/google/registry/cron/CommitLogFanoutAction.java @@ -19,12 +19,12 @@ import static java.util.concurrent.TimeUnit.SECONDS; import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.TaskOptions; -import com.google.common.base.Optional; import google.registry.model.ofy.CommitLogBucket; import google.registry.request.Action; import google.registry.request.Parameter; import google.registry.request.auth.Auth; import google.registry.util.TaskEnqueuer; +import java.util.Optional; import java.util.Random; import javax.inject.Inject; diff --git a/java/google/registry/cron/CronModule.java b/java/google/registry/cron/CronModule.java index 164620059..d2dbd09e1 100644 --- a/java/google/registry/cron/CronModule.java +++ b/java/google/registry/cron/CronModule.java @@ -19,11 +19,11 @@ import static google.registry.request.RequestParameters.extractOptionalIntParame import static google.registry.request.RequestParameters.extractRequiredParameter; import static google.registry.request.RequestParameters.extractSetOfParameters; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** Dagger module for the cron package. */ diff --git a/java/google/registry/cron/TldFanoutAction.java b/java/google/registry/cron/TldFanoutAction.java index eba54030c..671796932 100644 --- a/java/google/registry/cron/TldFanoutAction.java +++ b/java/google/registry/cron/TldFanoutAction.java @@ -32,7 +32,6 @@ import static java.util.concurrent.TimeUnit.SECONDS; import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.TaskHandle; import com.google.appengine.api.taskqueue.TaskOptions; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; @@ -44,6 +43,7 @@ import google.registry.request.RequestParameters; import google.registry.request.Response; import google.registry.request.auth.Auth; import google.registry.util.TaskEnqueuer; +import java.util.Optional; import java.util.Random; import java.util.Set; import javax.inject.Inject; diff --git a/java/google/registry/dns/DnsQueue.java b/java/google/registry/dns/DnsQueue.java index 82af080b9..8a349ba99 100644 --- a/java/google/registry/dns/DnsQueue.java +++ b/java/google/registry/dns/DnsQueue.java @@ -32,7 +32,6 @@ import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TransientFailureException; import com.google.apphosting.api.DeadlineExceededException; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.InternetDomainName; import google.registry.dns.DnsConstants.TargetType; @@ -40,6 +39,7 @@ import google.registry.model.registry.Registries; import google.registry.util.FormattingLogger; import google.registry.util.NonFinalForTesting; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.inject.Inject; diff --git a/java/google/registry/dns/ReadDnsQueueAction.java b/java/google/registry/dns/ReadDnsQueueAction.java index c19d079c1..380b52931 100644 --- a/java/google/registry/dns/ReadDnsQueueAction.java +++ b/java/google/registry/dns/ReadDnsQueueAction.java @@ -26,7 +26,6 @@ import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.TaskHandle; import com.google.appengine.api.taskqueue.TaskOptions; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -48,6 +47,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Random; import java.util.Set; import javax.inject.Inject; diff --git a/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java b/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java index 745d02a82..4e278b0c8 100644 --- a/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java +++ b/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java @@ -24,7 +24,6 @@ import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ResourceRecordSet; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -49,6 +48,7 @@ import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.Callable; import javax.inject.Inject; @@ -116,7 +116,7 @@ public class CloudDnsWriter extends BaseDnsWriter { // Load the target domain. Note that it can be null if this domain was just deleted. Optional domainResource = - Optional.fromNullable(loadByForeignKey(DomainResource.class, domainName, clock.nowUtc())); + Optional.ofNullable(loadByForeignKey(DomainResource.class, domainName, clock.nowUtc())); // Return early if no DNS records should be published. // desiredRecordsBuilder is populated with an empty set to indicate that all existing records @@ -186,7 +186,7 @@ public class CloudDnsWriter extends BaseDnsWriter { // desiredRecords is populated with an empty set to indicate that all existing records // should be deleted. Optional host = - Optional.fromNullable(loadByForeignKey(HostResource.class, hostName, clock.nowUtc())); + Optional.ofNullable(loadByForeignKey(HostResource.class, hostName, clock.nowUtc())); // Return early if the host is deleted. if (!host.isPresent()) { diff --git a/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java b/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java index a706e0d17..9c7402c7a 100644 --- a/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java +++ b/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java @@ -20,7 +20,6 @@ import com.google.api.client.json.JsonFactory; import com.google.api.services.dns.Dns; import com.google.api.services.dns.DnsScopes; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.util.concurrent.RateLimiter; import dagger.Module; import dagger.Provides; @@ -29,6 +28,7 @@ import dagger.multibindings.IntoSet; import dagger.multibindings.StringKey; import google.registry.config.RegistryConfig.Config; import google.registry.dns.writer.DnsWriter; +import java.util.Optional; import java.util.Set; import javax.inject.Named; diff --git a/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java b/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java index 3dac52714..76e518703 100644 --- a/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java +++ b/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java @@ -20,7 +20,6 @@ import static com.google.common.collect.Sets.union; import static google.registry.model.EppResourceUtils.loadByForeignKey; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; @@ -36,6 +35,7 @@ import java.io.IOException; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.Duration; import org.xbill.DNS.AAAARecord; diff --git a/java/google/registry/eclipse/BUILD b/java/google/registry/eclipse/BUILD index f7d55d025..d5d8c0c5d 100644 --- a/java/google/registry/eclipse/BUILD +++ b/java/google/registry/eclipse/BUILD @@ -26,7 +26,6 @@ java_binary( "//java/google/registry/module/frontend", "//java/google/registry/module/tools", "//java/google/registry/tools", - "//third_party/java/truth", "@com_google_apis_google_api_services_cloudkms", "@com_google_appengine_api_1_0_sdk//:link", "@com_google_appengine_api_stubs", @@ -34,6 +33,8 @@ java_binary( "@com_google_appengine_testing", "@com_google_appengine_tools_sdk", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_apache_ftpserver_core", "@org_apache_sshd_core", diff --git a/java/google/registry/export/DatastoreBackupInfo.java b/java/google/registry/export/DatastoreBackupInfo.java index de95a80a2..96fff8c22 100644 --- a/java/google/registry/export/DatastoreBackupInfo.java +++ b/java/google/registry/export/DatastoreBackupInfo.java @@ -23,13 +23,13 @@ import com.google.appengine.api.datastore.Text; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Ascii; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import google.registry.util.Clock; import google.registry.util.NonFinalForTesting; import google.registry.util.SystemClock; import java.util.Date; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; import org.joda.time.Duration; @@ -71,9 +71,9 @@ public class DatastoreBackupInfo { kinds = ImmutableSet.copyOf(rawKinds); startTime = new DateTime(rawStartTime).withZone(UTC); - completeTime = Optional.fromNullable( + completeTime = Optional.ofNullable( rawCompleteTime == null ? null : new DateTime(rawCompleteTime).withZone(UTC)); - gcsFilename = Optional.fromNullable( + gcsFilename = Optional.ofNullable( rawGcsFilename == null ? null : gcsPathToUri(rawGcsFilename.getValue())); } @@ -126,7 +126,7 @@ public class DatastoreBackupInfo { * backup started (if it has not completed). */ public Duration getRunningTime() { - return new Duration(startTime, completeTime.or(clock.nowUtc())); + return new Duration(startTime, completeTime.orElse(clock.nowUtc())); } public Optional getGcsFilename() { @@ -140,9 +140,9 @@ public class DatastoreBackupInfo { "Backup name: " + backupName, "Status: " + getStatus(), "Started: " + startTime, - "Ended: " + completeTime.orNull(), + "Ended: " + completeTime.orElse(null), "Duration: " + Ascii.toLowerCase(getRunningTime().toPeriod().toString().substring(2)), - "GCS: " + gcsFilename.orNull(), + "GCS: " + gcsFilename.orElse(null), "Kinds: " + kinds, ""); } diff --git a/java/google/registry/export/SyncGroupMembersAction.java b/java/google/registry/export/SyncGroupMembersAction.java index b8275bd71..227f903ec 100644 --- a/java/google/registry/export/SyncGroupMembersAction.java +++ b/java/google/registry/export/SyncGroupMembersAction.java @@ -23,7 +23,6 @@ import static google.registry.util.RegistrarUtils.normalizeClientId; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_OK; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; @@ -43,6 +42,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import javax.inject.Inject; @@ -140,7 +140,7 @@ public final class SyncGroupMembersAction implements Runnable { return null; }, RuntimeException.class); - resultsBuilder.put(registrar, Optional.absent()); + resultsBuilder.put(registrar, Optional.empty()); } catch (Throwable e) { logger.severe(e, e.getMessage()); resultsBuilder.put(registrar, Optional.of(e)); diff --git a/java/google/registry/export/sheet/SheetModule.java b/java/google/registry/export/sheet/SheetModule.java index 7c1b8825f..b278cdcfe 100644 --- a/java/google/registry/export/sheet/SheetModule.java +++ b/java/google/registry/export/sheet/SheetModule.java @@ -16,10 +16,10 @@ package google.registry.export.sheet; import static com.google.common.base.Strings.emptyToNull; -import com.google.common.base.Optional; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** Dagger module for the sheet package. */ @@ -29,6 +29,6 @@ public final class SheetModule { @Provides @Parameter("id") static Optional provideId(HttpServletRequest req) { - return Optional.fromNullable(emptyToNull(req.getParameter("id"))); + return Optional.ofNullable(emptyToNull(req.getParameter("id"))); } } diff --git a/java/google/registry/export/sheet/SyncRegistrarsSheetAction.java b/java/google/registry/export/sheet/SyncRegistrarsSheetAction.java index a74b49565..62d7facd8 100644 --- a/java/google/registry/export/sheet/SyncRegistrarsSheetAction.java +++ b/java/google/registry/export/sheet/SyncRegistrarsSheetAction.java @@ -27,7 +27,6 @@ import com.google.appengine.api.modules.ModulesService; import com.google.appengine.api.modules.ModulesServiceFactory; import com.google.appengine.api.taskqueue.TaskHandle; import com.google.appengine.api.taskqueue.TaskOptions.Method; -import com.google.common.base.Optional; import google.registry.config.RegistryConfig.Config; import google.registry.request.Action; import google.registry.request.Parameter; @@ -37,6 +36,7 @@ import google.registry.request.lock.LockHandler; import google.registry.util.FormattingLogger; import google.registry.util.NonFinalForTesting; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.Callable; import javax.annotation.Nullable; import javax.inject.Inject; @@ -121,7 +121,7 @@ public class SyncRegistrarsSheetAction implements Runnable { @Override public void run() { - final Optional sheetId = idParam.or(idConfig); + final Optional sheetId = Optional.ofNullable(idParam.orElse(idConfig.orElse(null))); if (!sheetId.isPresent()) { Result.MISSINGNO.send(response, null); return; diff --git a/java/google/registry/flows/EppController.java b/java/google/registry/flows/EppController.java index d42a29867..0653a5765 100644 --- a/java/google/registry/flows/EppController.java +++ b/java/google/registry/flows/EppController.java @@ -22,7 +22,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import google.registry.flows.FlowModule.EppExceptionInProviderException; @@ -35,6 +34,7 @@ import google.registry.model.eppoutput.Result.Code; import google.registry.monitoring.whitebox.BigQueryMetricsEnqueuer; import google.registry.monitoring.whitebox.EppMetric; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.inject.Inject; import org.json.simple.JSONValue; @@ -62,7 +62,7 @@ public final class EppController { boolean isDryRun, boolean isSuperuser, byte[] inputXmlBytes) { - eppMetricBuilder.setClientId(Optional.fromNullable(sessionMetadata.getClientId())); + eppMetricBuilder.setClientId(Optional.ofNullable(sessionMetadata.getClientId())); eppMetricBuilder.setPrivilegeLevel(isSuperuser ? "SUPERUSER" : "NORMAL"); try { EppInput eppInput; diff --git a/java/google/registry/flows/EppMetrics.java b/java/google/registry/flows/EppMetrics.java index 0be4e6316..f81434d67 100644 --- a/java/google/registry/flows/EppMetrics.java +++ b/java/google/registry/flows/EppMetrics.java @@ -86,9 +86,9 @@ public class EppMetrics { String eppStatusCode = metric.getStatus().isPresent() ? String.valueOf(metric.getStatus().get().code) : ""; eppRequestsByRegistrar.increment( - metric.getCommandName().or(""), metric.getClientId().or(""), eppStatusCode); + metric.getCommandName().orElse(""), metric.getClientId().orElse(""), eppStatusCode); eppRequestsByTld.increment( - metric.getCommandName().or(""), metric.getTld().or(""), eppStatusCode); + metric.getCommandName().orElse(""), metric.getTld().orElse(""), eppStatusCode); } /** Records the server-side processing time for an EPP request. */ @@ -98,8 +98,14 @@ public class EppMetrics { long processingTime = metric.getEndTimestamp().getMillis() - metric.getStartTimestamp().getMillis(); processingTimeByRegistrar.record( - processingTime, metric.getCommandName().or(""), metric.getClientId().or(""), eppStatusCode); + processingTime, + metric.getCommandName().orElse(""), + metric.getClientId().orElse(""), + eppStatusCode); processingTimeByTld.record( - processingTime, metric.getCommandName().or(""), metric.getTld().or(""), eppStatusCode); + processingTime, + metric.getCommandName().orElse(""), + metric.getTld().orElse(""), + eppStatusCode); } } diff --git a/java/google/registry/flows/FlowModule.java b/java/google/registry/flows/FlowModule.java index 9993306a3..740e5eb5f 100644 --- a/java/google/registry/flows/FlowModule.java +++ b/java/google/registry/flows/FlowModule.java @@ -17,7 +17,6 @@ package google.registry.flows; import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.nullToEmpty; -import com.google.common.base.Optional; import com.google.common.base.Strings; import dagger.Module; import dagger.Provides; @@ -35,6 +34,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.Result; import google.registry.model.reporting.HistoryEntry; import java.lang.annotation.Documented; +import java.util.Optional; import javax.inject.Qualifier; /** Module to choose and instantiate an EPP flow. */ @@ -194,7 +194,7 @@ public class FlowModule { @Provides @FlowScope static Optional provideOptionalAuthInfo(ResourceCommand resourceCommand) { - return Optional.fromNullable(((SingleResourceCommand) resourceCommand).getAuthInfo()); + return Optional.ofNullable(((SingleResourceCommand) resourceCommand).getAuthInfo()); } @Provides diff --git a/java/google/registry/flows/FlowReporter.java b/java/google/registry/flows/FlowReporter.java index 29abc014f..e861cea10 100644 --- a/java/google/registry/flows/FlowReporter.java +++ b/java/google/registry/flows/FlowReporter.java @@ -19,7 +19,6 @@ import static google.registry.xml.XmlTransformer.prettyPrint; import static java.util.Collections.EMPTY_LIST; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -29,6 +28,7 @@ import google.registry.flows.annotations.ReportingSpec; import google.registry.model.eppcommon.Trid; import google.registry.model.eppinput.EppInput; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.inject.Inject; import org.json.simple.JSONValue; @@ -72,7 +72,7 @@ public class FlowReporter { // Explicitly log flow metadata separately from the EPP XML itself so that it stays compact // enough to be sure to fit in a single log entry (the XML part in rare cases could be long // enough to overflow into multiple log entries, breaking routine parsing of the JSON format). - String singleTargetId = eppInput.getSingleTargetId().or(""); + String singleTargetId = eppInput.getSingleTargetId().orElse(""); ImmutableList targetIds = eppInput.getTargetIds(); logger.infofmt( "%s: %s", @@ -82,12 +82,12 @@ public class FlowReporter { .put("serverTrid", trid.getServerTransactionId()) .put("clientId", clientId) .put("commandType", eppInput.getCommandType()) - .put("resourceType", eppInput.getResourceType().or("")) + .put("resourceType", eppInput.getResourceType().orElse("")) .put("flowClassName", flowClass.getSimpleName()) .put("targetId", singleTargetId) .put("targetIds", targetIds) .put( - "tld", eppInput.isDomainResourceType() ? extractTld(singleTargetId).or("") : "") + "tld", eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "") .put( "tlds", eppInput.isDomainResourceType() ? extractTlds(targetIds).asList() : EMPTY_LIST) @@ -108,7 +108,7 @@ public class FlowReporter { private static final Optional extractTld(String domainName) { int index = domainName.indexOf('.'); return index == -1 - ? Optional.absent() + ? Optional.empty() : Optional.of(Ascii.toLowerCase(domainName.substring(index + 1))); } diff --git a/java/google/registry/flows/HttpSessionMetadata.java b/java/google/registry/flows/HttpSessionMetadata.java index 4b454e8d6..4a366e285 100644 --- a/java/google/registry/flows/HttpSessionMetadata.java +++ b/java/google/registry/flows/HttpSessionMetadata.java @@ -18,7 +18,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; import static google.registry.util.CollectionUtils.nullToEmpty; import com.google.common.base.Joiner; -import com.google.common.base.Optional; +import java.util.Optional; import java.util.Set; import javax.servlet.http.HttpSession; @@ -53,7 +53,7 @@ public class HttpSessionMetadata implements SessionMetadata { @Override public int getFailedLoginAttempts() { - return Optional.fromNullable((Integer) session.getAttribute(FAILED_LOGIN_ATTEMPTS)).or(0); + return Optional.ofNullable((Integer) session.getAttribute(FAILED_LOGIN_ATTEMPTS)).orElse(0); } @Override diff --git a/java/google/registry/flows/ResourceFlowUtils.java b/java/google/registry/flows/ResourceFlowUtils.java index a640eaef6..e6a160b53 100644 --- a/java/google/registry/flows/ResourceFlowUtils.java +++ b/java/google/registry/flows/ResourceFlowUtils.java @@ -17,7 +17,6 @@ package google.registry.flows; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.tryFind; import static com.google.common.collect.Sets.intersection; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.queryForLinkedDomains; @@ -26,7 +25,6 @@ import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey; import static google.registry.model.ofy.ObjectifyService.ofy; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -68,6 +66,7 @@ import google.registry.model.transfer.TransferResponse.ContactTransferResponse; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferStatus; import java.util.List; +import java.util.Optional; import java.util.Set; import org.joda.time.DateTime; @@ -345,7 +344,11 @@ public final class ResourceFlowUtils { } // The roid should match one of the contacts. Optional> foundContact = - tryFind(domain.getReferencedContacts(), key -> key.getName().equals(authRepoId)); + domain + .getReferencedContacts() + .stream() + .filter(key -> key.getName().equals(authRepoId)) + .findFirst(); if (!foundContact.isPresent()) { throw new BadAuthInfoForResourceException(); } diff --git a/java/google/registry/flows/TlsCredentials.java b/java/google/registry/flows/TlsCredentials.java index 2cddfac1a..d357ec02d 100644 --- a/java/google/registry/flows/TlsCredentials.java +++ b/java/google/registry/flows/TlsCredentials.java @@ -20,7 +20,6 @@ import static google.registry.request.RequestParameters.extractOptionalHeader; import static google.registry.request.RequestParameters.extractRequiredHeader; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.HostAndPort; import com.google.common.net.InetAddresses; @@ -32,6 +31,7 @@ import google.registry.request.Header; import google.registry.util.CidrAddressBlock; import google.registry.util.FormattingLogger; import java.net.InetAddress; +import java.util.Optional; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; diff --git a/java/google/registry/flows/contact/ContactDeleteFlow.java b/java/google/registry/flows/contact/ContactDeleteFlow.java index 0134bc65d..a1318a63e 100644 --- a/java/google/registry/flows/contact/ContactDeleteFlow.java +++ b/java/google/registry/flows/contact/ContactDeleteFlow.java @@ -23,7 +23,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -43,6 +42,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/contact/ContactInfoFlow.java b/java/google/registry/flows/contact/ContactInfoFlow.java index 1158d204e..82a55cbc4 100644 --- a/java/google/registry/flows/contact/ContactInfoFlow.java +++ b/java/google/registry/flows/contact/ContactInfoFlow.java @@ -19,7 +19,6 @@ import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence; import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo; import static google.registry.model.EppResourceUtils.isLinked; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -35,6 +34,7 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/contact/ContactTransferApproveFlow.java b/java/google/registry/flows/contact/ContactTransferApproveFlow.java index f28b79345..08c9898ee 100644 --- a/java/google/registry/flows/contact/ContactTransferApproveFlow.java +++ b/java/google/registry/flows/contact/ContactTransferApproveFlow.java @@ -24,7 +24,6 @@ import static google.registry.flows.contact.ContactFlowUtils.createGainingTransf import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; @@ -41,6 +40,7 @@ import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/contact/ContactTransferCancelFlow.java b/java/google/registry/flows/contact/ContactTransferCancelFlow.java index ede3c1a66..e265d6bc3 100644 --- a/java/google/registry/flows/contact/ContactTransferCancelFlow.java +++ b/java/google/registry/flows/contact/ContactTransferCancelFlow.java @@ -24,7 +24,6 @@ import static google.registry.flows.contact.ContactFlowUtils.createLosingTransfe import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; @@ -41,6 +40,7 @@ import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/contact/ContactTransferQueryFlow.java b/java/google/registry/flows/contact/ContactTransferQueryFlow.java index 6470fe43e..416a3d533 100644 --- a/java/google/registry/flows/contact/ContactTransferQueryFlow.java +++ b/java/google/registry/flows/contact/ContactTransferQueryFlow.java @@ -19,7 +19,6 @@ import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence; import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo; import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse; -import com.google.common.base.Optional; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; import google.registry.flows.Flow; @@ -33,6 +32,7 @@ import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/flows/contact/ContactTransferRejectFlow.java b/java/google/registry/flows/contact/ContactTransferRejectFlow.java index cf945d6c8..504e08d9b 100644 --- a/java/google/registry/flows/contact/ContactTransferRejectFlow.java +++ b/java/google/registry/flows/contact/ContactTransferRejectFlow.java @@ -24,7 +24,6 @@ import static google.registry.flows.contact.ContactFlowUtils.createGainingTransf import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; @@ -40,6 +39,7 @@ import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/contact/ContactTransferRequestFlow.java b/java/google/registry/flows/contact/ContactTransferRequestFlow.java index a76298e6c..a233f7908 100644 --- a/java/google/registry/flows/contact/ContactTransferRequestFlow.java +++ b/java/google/registry/flows/contact/ContactTransferRequestFlow.java @@ -25,7 +25,6 @@ import static google.registry.flows.contact.ContactFlowUtils.createTransferRespo import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.config.RegistryConfig.Config; @@ -48,6 +47,7 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; import org.joda.time.Duration; diff --git a/java/google/registry/flows/contact/ContactUpdateFlow.java b/java/google/registry/flows/contact/ContactUpdateFlow.java index bb797a59d..facbf9338 100644 --- a/java/google/registry/flows/contact/ContactUpdateFlow.java +++ b/java/google/registry/flows/contact/ContactUpdateFlow.java @@ -26,7 +26,6 @@ import static google.registry.flows.contact.ContactFlowUtils.validateAsciiPostal import static google.registry.flows.contact.ContactFlowUtils.validateContactAgainstPolicy; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -49,6 +48,7 @@ import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java b/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java index 38265bc0f..0c2d10d34 100644 --- a/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java @@ -15,7 +15,6 @@ package google.registry.flows.custom; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.InternetDomainName; import google.registry.flows.EppException; @@ -28,6 +27,7 @@ import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseData; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.reporting.HistoryEntry; +import java.util.Optional; /** * A no-op base class for {@link DomainCreateFlow} custom logic. diff --git a/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java b/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java index af061c0dd..9e0c91e1d 100644 --- a/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java @@ -26,7 +26,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAl import static google.registry.model.EppResourceUtils.loadDomainApplication; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.EppException.StatusProhibitsOperationException; @@ -48,6 +47,7 @@ import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainApplicationInfoFlow.java b/java/google/registry/flows/domain/DomainApplicationInfoFlow.java index c81c6d288..bc48d0c7f 100644 --- a/java/google/registry/flows/domain/DomainApplicationInfoFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationInfoFlow.java @@ -25,7 +25,6 @@ import static google.registry.flows.domain.DomainFlowUtils.loadForeignKeyedDesig import static google.registry.flows.domain.DomainFlowUtils.verifyApplicationDomainMatchesTargetId; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -52,6 +51,7 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.smd.EncodedSignedMark; import google.registry.model.smd.SignedMark; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java index c62a74978..f2e7e220b 100644 --- a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java @@ -44,7 +44,6 @@ import static google.registry.model.EppResourceUtils.loadDomainApplication; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.nullToEmpty; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.net.InternetDomainName; @@ -77,6 +76,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.registry.Registry; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainCheckFlow.java b/java/google/registry/flows/domain/DomainCheckFlow.java index 87e410eef..67af65425 100644 --- a/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/java/google/registry/flows/domain/DomainCheckFlow.java @@ -27,7 +27,6 @@ import static google.registry.model.index.DomainApplicationIndex.loadActiveAppli import static google.registry.model.registry.label.ReservationType.getTypeOfHighestSeverity; import static google.registry.pricing.PricingEngineProxy.isDomainPremium; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -63,6 +62,7 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; import org.joda.time.DateTime; @@ -151,7 +151,7 @@ public final class DomainCheckFlow implements Flow { ImmutableList.Builder checks = new ImmutableList.Builder<>(); for (String targetId : targetIds) { Optional message = getMessageForCheck(domainNames.get(targetId), existingIds, now); - checks.add(DomainCheck.create(!message.isPresent(), targetId, message.orNull())); + checks.add(DomainCheck.create(!message.isPresent(), targetId, message.orElse(null))); } BeforeResponseReturnData responseData = customLogic.beforeResponse( @@ -187,7 +187,7 @@ public final class DomainCheckFlow implements Flow { } return reservationTypes.isEmpty() - ? Optional.absent() + ? Optional.empty() : Optional.of(getTypeOfHighestSeverity(reservationTypes).getMessageForCheck()); } diff --git a/java/google/registry/flows/domain/DomainCreateFlow.java b/java/google/registry/flows/domain/DomainCreateFlow.java index 21d83ddf6..5617e8abf 100644 --- a/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/java/google/registry/flows/domain/DomainCreateFlow.java @@ -46,7 +46,6 @@ import static google.registry.model.registry.label.ReservedList.matchesAnchorTen import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.leapSafeAddYears; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -105,6 +104,7 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.tmch.LordnTask; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; import org.joda.time.Duration; @@ -255,7 +255,7 @@ public class DomainCreateFlow implements TransactionalFlow { DomainCreateFlowCustomLogic.AfterValidationParameters.newBuilder() .setDomainName(domainName) .setYears(years) - .setSignedMarkId(Optional.fromNullable(signedMarkId)) + .setSignedMarkId(Optional.ofNullable(signedMarkId)) .build()); FeeCreateCommandExtension feeCreate = eppInput.getSingleExtension(FeeCreateCommandExtension.class); diff --git a/java/google/registry/flows/domain/DomainDeleteFlow.java b/java/google/registry/flows/domain/DomainDeleteFlow.java index 83263be5f..26eee582f 100644 --- a/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -37,7 +37,6 @@ import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.union; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -90,6 +89,7 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; import java.util.Collections; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import javax.inject.Inject; diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index e78ddd1c0..f4804bec1 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -40,7 +40,6 @@ import static google.registry.util.DomainNameUtils.ACE_PREFIX; import com.google.common.base.CharMatcher; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -115,6 +114,7 @@ import java.math.BigDecimal; import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.money.CurrencyUnit; @@ -490,7 +490,7 @@ public class DomainFlowUtils { @SuppressWarnings("unchecked") static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) { Optional autorenewPollMessage = - Optional.fromNullable(ofy().load().key(domain.getAutorenewPollMessage()).now()); + Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now()); // Construct an updated autorenew poll message. If the autorenew poll message no longer exists, // create a new one at the same id. This can happen if a transfer was requested on a domain @@ -557,7 +557,7 @@ public class DomainFlowUtils { .setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase()) .setCurrencyIfSupported(registry.getCurrency()) .setPeriod(feeRequest.getPeriod()) - .setClass(pricingLogic.getFeeClass(domainNameString, now).orNull()); + .setClass(pricingLogic.getFeeClass(domainNameString, now).orElse(null)); ImmutableList fees = ImmutableList.of(); switch (feeRequest.getCommandName()) { @@ -939,22 +939,21 @@ public class DomainFlowUtils { .order("modificationTime") .list(); Optional entryToCancel = - Optional.fromJavaUtil( - Streams.findLast( - recentHistoryEntries - .stream() - .filter( - historyEntry -> { - // Look for add and renew transaction records that have yet to be reported - for (DomainTransactionRecord record : - historyEntry.getDomainTransactionRecords()) { - if (cancelableFields.contains(record.getReportField()) - && record.getReportingTime().isAfter(now)) { - return true; - } - } - return false; - }))); + Streams.findLast( + recentHistoryEntries + .stream() + .filter( + historyEntry -> { + // Look for add and renew transaction records that have yet to be reported + for (DomainTransactionRecord record : + historyEntry.getDomainTransactionRecords()) { + if (cancelableFields.contains(record.getReportField()) + && record.getReportingTime().isAfter(now)) { + return true; + } + } + return false; + })); ImmutableSet.Builder recordsBuilder = new ImmutableSet.Builder<>(); if (entryToCancel.isPresent()) { for (DomainTransactionRecord record : entryToCancel.get().getDomainTransactionRecords()) { diff --git a/java/google/registry/flows/domain/DomainInfoFlow.java b/java/google/registry/flows/domain/DomainInfoFlow.java index a4134db3c..5fcdfbeac 100644 --- a/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/java/google/registry/flows/domain/DomainInfoFlow.java @@ -24,7 +24,6 @@ import static google.registry.flows.domain.DomainFlowUtils.loadForeignKeyedDesig import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; @@ -53,6 +52,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainPricingLogic.java b/java/google/registry/flows/domain/DomainPricingLogic.java index b8c607175..22178d180 100644 --- a/java/google/registry/flows/domain/DomainPricingLogic.java +++ b/java/google/registry/flows/domain/DomainPricingLogic.java @@ -19,7 +19,6 @@ import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost; import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -37,6 +36,7 @@ import google.registry.model.domain.fee.BaseFee; import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.Fee; import google.registry.model.registry.Registry; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -210,6 +210,6 @@ public final class DomainPricingLogic { return Optional.of(token); } } - return Optional.absent(); + return Optional.empty(); } } diff --git a/java/google/registry/flows/domain/DomainRenewFlow.java b/java/google/registry/flows/domain/DomainRenewFlow.java index c54bc5b88..a94504ab9 100644 --- a/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/java/google/registry/flows/domain/DomainRenewFlow.java @@ -30,7 +30,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.leapSafeAddYears; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; @@ -74,6 +73,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index ce525f24b..f0519b1a6 100644 --- a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -28,7 +28,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNo import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; @@ -67,6 +66,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/java/google/registry/flows/domain/DomainTransferApproveFlow.java index a7be9b598..2a417b499 100644 --- a/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -33,7 +33,6 @@ import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.util.CollectionUtils.union; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -60,6 +59,7 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -119,7 +119,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { // the transfer period to zero. There is not a transfer cost if the transfer period is zero. Optional billingEvent = (transferData.getTransferPeriod().getValue() == 0) - ? Optional.absent() + ? Optional.empty() : Optional.of( new BillingEvent.OneTime.Builder() .setReason(Reason.TRANSFER) diff --git a/java/google/registry/flows/domain/DomainTransferCancelFlow.java b/java/google/registry/flows/domain/DomainTransferCancelFlow.java index 05aebde98..a285b00ad 100644 --- a/java/google/registry/flows/domain/DomainTransferCancelFlow.java +++ b/java/google/registry/flows/domain/DomainTransferCancelFlow.java @@ -29,7 +29,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -49,6 +48,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainTransferQueryFlow.java b/java/google/registry/flows/domain/DomainTransferQueryFlow.java index 6afa9454c..2e16e40d3 100644 --- a/java/google/registry/flows/domain/DomainTransferQueryFlow.java +++ b/java/google/registry/flows/domain/DomainTransferQueryFlow.java @@ -20,7 +20,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.model.domain.DomainResource.extendRegistrationWithCap; -import com.google.common.base.Optional; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; import google.registry.flows.Flow; @@ -36,6 +35,7 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainTransferRejectFlow.java b/java/google/registry/flows/domain/DomainTransferRejectFlow.java index bcd0e9036..fdf561be6 100644 --- a/java/google/registry/flows/domain/DomainTransferRejectFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRejectFlow.java @@ -31,7 +31,6 @@ import static google.registry.model.reporting.DomainTransactionRecord.Transactio import static google.registry.util.CollectionUtils.union; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.flows.EppException; @@ -51,6 +50,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/java/google/registry/flows/domain/DomainTransferRequestFlow.java index bd33cea82..2501f2951 100644 --- a/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -32,7 +32,6 @@ import static google.registry.model.domain.DomainResource.extendRegistrationWith import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; @@ -72,6 +71,7 @@ import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; import org.joda.time.DateTime; @@ -160,7 +160,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { // If the period is zero, then there is no fee for the transfer. Optional feesAndCredits = (period.getValue() == 0) - ? Optional.absent() + ? Optional.empty() : Optional.of(pricingLogic.getTransferPrice(registry, targetId, now)); if (feesAndCredits.isPresent()) { validateFeeChallenge(targetId, tld, now, feeTransfer, feesAndCredits.get()); @@ -200,7 +200,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { gainingClientId, (feesAndCredits.isPresent()) ? Optional.of(feesAndCredits.get().getTotalCost()) - : Optional.absent(), + : Optional.empty(), now); // Create the transfer data that represents the pending transfer. TransferData pendingTransferData = diff --git a/java/google/registry/flows/domain/DomainTransferUtils.java b/java/google/registry/flows/domain/DomainTransferUtils.java index 697f4312b..fe24d01cf 100644 --- a/java/google/registry/flows/domain/DomainTransferUtils.java +++ b/java/google/registry/flows/domain/DomainTransferUtils.java @@ -18,7 +18,6 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.MoreCollectors.onlyElement; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; @@ -38,6 +37,7 @@ import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferStatus; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.money.Money; import org.joda.time.DateTime; @@ -135,11 +135,10 @@ public final class DomainTransferUtils { registry, transferCost.get())); } + createOptionalAutorenewCancellation( + automaticTransferTime, historyEntry, targetId, existingDomain, transferCost) + .ifPresent(builder::add); return builder - .addAll( - createOptionalAutorenewCancellation( - automaticTransferTime, historyEntry, targetId, existingDomain, transferCost) - .asSet()) .add( createGainingClientAutorenewEvent( serverApproveNewExpirationTime, historyEntry, targetId, gainingClientId)) @@ -273,7 +272,7 @@ public final class DomainTransferUtils { .setEventTime(automaticTransferTime) .build()); } - return Optional.absent(); + return Optional.empty(); } private static BillingEvent.OneTime createTransferBillingEvent( diff --git a/java/google/registry/flows/domain/DomainUpdateFlow.java b/java/google/registry/flows/domain/DomainUpdateFlow.java index 180bf686a..8f6b623c5 100644 --- a/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -44,7 +44,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.DateTimeUtils.earliestOf; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; import com.googlecode.objectify.Key; @@ -82,6 +81,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.registry.Registry; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -371,6 +371,6 @@ public final class DomainUpdateFlow implements TransactionalFlow { } } } - return Optional.absent(); + return Optional.empty(); } } diff --git a/java/google/registry/flows/host/HostCreateFlow.java b/java/google/registry/flows/host/HostCreateFlow.java index f85be62ba..9fdfd12e5 100644 --- a/java/google/registry/flows/host/HostCreateFlow.java +++ b/java/google/registry/flows/host/HostCreateFlow.java @@ -25,7 +25,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.util.CollectionUtils.union; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.config.RegistryConfig.Config; @@ -52,6 +51,7 @@ import google.registry.model.index.ForeignKeyIndex; import google.registry.model.ofy.ObjectifyService; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -103,8 +103,8 @@ public final class HostCreateFlow implements TransactionalFlow { // we can detect error conditions earlier. Optional superordinateDomain = lookupSuperordinateDomain(validateHostName(targetId), now); - verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orNull()); - verifySuperordinateDomainOwnership(clientId, superordinateDomain.orNull()); + verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null)); + verifySuperordinateDomainOwnership(clientId, superordinateDomain.orElse(null)); boolean willBeSubordinate = superordinateDomain.isPresent(); boolean hasIpAddresses = !isNullOrEmpty(command.getInetAddresses()); if (willBeSubordinate != hasIpAddresses) { diff --git a/java/google/registry/flows/host/HostFlowUtils.java b/java/google/registry/flows/host/HostFlowUtils.java index 1a358f3e7..6facd351c 100644 --- a/java/google/registry/flows/host/HostFlowUtils.java +++ b/java/google/registry/flows/host/HostFlowUtils.java @@ -21,7 +21,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static java.util.stream.Collectors.joining; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import google.registry.flows.EppException; import google.registry.flows.EppException.AuthorizationErrorException; @@ -33,6 +32,7 @@ import google.registry.flows.EppException.StatusProhibitsOperationException; import google.registry.model.domain.DomainResource; import google.registry.model.eppcommon.StatusValue; import google.registry.util.Idn; +import java.util.Optional; import org.joda.time.DateTime; /** Static utility functions for host flows. */ @@ -94,7 +94,7 @@ public class HostFlowUtils { Optional tld = findTldForName(hostName); if (!tld.isPresent()) { // This is an host on a TLD we don't run, therefore obviously external, so we are done. - return Optional.absent(); + return Optional.empty(); } // This is a subordinate host String domainName = diff --git a/java/google/registry/flows/host/HostUpdateFlow.java b/java/google/registry/flows/host/HostUpdateFlow.java index a42c51ecc..375d493de 100644 --- a/java/google/registry/flows/host/HostUpdateFlow.java +++ b/java/google/registry/flows/host/HostUpdateFlow.java @@ -30,7 +30,6 @@ import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.isNullOrEmpty; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.dns.DnsQueue; @@ -61,6 +60,7 @@ import google.registry.model.index.ForeignKeyIndex; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import java.util.Objects; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -141,10 +141,10 @@ public final class HostUpdateFlow implements TransactionalFlow { // Note that lookupSuperordinateDomain calls cloneProjectedAtTime on the domain for us. Optional newSuperordinateDomain = lookupSuperordinateDomain(validateHostName(newHostName), now); - verifySuperordinateDomainNotInPendingDelete(newSuperordinateDomain.orNull()); + verifySuperordinateDomainNotInPendingDelete(newSuperordinateDomain.orElse(null)); EppResource owningResource = firstNonNull(oldSuperordinateDomain, existingHost); verifyUpdateAllowed( - command, existingHost, newSuperordinateDomain.orNull(), owningResource, isHostRename); + command, existingHost, newSuperordinateDomain.orElse(null), owningResource, isHostRename); if (isHostRename && loadAndGetKey(HostResource.class, newHostName, now) != null) { throw new HostAlreadyExistsException(newHostName); } diff --git a/java/google/registry/flows/session/LoginFlow.java b/java/google/registry/flows/session/LoginFlow.java index 7f6011963..0d3bb5718 100644 --- a/java/google/registry/flows/session/LoginFlow.java +++ b/java/google/registry/flows/session/LoginFlow.java @@ -17,7 +17,6 @@ package google.registry.flows.session; import static com.google.common.collect.Sets.difference; import static google.registry.util.CollectionUtils.nullToEmpty; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import google.registry.flows.EppException; import google.registry.flows.EppException.AuthenticationErrorClosingConnectionException; @@ -42,6 +41,7 @@ import google.registry.model.eppinput.EppInput.Services; import google.registry.model.eppoutput.EppResponse; import google.registry.model.registrar.Registrar; import google.registry.util.FormattingLogger; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; diff --git a/java/google/registry/keyring/api/KeyModule.java b/java/google/registry/keyring/api/KeyModule.java index c282bb731..d8e0781d1 100644 --- a/java/google/registry/keyring/api/KeyModule.java +++ b/java/google/registry/keyring/api/KeyModule.java @@ -16,10 +16,10 @@ package google.registry.keyring.api; import static com.google.common.base.Strings.emptyToNull; -import com.google.common.base.Optional; import dagger.Module; import dagger.Provides; import java.lang.annotation.Documented; +import java.util.Optional; import javax.inject.Qualifier; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPrivateKey; @@ -57,19 +57,19 @@ public final class KeyModule { @Provides @Key("marksdbDnlLogin") static Optional provideMarksdbDnlLogin(Keyring keyring) { - return Optional.fromNullable(emptyToNull(keyring.getMarksdbDnlLogin())); + return Optional.ofNullable(emptyToNull(keyring.getMarksdbDnlLogin())); } @Provides @Key("marksdbLordnPassword") static Optional provideMarksdbLordnPassword(Keyring keyring) { - return Optional.fromNullable(emptyToNull(keyring.getMarksdbLordnPassword())); + return Optional.ofNullable(emptyToNull(keyring.getMarksdbLordnPassword())); } @Provides @Key("marksdbSmdrlLogin") static Optional provideMarksdbSmdrlLogin(Keyring keyring) { - return Optional.fromNullable(emptyToNull(keyring.getMarksdbSmdrlLogin())); + return Optional.ofNullable(emptyToNull(keyring.getMarksdbSmdrlLogin())); } @Provides diff --git a/java/google/registry/keyring/api/PgpHelper.java b/java/google/registry/keyring/api/PgpHelper.java index ee1a5bf8f..4fb87e9f3 100644 --- a/java/google/registry/keyring/api/PgpHelper.java +++ b/java/google/registry/keyring/api/PgpHelper.java @@ -22,10 +22,10 @@ import static org.bouncycastle.bcpg.PublicKeyAlgorithmTags.ELGAMAL_GENERAL; import static org.bouncycastle.bcpg.PublicKeyAlgorithmTags.RSA_GENERAL; import static org.bouncycastle.bcpg.PublicKeyAlgorithmTags.RSA_SIGN; -import com.google.common.base.Optional; import com.google.common.base.VerifyException; import java.io.IOException; import java.util.Iterator; +import java.util.Optional; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPrivateKey; @@ -156,7 +156,7 @@ public final class PgpHelper { throw new AssertionError(); } } - return Optional.absent(); + return Optional.empty(); } /** Returns {@code true} if this key can be used for signing. */ diff --git a/java/google/registry/loadtest/LoadTestModule.java b/java/google/registry/loadtest/LoadTestModule.java index 2d334f1ca..c49a9e253 100644 --- a/java/google/registry/loadtest/LoadTestModule.java +++ b/java/google/registry/loadtest/LoadTestModule.java @@ -43,73 +43,73 @@ public final class LoadTestModule { @Parameter("delaySeconds") static int provideDelaySeconds(HttpServletRequest req) { return extractOptionalIntParameter(req, "delaySeconds") - .or(Minutes.ONE.toStandardSeconds().getSeconds()); + .orElse(Minutes.ONE.toStandardSeconds().getSeconds()); } @Provides @Parameter("runSeconds") static int provideRunSeconds(HttpServletRequest req) { return extractOptionalIntParameter(req, "runSeconds") - .or(Minutes.ONE.toStandardSeconds().getSeconds()); + .orElse(Minutes.ONE.toStandardSeconds().getSeconds()); } @Provides @Parameter("successfulDomainCreates") static int provideSuccessfulDomainCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "successfulDomainCreates").or(0); + return extractOptionalIntParameter(req, "successfulDomainCreates").orElse(0); } @Provides @Parameter("failedDomainCreates") static int provideFailedDomainCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "failedDomainCreates").or(0); + return extractOptionalIntParameter(req, "failedDomainCreates").orElse(0); } @Provides @Parameter("domainInfos") static int provideDomainInfos(HttpServletRequest req) { - return extractOptionalIntParameter(req, "domainInfos").or(0); + return extractOptionalIntParameter(req, "domainInfos").orElse(0); } @Provides @Parameter("domainChecks") static int provideDomainChecks(HttpServletRequest req) { - return extractOptionalIntParameter(req, "domainChecks").or(0); + return extractOptionalIntParameter(req, "domainChecks").orElse(0); } @Provides @Parameter("successfulContactCreates") static int provideSuccessfulContactCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "successfulContactCreates").or(0); + return extractOptionalIntParameter(req, "successfulContactCreates").orElse(0); } @Provides @Parameter("failedContactCreates") static int provideFailedContactCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "failedContactCreates").or(0); + return extractOptionalIntParameter(req, "failedContactCreates").orElse(0); } @Provides @Parameter("contactInfos") static int provideContactInfos(HttpServletRequest req) { - return extractOptionalIntParameter(req, "contactInfos").or(0); + return extractOptionalIntParameter(req, "contactInfos").orElse(0); } @Provides @Parameter("successfulHostCreates") static int provideSuccessfulHostCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "successfulHostCreates").or(0); + return extractOptionalIntParameter(req, "successfulHostCreates").orElse(0); } @Provides @Parameter("failedHostCreates") static int provideFailedHostCreates(HttpServletRequest req) { - return extractOptionalIntParameter(req, "failedHostCreates").or(0); + return extractOptionalIntParameter(req, "failedHostCreates").orElse(0); } @Provides @Parameter("hostInfos") static int provideHostInfos(HttpServletRequest req) { - return extractOptionalIntParameter(req, "hostInfos").or(0); + return extractOptionalIntParameter(req, "hostInfos").orElse(0); } } diff --git a/java/google/registry/mapreduce/MapreduceModule.java b/java/google/registry/mapreduce/MapreduceModule.java index e00b501dc..d3e3e44e9 100644 --- a/java/google/registry/mapreduce/MapreduceModule.java +++ b/java/google/registry/mapreduce/MapreduceModule.java @@ -20,10 +20,10 @@ import static google.registry.mapreduce.MapreduceRunner.PARAM_REDUCE_SHARDS; import static google.registry.request.RequestParameters.extractBooleanParameter; import static google.registry.request.RequestParameters.extractOptionalIntParameter; -import com.google.common.base.Optional; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** Dagger module for the mapreduce package. */ diff --git a/java/google/registry/mapreduce/MapreduceRunner.java b/java/google/registry/mapreduce/MapreduceRunner.java index 9c152ac54..c6e717753 100644 --- a/java/google/registry/mapreduce/MapreduceRunner.java +++ b/java/google/registry/mapreduce/MapreduceRunner.java @@ -33,12 +33,12 @@ import com.google.appengine.tools.mapreduce.outputs.NoOutput; import com.google.appengine.tools.pipeline.Job0; import com.google.appengine.tools.pipeline.JobSetting; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import google.registry.mapreduce.inputs.ConcatenatingInput; import google.registry.request.Parameter; import google.registry.util.FormattingLogger; import google.registry.util.PipelineUtils; import java.io.Serializable; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.Duration; @@ -143,7 +143,7 @@ public class MapreduceRunner { return new MapJob<>( new MapSpecification.Builder() .setJobName(jobName) - .setInput(new ConcatenatingInput<>(inputs, httpParamMapShards.or(defaultMapShards))) + .setInput(new ConcatenatingInput<>(inputs, httpParamMapShards.orElse(defaultMapShards))) .setMapper(mapper) .setOutput(output) .build(), @@ -199,13 +199,13 @@ public class MapreduceRunner { return new MapReduceJob<>( new MapReduceSpecification.Builder() .setJobName(jobName) - .setInput(new ConcatenatingInput<>(inputs, httpParamMapShards.or(defaultMapShards))) + .setInput(new ConcatenatingInput<>(inputs, httpParamMapShards.orElse(defaultMapShards))) .setMapper(mapper) .setReducer(reducer) .setOutput(output) .setKeyMarshaller(Marshallers.getSerializationMarshaller()) .setValueMarshaller(Marshallers.getSerializationMarshaller()) - .setNumReducers(httpParamReduceShards.or(defaultReduceShards)) + .setNumReducers(httpParamReduceShards.orElse(defaultReduceShards)) .build(), new MapReduceSettings.Builder() .setWorkerQueueName(QUEUE_NAME) diff --git a/java/google/registry/mapreduce/inputs/BUILD b/java/google/registry/mapreduce/inputs/BUILD index 52b9958c6..74390a6e0 100644 --- a/java/google/registry/mapreduce/inputs/BUILD +++ b/java/google/registry/mapreduce/inputs/BUILD @@ -14,6 +14,7 @@ java_library( "@com_google_appengine_api_1_0_sdk", "@com_google_appengine_tools_appengine_mapreduce", "@com_google_appengine_tools_appengine_pipeline", + "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", "@javax_servlet_api", diff --git a/java/google/registry/mapreduce/inputs/CommitLogManifestInput.java b/java/google/registry/mapreduce/inputs/CommitLogManifestInput.java index c7238b267..42a0e9d14 100644 --- a/java/google/registry/mapreduce/inputs/CommitLogManifestInput.java +++ b/java/google/registry/mapreduce/inputs/CommitLogManifestInput.java @@ -16,27 +16,33 @@ package google.registry.mapreduce.inputs; import com.google.appengine.tools.mapreduce.Input; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.Key; import google.registry.model.ofy.CommitLogBucket; import google.registry.model.ofy.CommitLogManifest; import java.util.List; +import javax.annotation.Nullable; import org.joda.time.DateTime; /** Base class for {@link Input} classes that map over {@link CommitLogManifest}. */ public class CommitLogManifestInput extends Input> { - private static final long serialVersionUID = 2043552272352286428L; + private static final long serialVersionUID = 6744322799131602384L; /** * Cutoff date for result. * - * If present, all resulting CommitLogManifest will be dated prior to this date. + *

If present, all resulting CommitLogManifest will be dated prior to this date. This can't be + * of type {@code Optional} because Optional purposely isn't Serializable. */ - private final Optional olderThan; + @Nullable + private final DateTime olderThan; - public CommitLogManifestInput(Optional olderThan) { + public CommitLogManifestInput() { + this.olderThan = null; + } + + public CommitLogManifestInput(@Nullable DateTime olderThan) { this.olderThan = olderThan; } diff --git a/java/google/registry/mapreduce/inputs/CommitLogManifestReader.java b/java/google/registry/mapreduce/inputs/CommitLogManifestReader.java index bc440e93f..434c9fd56 100644 --- a/java/google/registry/mapreduce/inputs/CommitLogManifestReader.java +++ b/java/google/registry/mapreduce/inputs/CommitLogManifestReader.java @@ -21,7 +21,6 @@ import com.google.appengine.api.datastore.Cursor; import com.google.appengine.api.datastore.DatastoreTimeoutException; import com.google.appengine.api.datastore.QueryResultIterator; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import com.googlecode.objectify.cmd.Query; import google.registry.model.ofy.CommitLogBucket; @@ -30,13 +29,12 @@ import google.registry.util.FormattingLogger; import google.registry.util.Retrier; import google.registry.util.SystemSleeper; import java.util.NoSuchElementException; +import javax.annotation.Nullable; import org.joda.time.DateTime; /** {@link InputReader} that maps over {@link CommitLogManifest}. */ class CommitLogManifestReader extends InputReader> { - private static final long serialVersionUID = 5117046535590539778L; - static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); /** @@ -48,6 +46,7 @@ class CommitLogManifestReader extends InputReader> { private static final long MEMORY_ESTIMATE = 100 * 1024; private static final Retrier retrier = new Retrier(new SystemSleeper(), 3); + private static final long serialVersionUID = 2553537421598284748L; private final Key bucketKey; @@ -56,7 +55,8 @@ class CommitLogManifestReader extends InputReader> { * * If present, all resulting CommitLogManifest will be dated prior to this date. */ - private final Optional olderThan; + @Nullable + private final DateTime olderThan; private Cursor cursor; private int total; @@ -64,7 +64,7 @@ class CommitLogManifestReader extends InputReader> { private transient QueryResultIterator> queryIterator; - CommitLogManifestReader(Key bucketKey, Optional olderThan) { + CommitLogManifestReader(Key bucketKey, @Nullable DateTime olderThan) { this.bucketKey = bucketKey; this.olderThan = olderThan; } @@ -112,10 +112,10 @@ class CommitLogManifestReader extends InputReader> { /** Query for children of this bucket. */ Query query() { Query query = ofy().load().type(CommitLogManifest.class).ancestor(bucketKey); - if (olderThan.isPresent()) { + if (olderThan != null) { query = query.filterKey( "<", - Key.create(bucketKey, CommitLogManifest.class, olderThan.get().getMillis())); + Key.create(bucketKey, CommitLogManifest.class, olderThan.getMillis())); } return query; } diff --git a/java/google/registry/model/Buildable.java b/java/google/registry/model/Buildable.java index 7f325b1cd..334899454 100644 --- a/java/google/registry/model/Buildable.java +++ b/java/google/registry/model/Buildable.java @@ -18,10 +18,10 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import google.registry.model.ofy.ObjectifyService; import google.registry.util.TypeUtils.TypeInstantiator; import java.lang.reflect.Field; +import java.util.Optional; /** Interface for {@link ImmutableObject} subclasses that have a builder. */ public interface Buildable { @@ -64,8 +64,8 @@ public interface Buildable { } if (idField != null && !idField.getType().equals(String.class) - && Optional.fromNullable((Long) ModelUtils.getFieldValue(instance, idField)) - .or(0L) == 0) { + && Optional.ofNullable((Long) ModelUtils.getFieldValue(instance, idField)) + .orElse(0L) == 0) { ModelUtils.setFieldValue(instance, idField, ObjectifyService.allocateId()); } return instance; diff --git a/java/google/registry/model/EppResource.java b/java/google/registry/model/EppResource.java index 74787e185..398fa71a0 100644 --- a/java/google/registry/model/EppResource.java +++ b/java/google/registry/model/EppResource.java @@ -23,7 +23,6 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.END_OF_TIME; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import com.googlecode.objectify.Key; @@ -32,6 +31,7 @@ import com.googlecode.objectify.annotation.Index; import google.registry.model.eppcommon.StatusValue; import google.registry.model.ofy.CommitLogManifest; import google.registry.model.transfer.TransferData; +import java.util.Optional; import java.util.Set; import org.joda.time.DateTime; @@ -296,7 +296,7 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable { addStatusValue(StatusValue.OK); } // If there is no deletion time, set it to END_OF_TIME. - setDeletionTime(Optional.fromNullable(getInstance().deletionTime).or(END_OF_TIME)); + setDeletionTime(Optional.ofNullable(getInstance().deletionTime).orElse(END_OF_TIME)); return ImmutableObject.cloneEmptyToNull(super.build()); } } diff --git a/java/google/registry/model/UpdateAutoTimestamp.java b/java/google/registry/model/UpdateAutoTimestamp.java index f385b2a27..f8f250997 100644 --- a/java/google/registry/model/UpdateAutoTimestamp.java +++ b/java/google/registry/model/UpdateAutoTimestamp.java @@ -16,8 +16,8 @@ package google.registry.model; import static google.registry.util.DateTimeUtils.START_OF_TIME; -import com.google.common.base.Optional; import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory; +import java.util.Optional; import org.joda.time.DateTime; /** @@ -31,7 +31,7 @@ public class UpdateAutoTimestamp extends ImmutableObject { /** Returns the timestamp, or {@link #START_OF_TIME} if it's null. */ public DateTime getTimestamp() { - return Optional.fromNullable(timestamp).or(START_OF_TIME); + return Optional.ofNullable(timestamp).orElse(START_OF_TIME); } public static UpdateAutoTimestamp create(DateTime timestamp) { diff --git a/java/google/registry/model/billing/BillingEvent.java b/java/google/registry/model/billing/BillingEvent.java index 8f2d2991d..e37bd408f 100644 --- a/java/google/registry/model/billing/BillingEvent.java +++ b/java/google/registry/model/billing/BillingEvent.java @@ -24,7 +24,6 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -44,6 +43,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import java.util.Objects; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.money.Money; @@ -391,7 +391,7 @@ public abstract class BillingEvent extends ImmutableObject checkNotNull(instance.reason); instance.recurrenceTimeOfYear = TimeOfYear.fromDateTime(instance.eventTime); instance.recurrenceEndTime = - Optional.fromNullable(instance.recurrenceEndTime).or(END_OF_TIME); + Optional.ofNullable(instance.recurrenceEndTime).orElse(END_OF_TIME); return super.build(); } } diff --git a/java/google/registry/model/billing/RegistrarCredit.java b/java/google/registry/model/billing/RegistrarCredit.java index f2dbf9a79..0f8d8fc4a 100644 --- a/java/google/registry/model/billing/RegistrarCredit.java +++ b/java/google/registry/model/billing/RegistrarCredit.java @@ -21,7 +21,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.Registries.assertTldExists; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Ordering; @@ -35,6 +34,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.annotations.ReportedOn; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; +import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.time.DateTime; @@ -194,7 +194,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable Registry.get(instance.tld).getCurrency().equals(instance.currency), "Credits must be in the currency of the assigned TLD"); instance.description = - Optional.fromNullable(instance.description).or(instance.getDefaultDescription()); + Optional.ofNullable(instance.description).orElse(instance.getDefaultDescription()); return super.build(); } } diff --git a/java/google/registry/model/billing/RegistrarCreditBalance.java b/java/google/registry/model/billing/RegistrarCreditBalance.java index 7920e79b6..a86d139ac 100644 --- a/java/google/registry/model/billing/RegistrarCreditBalance.java +++ b/java/google/registry/model/billing/RegistrarCreditBalance.java @@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkState; import static google.registry.model.ofy.ObjectifyService.ofy; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ForwardingNavigableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Maps; @@ -34,6 +33,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.annotations.ReportedOn; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.money.Money; import org.joda.time.DateTime; @@ -171,8 +171,8 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui ofy().load().type(RegistrarCreditBalance.class).ancestor(registrarCredit)) { // Create the submap at this key if it doesn't exist already. Map submap = - Optional.fromNullable(map.get(balance.effectiveTime)) - .or(new HashMap()); + Optional.ofNullable(map.get(balance.effectiveTime)) + .orElse(new HashMap()); submap.put(balance.writtenTime, balance.amount); map.put(balance.effectiveTime, submap); } @@ -212,8 +212,8 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui private Optional getMostRecentlyWrittenBalance( Map.Entry> balancesAtEffectiveTime) { return balancesAtEffectiveTime == null - ? Optional.absent() - // Don't use Optional.fromNullable() here since it's an error if there's a empty submap. + ? Optional.empty() + // Don't use Optional.ofNullable() here since it's an error if there's a empty submap. : Optional.of(balancesAtEffectiveTime.getValue().lastEntry().getValue()); } diff --git a/java/google/registry/model/contact/ContactResource.java b/java/google/registry/model/contact/ContactResource.java index de9e36d9c..cb24e90cb 100644 --- a/java/google/registry/model/contact/ContactResource.java +++ b/java/google/registry/model/contact/ContactResource.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.ImmutableList.toImmutableList; import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime; -import com.google.common.base.Optional; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.annotation.Entity; @@ -32,6 +31,7 @@ import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.PostalInfo.Type; import google.registry.model.transfer.TransferData; +import java.util.Optional; import java.util.stream.Stream; import javax.xml.bind.annotation.XmlElement; import org.joda.time.DateTime; @@ -147,7 +147,7 @@ public class ContactResource extends EppResource implements @Override public final TransferData getTransferData() { - return Optional.fromNullable(transferData).or(TransferData.EMPTY); + return Optional.ofNullable(transferData).orElse(TransferData.EMPTY); } @Override diff --git a/java/google/registry/model/contact/PostalInfo.java b/java/google/registry/model/contact/PostalInfo.java index 70a7acd31..6e43dd7e2 100644 --- a/java/google/registry/model/contact/PostalInfo.java +++ b/java/google/registry/model/contact/PostalInfo.java @@ -16,11 +16,11 @@ package google.registry.model.contact; import static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Optional; import com.googlecode.objectify.annotation.Embed; import google.registry.model.Buildable; import google.registry.model.Buildable.Overlayable; import google.registry.model.ImmutableObject; +import java.util.Optional; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEnumValue; @@ -77,10 +77,9 @@ public class PostalInfo extends ImmutableObject implements Overlayable getEffectiveDate() { - return Optional.absent(); + return Optional.empty(); } } diff --git a/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java index 9ad93d178..124f6b79d 100644 --- a/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java @@ -14,10 +14,10 @@ package google.registry.model.domain.fee06; -import com.google.common.base.Optional; import google.registry.model.domain.fee.FeeExtensionCommandDescriptor; import google.registry.model.domain.fee.FeeQueryCommandExtensionItem; import google.registry.model.eppinput.EppInput.CommandExtension; +import java.util.Optional; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.joda.money.CurrencyUnit; @@ -66,7 +66,7 @@ public class FeeInfoCommandExtensionV06 @Override public Optional getEffectiveDate() { - return Optional.absent(); + return Optional.empty(); } } diff --git a/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java index 7502a51c7..8116ad72e 100644 --- a/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java @@ -16,7 +16,6 @@ package google.registry.model.domain.fee11; import static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.ImmutableObject; @@ -26,6 +25,7 @@ import google.registry.model.domain.fee.FeeCheckCommandExtensionItem; import google.registry.model.domain.fee.FeeCheckResponseExtensionItem; import google.registry.model.domain.fee.FeeExtensionCommandDescriptor; import google.registry.model.domain.fee11.FeeCheckCommandExtensionV11.FeeCheckCommandExtensionItemV11; +import java.util.Optional; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @@ -115,7 +115,7 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject @Override public Period getPeriod() { - return Optional.fromNullable(period).or(DEFAULT_PERIOD); + return Optional.ofNullable(period).orElse(DEFAULT_PERIOD); } @Override @@ -140,7 +140,7 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject @Override public Optional getEffectiveDate() { - return Optional.absent(); + return Optional.empty(); } } } diff --git a/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java b/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java index e6ef5fbe7..4bc0322a5 100644 --- a/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java +++ b/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java @@ -16,9 +16,9 @@ package google.registry.model.domain.fee12; import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; -import com.google.common.base.Optional; import google.registry.model.domain.Period; import google.registry.model.domain.fee.FeeCheckCommandExtensionItem; +import java.util.Optional; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @@ -110,6 +110,6 @@ public class FeeCheckCommandExtensionItemV12 extends FeeCheckCommandExtensionIte @Override public Optional getEffectiveDate() { - return Optional.fromNullable(feeDate); + return Optional.ofNullable(feeDate); } } diff --git a/java/google/registry/model/domain/launch/LaunchNotice.java b/java/google/registry/model/domain/launch/LaunchNotice.java index 733507ee5..ba5fc4330 100644 --- a/java/google/registry/model/domain/launch/LaunchNotice.java +++ b/java/google/registry/model/domain/launch/LaunchNotice.java @@ -22,12 +22,12 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; -import com.google.common.base.Optional; import com.google.common.primitives.Ints; import com.googlecode.objectify.annotation.Embed; import com.googlecode.objectify.annotation.IgnoreSave; import com.googlecode.objectify.condition.IfNull; import google.registry.model.ImmutableObject; +import java.util.Optional; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @@ -64,7 +64,7 @@ public class LaunchNotice extends ImmutableObject { public String getValidatorId() { // The default value is "tmch". - return Optional.fromNullable(validatorId).or("tmch"); + return Optional.ofNullable(validatorId).orElse("tmch"); } } @@ -78,7 +78,7 @@ public class LaunchNotice extends ImmutableObject { DateTime acceptedTime; public NoticeIdType getNoticeId() { - return Optional.fromNullable(noticeId).or(EMPTY_NOTICE_ID); + return Optional.ofNullable(noticeId).orElse(EMPTY_NOTICE_ID); } public DateTime getExpirationTime() { diff --git a/java/google/registry/model/eppinput/EppInput.java b/java/google/registry/model/eppinput/EppInput.java index c958b5275..31f16bb97 100644 --- a/java/google/registry/model/eppinput/EppInput.java +++ b/java/google/registry/model/eppinput/EppInput.java @@ -18,7 +18,6 @@ import static google.registry.util.CollectionUtils.nullSafeImmutableCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.ImmutableObject; @@ -56,6 +55,7 @@ import google.registry.model.eppinput.ResourceCommand.ResourceCheck; import google.registry.model.eppinput.ResourceCommand.SingleResourceCommand; import google.registry.model.host.HostCommand; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlAttribute; @@ -107,12 +107,12 @@ public class EppInput extends ImmutableObject { return Optional.of(xmlSchemaAnnotation.xmlns()[0].prefix()); } } - return Optional.absent(); + return Optional.empty(); } /** Returns whether this EppInput represents a command that operates on domain resources. */ public boolean isDomainResourceType() { - return getResourceType().or("").equals("domain"); + return getResourceType().orElse("").equals("domain"); } @Nullable @@ -131,7 +131,7 @@ public class EppInput extends ImmutableObject { ResourceCommand resourceCommand = getResourceCommand(); return resourceCommand instanceof SingleResourceCommand ? Optional.of(((SingleResourceCommand) resourceCommand).getTargetId()) - : Optional.absent(); + : Optional.empty(); } /** diff --git a/java/google/registry/model/eppoutput/EppResponse.java b/java/google/registry/model/eppoutput/EppResponse.java index 9524cbf47..9a0d4cc00 100644 --- a/java/google/registry/model/eppoutput/EppResponse.java +++ b/java/google/registry/model/eppoutput/EppResponse.java @@ -17,7 +17,6 @@ package google.registry.model.eppoutput; import static google.registry.util.CollectionUtils.forceEmptyToNull; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; @@ -157,9 +156,7 @@ public class EppResponse extends ImmutableObject implements ResponseOrGreeting { @Nullable public ResponseExtension getFirstExtensionOfType(Class clazz) { - return Optional.fromJavaUtil( - extensions.stream().filter(clazz::isInstance).map(clazz::cast).findFirst()) - .orNull(); + return extensions.stream().filter(clazz::isInstance).map(clazz::cast).findFirst().orElse(null); } @Nullable diff --git a/java/google/registry/model/host/HostResource.java b/java/google/registry/model/host/HostResource.java index 8837cad66..0ea9696c8 100644 --- a/java/google/registry/model/host/HostResource.java +++ b/java/google/registry/model/host/HostResource.java @@ -21,7 +21,6 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DomainNameUtils.canonicalizeDomainName; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Entity; @@ -35,6 +34,7 @@ import google.registry.model.annotations.ReportedOn; import google.registry.model.domain.DomainResource; import google.registry.model.transfer.TransferData; import java.net.InetAddress; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -146,9 +146,9 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource superordinateDomain != null && Key.create(superordinateDomain).equals(getSuperordinateDomain())); DateTime lastSuperordinateChange = - Optional.fromNullable(getLastSuperordinateChange()).or(getCreationTime()); + Optional.ofNullable(getLastSuperordinateChange()).orElse(getCreationTime()); DateTime lastTransferOfCurrentSuperordinate = - Optional.fromNullable(superordinateDomain.getLastTransferTime()).or(START_OF_TIME); + Optional.ofNullable(superordinateDomain.getLastTransferTime()).orElse(START_OF_TIME); return (lastSuperordinateChange.isBefore(lastTransferOfCurrentSuperordinate)) ? superordinateDomain.getLastTransferTime() : getLastTransferTime(); diff --git a/java/google/registry/model/poll/PollMessage.java b/java/google/registry/model/poll/PollMessage.java index fed697c55..ea286463f 100644 --- a/java/google/registry/model/poll/PollMessage.java +++ b/java/google/registry/model/poll/PollMessage.java @@ -22,7 +22,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Converter; -import com.google.common.base.Optional; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; @@ -47,6 +46,7 @@ import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferResponse.ContactTransferResponse; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; /** @@ -351,7 +351,7 @@ public abstract class PollMessage extends ImmutableObject public Autorenew build() { Autorenew instance = getInstance(); instance.autorenewEndTime = - Optional.fromNullable(instance.autorenewEndTime).or(END_OF_TIME); + Optional.ofNullable(instance.autorenewEndTime).orElse(END_OF_TIME); return super.build(); } } diff --git a/java/google/registry/model/pricing/PremiumPricingEngine.java b/java/google/registry/model/pricing/PremiumPricingEngine.java index 919440341..f951449d7 100644 --- a/java/google/registry/model/pricing/PremiumPricingEngine.java +++ b/java/google/registry/model/pricing/PremiumPricingEngine.java @@ -14,7 +14,7 @@ package google.registry.model.pricing; -import com.google.common.base.Optional; +import java.util.Optional; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java b/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java index b284ea1e2..8f951cef4 100644 --- a/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java +++ b/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java @@ -23,9 +23,9 @@ import static google.registry.model.registry.label.ReservedList.getReservationTy import static google.registry.util.DomainNameUtils.getTldFromDomainName; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import google.registry.model.registry.Registry; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; import org.joda.time.DateTime; @@ -52,8 +52,8 @@ public final class StaticPremiumListPricingEngine implements PremiumPricingEngin isNameCollisionInSunrise ? "collision" : null)); return DomainPrices.create( premiumPrice.isPresent(), - premiumPrice.or(registry.getStandardCreateCost()), - premiumPrice.or(registry.getStandardRenewCost(priceTime)), - Optional.fromNullable(feeClass)); + premiumPrice.orElse(registry.getStandardCreateCost()), + premiumPrice.orElse(registry.getStandardRenewCost(priceTime)), + Optional.ofNullable(feeClass)); } } diff --git a/java/google/registry/model/registrar/Registrar.java b/java/google/registry/model/registrar/Registrar.java index 4a50da0f0..01234f780 100644 --- a/java/google/registry/model/registrar/Registrar.java +++ b/java/google/registry/model/registrar/Registrar.java @@ -39,7 +39,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Comparator.comparing; import static java.util.function.Predicate.isEqual; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; @@ -80,6 +79,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import javax.annotation.Nullable; @@ -896,13 +896,13 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable /** Loads and returns a registrar entity by its client id directly from Datastore. */ public static Optional loadByClientId(String clientId) { checkArgument(!Strings.isNullOrEmpty(clientId), "clientId must be specified"); - return Optional.fromNullable( + return Optional.ofNullable( ofy().load().type(Registrar.class).parent(getCrossTldKey()).id(clientId).now()); } /** Loads and returns a registrar entity by its client id using an in-memory cache. */ public static Optional loadByClientIdCached(String clientId) { checkArgument(!Strings.isNullOrEmpty(clientId), "clientId must be specified"); - return Optional.fromNullable(CACHE_BY_CLIENT_ID.get().get(clientId)); + return Optional.ofNullable(CACHE_BY_CLIENT_ID.get().get(clientId)); } } diff --git a/java/google/registry/model/registry/Registries.java b/java/google/registry/model/registry/Registries.java index 0488aac36..cebc29f78 100644 --- a/java/google/registry/model/registry/Registries.java +++ b/java/google/registry/model/registry/Registries.java @@ -27,7 +27,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -35,6 +34,7 @@ import com.google.common.collect.Streams; import com.google.common.net.InternetDomainName; import com.googlecode.objectify.Work; import google.registry.model.registry.Registry.TldType; +import java.util.Optional; /** Utilities for finding and listing {@link Registry} entities. */ public final class Registries { @@ -123,7 +123,7 @@ public final class Registries { return Optional.of(domainName); } } - return Optional.absent(); + return Optional.empty(); } /** @@ -132,7 +132,7 @@ public final class Registries { */ public static InternetDomainName findTldForNameOrThrow(InternetDomainName domainName) { return checkArgumentNotNull( - findTldForName(domainName).orNull(), + findTldForName(domainName).orElse(null), "Domain name is not under a recognized TLD: %s", domainName.toString()); } } diff --git a/java/google/registry/model/registry/Registry.java b/java/google/registry/model/registry/Registry.java index 5552e826b..0ae1783c7 100644 --- a/java/google/registry/model/registry/Registry.java +++ b/java/google/registry/model/registry/Registry.java @@ -30,7 +30,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.joda.money.CurrencyUnit.USD; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -67,6 +66,7 @@ import google.registry.model.registry.label.ReservedList.ReservedListEntry; import google.registry.util.Idn; import java.util.Collection; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.money.CurrencyUnit; @@ -213,7 +213,7 @@ public class Registry extends ImmutableObject implements Buildable { /** Returns the registry for a given TLD, throwing if none exists. */ public static Registry get(String tld) { - Registry registry = CACHE.getUnchecked(tld).orNull(); + Registry registry = CACHE.getUnchecked(tld).orElse(null); if (registry == null) { throw new RegistryNotFoundException(tld); } @@ -241,7 +241,7 @@ public class Registry extends ImmutableObject implements Buildable { public Optional load(final String tld) { // Enter a transactionless context briefly; we don't want to enroll every TLD in a // transaction that might be wrapping this call. - return Optional.fromNullable( + return Optional.ofNullable( ofy() .doTransactionless( new Work() { diff --git a/java/google/registry/model/registry/label/BaseDomainLabelList.java b/java/google/registry/model/registry/label/BaseDomainLabelList.java index f506d0c10..b471a86a0 100644 --- a/java/google/registry/model/registry/label/BaseDomainLabelList.java +++ b/java/google/registry/model/registry/label/BaseDomainLabelList.java @@ -19,7 +19,6 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.registry.Registries.getTlds; -import com.google.common.base.Optional; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; import com.google.common.cache.LoadingCache; import com.google.common.collect.HashMultiset; @@ -39,6 +38,7 @@ import google.registry.model.registry.label.ReservedList.ReservedListEntry; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -153,7 +153,7 @@ public abstract class BaseDomainLabelList, R extends Dom try { return Optional.of(cache.get(listName)); } catch (InvalidCacheLoadException e) { - return Optional.absent(); + return Optional.empty(); } catch (ExecutionException e) { throw new UncheckedExecutionException("Could not retrieve list named " + listName, e); } diff --git a/java/google/registry/model/registry/label/PremiumList.java b/java/google/registry/model/registry/label/PremiumList.java index b756ae7cf..7f4d2d878 100644 --- a/java/google/registry/model/registry/label/PremiumList.java +++ b/java/google/registry/model/registry/label/PremiumList.java @@ -13,6 +13,7 @@ // limitations under the License. package google.registry.model.registry.label; + import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.hash.Funnels.unencodedCharsFunnel; import static google.registry.config.RegistryConfig.getDomainLabelListCacheDuration; @@ -24,7 +25,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -46,6 +46,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; @@ -206,12 +207,9 @@ public final class PremiumList extends BaseDomainLabelList load(final Key entryKey) { return ofy() .doTransactionless( - new Work>() { - @Override - public Optional run() { - return Optional.fromNullable(ofy().load().key(entryKey).now()); - } - }); + () -> { + return Optional.ofNullable(ofy().load().key(entryKey).now()); + }); } }); } @@ -226,7 +224,7 @@ public final class PremiumList extends BaseDomainLabelList absent(); + return Optional.empty(); } catch (ExecutionException e) { throw new UncheckedExecutionException("Could not retrieve premium list named " + name, e); } diff --git a/java/google/registry/model/registry/label/PremiumListUtils.java b/java/google/registry/model/registry/label/PremiumListUtils.java index ed79cf5a1..d23858098 100644 --- a/java/google/registry/model/registry/label/PremiumListUtils.java +++ b/java/google/registry/model/registry/label/PremiumListUtils.java @@ -31,7 +31,6 @@ import static org.joda.time.DateTimeZone.UTC; import com.google.auto.value.AutoValue; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -45,6 +44,7 @@ import google.registry.model.registry.label.PremiumList.PremiumListEntry; import google.registry.model.registry.label.PremiumList.PremiumListRevision; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.ExecutionException; import org.joda.money.Money; import org.joda.time.DateTime; @@ -73,7 +73,7 @@ public final class PremiumListUtils { public static Optional getPremiumPrice(String label, Registry registry) { // If the registry has no configured premium list, then no labels are premium. if (registry.getPremiumList() == null) { - return Optional.absent(); + return Optional.empty(); } DateTime startTime = DateTime.now(UTC); String listName = registry.getPremiumList().getName(); @@ -103,7 +103,7 @@ public final class PremiumListUtils { private static CheckResults checkStatus(PremiumListRevision premiumListRevision, String label) { if (!premiumListRevision.getProbablePremiumLabels().mightContain(label)) { - return CheckResults.create(BLOOM_FILTER_NEGATIVE, Optional.absent()); + return CheckResults.create(BLOOM_FILTER_NEGATIVE, Optional.empty()); } Key entryKey = @@ -115,7 +115,7 @@ public final class PremiumListUtils { if (entry.isPresent()) { return CheckResults.create(CACHED_POSITIVE, Optional.of(entry.get().getValue())); } else { - return CheckResults.create(CACHED_NEGATIVE, Optional.absent()); + return CheckResults.create(CACHED_NEGATIVE, Optional.empty()); } } @@ -123,7 +123,7 @@ public final class PremiumListUtils { if (entry.isPresent()) { return CheckResults.create(UNCACHED_POSITIVE, Optional.of(entry.get().getValue())); } else { - return CheckResults.create(UNCACHED_NEGATIVE, Optional.absent()); + return CheckResults.create(UNCACHED_NEGATIVE, Optional.empty()); } } catch (InvalidCacheLoadException | ExecutionException e) { throw new RuntimeException("Could not load premium list entry " + entryKey, e); @@ -173,7 +173,7 @@ public final class PremiumListUtils { .id(premiumList.getName()) .now(); checkState( - Objects.equals(existing, oldPremiumList.orNull()), + Objects.equals(existing, oldPremiumList.orElse(null)), "PremiumList was concurrently edited"); PremiumList newList = premiumList.asBuilder() .setLastUpdateTime(now) diff --git a/java/google/registry/model/registry/label/ReservedList.java b/java/google/registry/model/registry/label/ReservedList.java index 201e9bf7f..801d34026 100644 --- a/java/google/registry/model/registry/label/ReservedList.java +++ b/java/google/registry/model/registry/label/ReservedList.java @@ -30,7 +30,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.joda.time.DateTimeZone.UTC; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -49,6 +48,7 @@ import google.registry.model.registry.label.DomainLabelMetrics.MetricsReservedLi import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; @@ -338,7 +338,7 @@ public final class ReservedList */ public Optional getReservationInList(String label) { ReservedListEntry entry = getReservedListEntries().get(label); - return Optional.fromNullable(entry == null ? null : entry.reservationType); + return Optional.ofNullable(entry == null ? null : entry.reservationType); } @Override diff --git a/java/google/registry/model/server/Lock.java b/java/google/registry/model/server/Lock.java index a294f658f..f7e9b6e21 100644 --- a/java/google/registry/model/server/Lock.java +++ b/java/google/registry/model/server/Lock.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.isAtOrAfter; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.googlecode.objectify.VoidWork; import com.googlecode.objectify.Work; @@ -30,6 +29,7 @@ import google.registry.model.annotations.NotBackedUp.Reason; import google.registry.util.FormattingLogger; import google.registry.util.RequestStatusChecker; import google.registry.util.RequestStatusCheckerImpl; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.time.DateTime; import org.joda.time.Duration; @@ -99,7 +99,7 @@ public class Lock extends ImmutableObject { // It's important to use transactNew rather than transact, because a Lock can be used to control // access to resources like GCS that can't be transactionally rolled back. Therefore, the lock // must be definitively acquired before it is used, even when called inside another transaction. - return Optional.fromNullable(ofy().transactNew(new Work() { + return Optional.ofNullable(ofy().transactNew(new Work() { @Override public Lock run() { String lockId = makeLockId(resourceName, tld); diff --git a/java/google/registry/module/backend/BackendModule.java b/java/google/registry/module/backend/BackendModule.java index 57e2ee416..c617c7d86 100644 --- a/java/google/registry/module/backend/BackendModule.java +++ b/java/google/registry/module/backend/BackendModule.java @@ -20,13 +20,13 @@ import static google.registry.request.RequestParameters.extractOptionalDatetimeP import static google.registry.request.RequestParameters.extractRequiredParameter; import static google.registry.request.RequestParameters.extractSetOfParameters; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import dagger.Module; import dagger.Provides; import google.registry.batch.ExpandRecurringBillingEventsAction; import google.registry.request.Parameter; import google.registry.request.RequestParameters; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; diff --git a/java/google/registry/monitoring/metrics/MetricExporter.java b/java/google/registry/monitoring/metrics/MetricExporter.java index a8f596504..7a714a9c4 100644 --- a/java/google/registry/monitoring/metrics/MetricExporter.java +++ b/java/google/registry/monitoring/metrics/MetricExporter.java @@ -16,10 +16,10 @@ package google.registry.monitoring.metrics; import static com.google.common.util.concurrent.MoreExecutors.directExecutor; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.AbstractExecutionThreadService; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; diff --git a/java/google/registry/monitoring/metrics/MetricReporter.java b/java/google/registry/monitoring/metrics/MetricReporter.java index df414a3cc..dd9d2f050 100644 --- a/java/google/registry/monitoring/metrics/MetricReporter.java +++ b/java/google/registry/monitoring/metrics/MetricReporter.java @@ -18,9 +18,9 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.AbstractScheduledService; +import java.util.Optional; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executors; @@ -117,7 +117,7 @@ public class MetricReporter extends AbstractScheduledService { runOneIteration(); // Offer a poision pill to inform the exporter to stop. - writeQueue.offer(Optional.>>absent()); + writeQueue.offer(Optional.>>empty()); try { metricExporter.awaitTerminated(10, TimeUnit.SECONDS); logger.info("Shut down MetricExporter"); diff --git a/java/google/registry/monitoring/metrics/contrib/BUILD b/java/google/registry/monitoring/metrics/contrib/BUILD index 14d60a8b5..0a10857cd 100644 --- a/java/google/registry/monitoring/metrics/contrib/BUILD +++ b/java/google/registry/monitoring/metrics/contrib/BUILD @@ -10,8 +10,9 @@ java_library( srcs = glob(["*.java"]), deps = [ "//java/google/registry/monitoring/metrics", - "//third_party/java/truth", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", ], ) diff --git a/java/google/registry/monitoring/whitebox/EppMetric.java b/java/google/registry/monitoring/whitebox/EppMetric.java index d3415268e..a2472bf23 100644 --- a/java/google/registry/monitoring/whitebox/EppMetric.java +++ b/java/google/registry/monitoring/whitebox/EppMetric.java @@ -19,7 +19,6 @@ import static google.registry.bigquery.BigqueryUtils.toBigqueryTimestamp; import com.google.api.services.bigquery.model.TableFieldSchema; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -28,6 +27,7 @@ import google.registry.bigquery.BigqueryUtils.FieldType; import google.registry.model.eppoutput.Result.Code; import google.registry.model.registry.Registries; import google.registry.util.Clock; +import java.util.Optional; import org.joda.time.DateTime; /** @@ -178,13 +178,13 @@ public abstract class EppMetric implements BigQueryMetric { public Builder setTlds(ImmutableSet tlds) { switch (tlds.size()) { case 0: - setTld(Optional.absent()); + setTld(Optional.empty()); break; case 1: String tld = Iterables.getOnlyElement(tlds); // Only record TLDs that actually exist, otherwise we can blow up cardinality by recording // an arbitrarily large number of strings. - setTld(Optional.fromNullable(Registries.getTlds().contains(tld) ? tld : "_invalid")); + setTld(Optional.ofNullable(Registries.getTlds().contains(tld) ? tld : "_invalid")); break; default: setTld("_various"); diff --git a/java/google/registry/pricing/PricingEngineProxy.java b/java/google/registry/pricing/PricingEngineProxy.java index c5e75f305..90170e63a 100644 --- a/java/google/registry/pricing/PricingEngineProxy.java +++ b/java/google/registry/pricing/PricingEngineProxy.java @@ -18,11 +18,11 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static google.registry.util.DomainNameUtils.getTldFromDomainName; -import com.google.common.base.Optional; import google.registry.model.pricing.PremiumPricingEngine; import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; import google.registry.model.registry.Registry; import java.util.Map; +import java.util.Optional; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/java/google/registry/rdap/RdapActionBase.java b/java/google/registry/rdap/RdapActionBase.java index 52ece11ed..22360071c 100644 --- a/java/google/registry/rdap/RdapActionBase.java +++ b/java/google/registry/rdap/RdapActionBase.java @@ -26,7 +26,6 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_OK; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.net.InternetDomainName; import com.google.common.net.MediaType; @@ -54,6 +53,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -196,7 +196,7 @@ public abstract class RdapActionBase implements Runnable { */ boolean shouldIncludeDeleted() { // If includeDeleted is not specified, or set to false, we don't need to go any further. - if (!includeDeletedParam.or(false)) { + if (!includeDeletedParam.orElse(false)) { return false; } if (!authResult.userAuthInfo().isPresent()) { diff --git a/java/google/registry/rdap/RdapDomainSearchAction.java b/java/google/registry/rdap/RdapDomainSearchAction.java index e9f016510..78b0febe1 100644 --- a/java/google/registry/rdap/RdapDomainSearchAction.java +++ b/java/google/registry/rdap/RdapDomainSearchAction.java @@ -21,7 +21,6 @@ import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.HEAD; import static google.registry.util.DateTimeUtils.END_OF_TIME; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; @@ -48,6 +47,7 @@ import java.net.InetAddress; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/rdap/RdapEntityAction.java b/java/google/registry/rdap/RdapEntityAction.java index 5e8615b90..0ab3b67fa 100644 --- a/java/google/registry/rdap/RdapEntityAction.java +++ b/java/google/registry/rdap/RdapEntityAction.java @@ -19,7 +19,6 @@ import static google.registry.rdap.RdapUtils.getRegistrarByIanaIdentifier; import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.HEAD; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Longs; import com.google.re2j.Pattern; @@ -33,6 +32,7 @@ import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NotFoundException; import google.registry.request.auth.Auth; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -89,7 +89,7 @@ public class RdapEntityAction extends RdapActionBase { return rdapJsonFormatter.makeRdapJsonForContact( contactResource, true, - Optional.absent(), + Optional.empty(), rdapLinkBase, rdapWhoisServer, now, diff --git a/java/google/registry/rdap/RdapEntitySearchAction.java b/java/google/registry/rdap/RdapEntitySearchAction.java index 57d5f9a1d..f293dab87 100644 --- a/java/google/registry/rdap/RdapEntitySearchAction.java +++ b/java/google/registry/rdap/RdapEntitySearchAction.java @@ -20,7 +20,6 @@ import static google.registry.rdap.RdapUtils.getRegistrarByIanaIdentifier; import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.HEAD; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; @@ -42,6 +41,7 @@ import google.registry.request.auth.Auth; import google.registry.util.Clock; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -298,7 +298,7 @@ public class RdapEntitySearchAction extends RdapActionBase { jsonOutputList.add(rdapJsonFormatter.makeRdapJsonForContact( contact, false, - Optional.absent(), + Optional.empty(), rdapLinkBase, rdapWhoisServer, now, diff --git a/java/google/registry/rdap/RdapJsonFormatter.java b/java/google/registry/rdap/RdapJsonFormatter.java index 88a16a68a..1060c68e2 100644 --- a/java/google/registry/rdap/RdapJsonFormatter.java +++ b/java/google/registry/rdap/RdapJsonFormatter.java @@ -22,7 +22,6 @@ import static google.registry.util.CollectionUtils.union; import static google.registry.util.DomainNameUtils.ACE_PREFIX; import com.google.common.base.Functions; -import com.google.common.base.Optional; import com.google.common.base.Predicates; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; @@ -60,6 +59,7 @@ import java.net.URI; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/java/google/registry/rdap/RdapModule.java b/java/google/registry/rdap/RdapModule.java index 870173377..3527f7bf6 100644 --- a/java/google/registry/rdap/RdapModule.java +++ b/java/google/registry/rdap/RdapModule.java @@ -14,12 +14,12 @@ package google.registry.rdap; -import com.google.common.base.Optional; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; import google.registry.request.RequestParameters; import java.net.InetAddress; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** Dagger module for the RDAP package. */ diff --git a/java/google/registry/rdap/RdapNameserverSearchAction.java b/java/google/registry/rdap/RdapNameserverSearchAction.java index a347d0d72..ea26679bc 100644 --- a/java/google/registry/rdap/RdapNameserverSearchAction.java +++ b/java/google/registry/rdap/RdapNameserverSearchAction.java @@ -18,7 +18,6 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.HEAD; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; @@ -41,6 +40,7 @@ import google.registry.util.Idn; import java.net.InetAddress; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/rdap/RdapUtils.java b/java/google/registry/rdap/RdapUtils.java index 3b057e1e2..10a9ff271 100644 --- a/java/google/registry/rdap/RdapUtils.java +++ b/java/google/registry/rdap/RdapUtils.java @@ -14,10 +14,10 @@ package google.registry.rdap; -import static com.google.common.collect.Iterables.tryFind; - -import com.google.common.base.Optional; +import com.google.common.collect.Streams; import google.registry.model.registrar.Registrar; +import java.util.Objects; +import java.util.Optional; /** Utility functions for RDAP. */ public final class RdapUtils { @@ -26,11 +26,8 @@ public final class RdapUtils { /** Looks up a registrar by its IANA identifier. */ static Optional getRegistrarByIanaIdentifier(final long ianaIdentifier) { - return tryFind( - Registrar.loadAllCached(), - registrar -> { - Long registrarIanaIdentifier = registrar.getIanaIdentifier(); - return (registrarIanaIdentifier != null) && (registrarIanaIdentifier == ianaIdentifier); - }); + return Streams.stream(Registrar.loadAllCached()) + .filter(registrar -> Objects.equals(ianaIdentifier, registrar.getIanaIdentifier())) + .findFirst(); } } diff --git a/java/google/registry/rde/JSchSshSession.java b/java/google/registry/rde/JSchSshSession.java index 339e33289..b48a6a332 100644 --- a/java/google/registry/rde/JSchSshSession.java +++ b/java/google/registry/rde/JSchSshSession.java @@ -62,7 +62,7 @@ final class JSchSshSession implements Closeable { RdeUploadUrl url = RdeUploadUrl.create(uri); logger.info("Connecting to SSH endpoint: " + url); Session session = jsch.getSession( - url.getUser().or("domain-registry"), + url.getUser().orElse("domain-registry"), url.getHost(), url.getPort()); if (url.getPass().isPresent()) { diff --git a/java/google/registry/rde/PendingDeposit.java b/java/google/registry/rde/PendingDeposit.java index b0b0f23db..2b46da4ef 100644 --- a/java/google/registry/rde/PendingDeposit.java +++ b/java/google/registry/rde/PendingDeposit.java @@ -15,14 +15,19 @@ package google.registry.rde; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeMode; import java.io.Serializable; +import java.util.Optional; +import javax.annotation.Nullable; import org.joda.time.DateTime; import org.joda.time.Duration; -/** Container representing a single RDE or BRDA XML escrow deposit that needs to be created. */ +/** + * Container representing a single RDE or BRDA XML escrow deposit that needs to be created. + * + *

There are some {@code @Nullable} fields here because Optionals aren't Serializable. + */ @AutoValue public abstract class PendingDeposit implements Serializable { @@ -44,22 +49,26 @@ public abstract class PendingDeposit implements Serializable { public abstract RdeMode mode(); /** The cursor type to update (not used in manual operation). */ - public abstract Optional cursor(); + @Nullable + public abstract CursorType cursor(); /** Amount of time to increment the cursor (not used in manual operation). */ - public abstract Optional interval(); + @Nullable + public abstract Duration interval(); /** * Subdirectory of bucket/manual in which files should be placed, including a trailing slash (used * only in manual operation). */ - public abstract Optional directoryWithTrailingSlash(); + @Nullable + public abstract String directoryWithTrailingSlash(); /** * Revision number for generated files; if absent, use the next available in the sequence (used * only in manual operation). */ - public abstract Optional revision(); + @Nullable + public abstract Integer revision(); static PendingDeposit create( String tld, DateTime watermark, RdeMode mode, CursorType cursor, Duration interval) { @@ -68,10 +77,10 @@ public abstract class PendingDeposit implements Serializable { tld, watermark, mode, - Optional.of(cursor), - Optional.of(interval), - Optional.absent(), - Optional.absent()); + cursor, + interval, + null, + null); } static PendingDeposit createInManualOperation( @@ -79,15 +88,15 @@ public abstract class PendingDeposit implements Serializable { DateTime watermark, RdeMode mode, String directoryWithTrailingSlash, - Optional revision) { + @Nullable Integer revision) { return new AutoValue_PendingDeposit( true, tld, watermark, mode, - Optional.absent(), - Optional.absent(), - Optional.of(directoryWithTrailingSlash), + null, + null, + directoryWithTrailingSlash, revision); } diff --git a/java/google/registry/rde/RdeModule.java b/java/google/registry/rde/RdeModule.java index 84591e0b5..ac22b7f12 100644 --- a/java/google/registry/rde/RdeModule.java +++ b/java/google/registry/rde/RdeModule.java @@ -23,11 +23,11 @@ import static google.registry.request.RequestParameters.extractSetOfDatetimePara import static google.registry.request.RequestParameters.extractSetOfParameters; import com.google.appengine.api.taskqueue.Queue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; +import java.util.Optional; import javax.inject.Named; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; diff --git a/java/google/registry/rde/RdeStagingAction.java b/java/google/registry/rde/RdeStagingAction.java index 7061a6219..85c15d929 100644 --- a/java/google/registry/rde/RdeStagingAction.java +++ b/java/google/registry/rde/RdeStagingAction.java @@ -22,7 +22,6 @@ import static google.registry.xml.ValidationMode.STRICT; import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; @@ -47,6 +46,7 @@ import google.registry.request.Response; import google.registry.request.auth.Auth; import google.registry.util.Clock; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; import org.joda.time.Duration; @@ -328,7 +328,7 @@ public final class RdeStagingAction implements Runnable { watermark, mode, directoryWithTrailingSlash, - revision)); + revision.orElse(null))); } } } diff --git a/java/google/registry/rde/RdeStagingMapper.java b/java/google/registry/rde/RdeStagingMapper.java index b04f3ac6f..8e9b41316 100644 --- a/java/google/registry/rde/RdeStagingMapper.java +++ b/java/google/registry/rde/RdeStagingMapper.java @@ -21,7 +21,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import com.google.appengine.tools.mapreduce.Mapper; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; @@ -37,6 +36,7 @@ import google.registry.model.registrar.Registrar; import google.registry.xml.ValidationMode; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import org.joda.time.DateTime; /** Mapper for {@link RdeStagingAction}. */ @@ -119,10 +119,9 @@ public final class RdeStagingMapper extends Mapper emit(pending, fragment)); } } @@ -146,7 +145,7 @@ public final class RdeStagingMapper extends Mapper { public Optional getUser() { String userInfo = uri.getUserInfo(); if (isNullOrEmpty(userInfo)) { - return Optional.absent(); + return Optional.empty(); } int idx = userInfo.indexOf(':'); if (idx != -1) { @@ -83,13 +83,13 @@ final class RdeUploadUrl implements Comparable { public Optional getPass() { String userInfo = uri.getUserInfo(); if (isNullOrEmpty(userInfo)) { - return Optional.absent(); + return Optional.empty(); } int idx = userInfo.indexOf(':'); if (idx != -1) { return Optional.of(userInfo.substring(idx + 1)); } else { - return Optional.absent(); + return Optional.empty(); } } @@ -112,7 +112,7 @@ final class RdeUploadUrl implements Comparable { public Optional getPath() { String path = uri.getPath(); if (isNullOrEmpty(path) || path.equals("/")) { - return Optional.absent(); + return Optional.empty(); } else { return Optional.of(path.substring(1)); } @@ -134,7 +134,7 @@ final class RdeUploadUrl implements Comparable { result += String.format(":%d", getPort()); } result += "/"; - result += getPath().or(""); + result += getPath().orElse(""); return result; } diff --git a/java/google/registry/rde/imports/RdeContactImportAction.java b/java/google/registry/rde/imports/RdeContactImportAction.java index 7b4b56d24..c977dfb7e 100644 --- a/java/google/registry/rde/imports/RdeContactImportAction.java +++ b/java/google/registry/rde/imports/RdeContactImportAction.java @@ -22,7 +22,6 @@ import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Mapper; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.VoidWork; import google.registry.config.RegistryConfig.Config; @@ -39,6 +38,7 @@ import google.registry.util.SystemClock; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdecontact.XjcRdeContact; import google.registry.xjc.rdecontact.XjcRdeContactElement; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/rde/imports/RdeContactInput.java b/java/google/registry/rde/imports/RdeContactInput.java index 3e974dcf9..6ac2144e0 100644 --- a/java/google/registry/rde/imports/RdeContactInput.java +++ b/java/google/registry/rde/imports/RdeContactInput.java @@ -24,7 +24,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Input; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; @@ -35,6 +34,7 @@ import google.registry.xjc.rdecontact.XjcRdeContactElement; import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.Optional; /** * A MapReduce {@link Input} that imports {@link ContactResource} objects from an escrow file. @@ -68,7 +68,7 @@ public class RdeContactInput extends Input> { public RdeContactInput(Optional mapShards, String importBucketName, String importFileName) { - this.numReaders = mapShards.or(DEFAULT_READERS); + this.numReaders = mapShards.orElse(DEFAULT_READERS); this.importBucketName = importBucketName; this.importFileName = importFileName; } diff --git a/java/google/registry/rde/imports/RdeDomainImportAction.java b/java/google/registry/rde/imports/RdeDomainImportAction.java index c53102824..004ad1261 100644 --- a/java/google/registry/rde/imports/RdeDomainImportAction.java +++ b/java/google/registry/rde/imports/RdeDomainImportAction.java @@ -32,7 +32,6 @@ import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Mapper; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.VoidWork; @@ -60,6 +59,7 @@ import google.registry.util.SystemClock; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdedomain.XjcRdeDomain; import google.registry.xjc.rdedomain.XjcRdeDomainElement; +import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/java/google/registry/rde/imports/RdeDomainInput.java b/java/google/registry/rde/imports/RdeDomainInput.java index bc49145aa..f97d50d93 100644 --- a/java/google/registry/rde/imports/RdeDomainInput.java +++ b/java/google/registry/rde/imports/RdeDomainInput.java @@ -24,7 +24,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Input; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; @@ -35,6 +34,7 @@ import google.registry.xjc.rdedomain.XjcRdeDomainElement; import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.Optional; /** * A MapReduce {@link Input} that imports {@link DomainResource} objects from an escrow file. @@ -68,7 +68,7 @@ public class RdeDomainInput extends Input> { public RdeDomainInput( Optional mapShards, String importBucketName, String importFileName) { - this.numReaders = mapShards.or(DEFAULT_READERS); + this.numReaders = mapShards.orElse(DEFAULT_READERS); this.importBucketName = importBucketName; this.importFileName = importFileName; } diff --git a/java/google/registry/rde/imports/RdeHostImportAction.java b/java/google/registry/rde/imports/RdeHostImportAction.java index d3b07f978..79353f440 100644 --- a/java/google/registry/rde/imports/RdeHostImportAction.java +++ b/java/google/registry/rde/imports/RdeHostImportAction.java @@ -22,7 +22,6 @@ import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Mapper; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.VoidWork; import google.registry.config.RegistryConfig.Config; @@ -39,6 +38,7 @@ import google.registry.util.SystemClock; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdehost.XjcRdeHost; import google.registry.xjc.rdehost.XjcRdeHostElement; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/rde/imports/RdeHostInput.java b/java/google/registry/rde/imports/RdeHostInput.java index 4b080c99b..9d4dd7955 100644 --- a/java/google/registry/rde/imports/RdeHostInput.java +++ b/java/google/registry/rde/imports/RdeHostInput.java @@ -22,7 +22,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.mapreduce.Input; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; @@ -33,6 +32,7 @@ import google.registry.xjc.rdehost.XjcRdeHostElement; import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.Optional; /** * A MapReduce {@link Input} that imports {@link HostResource} objects from an escrow file. @@ -67,7 +67,7 @@ public class RdeHostInput extends Input> { public RdeHostInput(Optional mapShards, String importBucketName, String importFileName) { - this.numReaders = mapShards.or(DEFAULT_READERS); + this.numReaders = mapShards.orElse(DEFAULT_READERS); checkArgument(numReaders > 0, "Number of shards must be greater than zero"); this.importBucketName = importBucketName; this.importFileName = importFileName; diff --git a/java/google/registry/rde/imports/RdeHostLinkAction.java b/java/google/registry/rde/imports/RdeHostLinkAction.java index 3ea717b55..23204340f 100644 --- a/java/google/registry/rde/imports/RdeHostLinkAction.java +++ b/java/google/registry/rde/imports/RdeHostLinkAction.java @@ -23,7 +23,6 @@ import static google.registry.util.PipelineUtils.createJobPath; import static java.util.stream.Collectors.joining; import com.google.appengine.tools.mapreduce.Mapper; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.InternetDomainName; import com.googlecode.objectify.Key; @@ -43,6 +42,7 @@ import google.registry.util.FormattingLogger; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdehost.XjcRdeHost; import google.registry.xjc.rdehost.XjcRdeHostElement; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -191,7 +191,7 @@ public class RdeHostLinkAction implements Runnable { Optional tld = findTldForName(hostName); // out of zone hosts cannot be linked if (!tld.isPresent()) { - return Optional.absent(); + return Optional.empty(); } // This is a subordinate host String domainName = diff --git a/java/google/registry/rde/imports/RdeParser.java b/java/google/registry/rde/imports/RdeParser.java index 8ef74afb5..0f9698fd8 100644 --- a/java/google/registry/rde/imports/RdeParser.java +++ b/java/google/registry/rde/imports/RdeParser.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import google.registry.xjc.rdecontact.XjcRdeContact; import google.registry.xjc.rdecontact.XjcRdeContactElement; @@ -41,6 +40,7 @@ import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Optional; import javax.annotation.concurrent.NotThreadSafe; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -116,31 +116,31 @@ public class RdeParser implements Closeable { } public Long getDomainCount() { - return Optional.fromNullable(counts.get(RDE_DOMAIN_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_DOMAIN_URI)).orElse(0L); } public Long getHostCount() { - return Optional.fromNullable(counts.get(RDE_HOST_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_HOST_URI)).orElse(0L); } public Long getContactCount() { - return Optional.fromNullable(counts.get(RDE_CONTACT_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_CONTACT_URI)).orElse(0L); } public Long getRegistrarCount() { - return Optional.fromNullable(counts.get(RDE_REGISTRAR_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_REGISTRAR_URI)).orElse(0L); } public Long getIdnCount() { - return Optional.fromNullable(counts.get(RDE_IDN_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_IDN_URI)).orElse(0L); } public Long getNndnCount() { - return Optional.fromNullable(counts.get(RDE_NNDN_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_NNDN_URI)).orElse(0L); } public Long getEppParamsCount() { - return Optional.fromNullable(counts.get(RDE_EPP_PARAMS_URI)).or(0L); + return Optional.ofNullable(counts.get(RDE_EPP_PARAMS_URI)).orElse(0L); } private RdeHeader(XjcRdeHeader header) { diff --git a/java/google/registry/reporting/IcannReportingModule.java b/java/google/registry/reporting/IcannReportingModule.java index d09e3c207..8ee0c6ca0 100644 --- a/java/google/registry/reporting/IcannReportingModule.java +++ b/java/google/registry/reporting/IcannReportingModule.java @@ -21,12 +21,12 @@ import static google.registry.request.RequestParameters.extractRequiredParameter import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.http.HttpTransport; import com.google.api.client.json.jackson2.JacksonFactory; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import dagger.Module; import dagger.Provides; import google.registry.bigquery.BigqueryConnection; import google.registry.request.Parameter; +import java.util.Optional; import java.util.concurrent.Executors; import javax.servlet.http.HttpServletRequest; import org.joda.time.Duration; diff --git a/java/google/registry/reporting/IcannReportingStagingAction.java b/java/google/registry/reporting/IcannReportingStagingAction.java index d4516088e..d5de89a19 100644 --- a/java/google/registry/reporting/IcannReportingStagingAction.java +++ b/java/google/registry/reporting/IcannReportingStagingAction.java @@ -22,7 +22,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import com.google.api.services.bigquery.model.TableFieldSchema; import com.google.appengine.tools.cloudstorage.GcsFilename; -import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableCollection; @@ -50,6 +49,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.concurrent.ExecutionException; import javax.inject.Inject; diff --git a/java/google/registry/reporting/IcannReportingUploadAction.java b/java/google/registry/reporting/IcannReportingUploadAction.java index 0136545a8..417d89b43 100644 --- a/java/google/registry/reporting/IcannReportingUploadAction.java +++ b/java/google/registry/reporting/IcannReportingUploadAction.java @@ -20,7 +20,6 @@ import static google.registry.model.registry.Registries.assertTldExists; import static google.registry.request.Action.Method.POST; import com.google.appengine.tools.cloudstorage.GcsFilename; -import com.google.common.base.Optional; import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.Config; import google.registry.gcs.GcsUtils; @@ -35,6 +34,7 @@ import google.registry.util.Retrier; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/repositories.bzl b/java/google/registry/repositories.bzl index 9d15385a9..38c58c77b 100644 --- a/java/google/registry/repositories.bzl +++ b/java/google/registry/repositories.bzl @@ -72,6 +72,7 @@ def domain_registry_repositories( omit_com_google_re2j=False, omit_com_google_template_soy=False, omit_com_google_truth=False, + omit_com_google_truth_extensions_truth_java8_extension=False, omit_com_googlecode_charts4j=False, omit_com_googlecode_json_simple=False, omit_com_ibm_icu_icu4j=False, @@ -212,6 +213,8 @@ def domain_registry_repositories( com_google_template_soy() if not omit_com_google_truth: com_google_truth() + if not omit_com_google_truth_extensions_truth_java8_extension: + com_google_truth_extensions_truth_java8_extension() if not omit_com_googlecode_charts4j: com_googlecode_charts4j() if not omit_com_googlecode_json_simple: @@ -1166,6 +1169,21 @@ def com_google_truth(): ], ) +def com_google_truth_extensions_truth_java8_extension(): + java_import_external( + name = "com_google_truth_extensions_truth_java8_extension", + jar_sha256 = "44566c46783296856c80b14fc3b324d0616c192fa0090214b0eaf1b0b5697266", + jar_urls = [ + "http://central.maven.org/maven2/com/google/truth/extensions/truth-java8-extension/0.36/truth-java8-extension-0.36.jar", + ], + licenses = ["notice"], # The Apache Software License, Version 2.0 + testonly_ = True, + deps = [ + "@com_google_truth", + "@com_google_errorprone_error_prone_annotations", + ], + ) + def com_googlecode_charts4j(): java_import_external( name = "com_googlecode_charts4j", diff --git a/java/google/registry/request/RequestHandler.java b/java/google/registry/request/RequestHandler.java index 6b8d40173..1d2b8918d 100644 --- a/java/google/registry/request/RequestHandler.java +++ b/java/google/registry/request/RequestHandler.java @@ -20,12 +20,12 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; import static javax.servlet.http.HttpServletResponse.SC_METHOD_NOT_ALLOWED; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; -import com.google.common.base.Optional; import google.registry.request.auth.AuthResult; import google.registry.request.auth.RequestAuthenticator; import google.registry.util.FormattingLogger; import google.registry.util.TypeUtils.TypeInstantiator; import java.io.IOException; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Provider; import javax.servlet.http.HttpServletRequest; diff --git a/java/google/registry/request/RequestParameters.java b/java/google/registry/request/RequestParameters.java index f4d85ac44..8f6e4d28c 100644 --- a/java/google/registry/request/RequestParameters.java +++ b/java/google/registry/request/RequestParameters.java @@ -19,11 +19,11 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.nullToEmpty; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import google.registry.request.HttpException.BadRequestException; import java.net.InetAddress; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -60,7 +60,7 @@ public final class RequestParameters { /** Returns the first GET or POST parameter associated with {@code name}. */ public static Optional extractOptionalParameter(HttpServletRequest req, String name) { - return Optional.fromNullable(emptyToNull(req.getParameter(name))); + return Optional.ofNullable(emptyToNull(req.getParameter(name))); } /** @@ -72,7 +72,7 @@ public final class RequestParameters { String stringParam = req.getParameter(name); try { return isNullOrEmpty(stringParam) - ? Optional.absent() + ? Optional.empty() : Optional.of(Integer.valueOf(stringParam)); } catch (NumberFormatException e) { throw new BadRequestException("Expected integer: " + name); @@ -123,7 +123,7 @@ public final class RequestParameters { HttpServletRequest req, String name) { String stringParam = req.getParameter(name); return isNullOrEmpty(stringParam) - ? Optional.absent() + ? Optional.empty() : Optional.of(Boolean.valueOf(stringParam)); } @@ -167,7 +167,7 @@ public final class RequestParameters { String stringParam = req.getParameter(name); try { return isNullOrEmpty(stringParam) - ? Optional.absent() + ? Optional.empty() : Optional.of(DateTime.parse(stringParam)); } catch (IllegalArgumentException e) { throw new BadRequestException("Bad ISO 8601 timestamp: " + name); @@ -212,7 +212,7 @@ public final class RequestParameters { HttpServletRequest req, String name) { Optional paramVal = extractOptionalParameter(req, name); if (!paramVal.isPresent()) { - return Optional.absent(); + return Optional.empty(); } try { return Optional.of(InetAddresses.forString(paramVal.get())); @@ -245,7 +245,7 @@ public final class RequestParameters { * @param name case insensitive header name */ public static Optional extractOptionalHeader(HttpServletRequest req, String name) { - return Optional.fromNullable(req.getHeader(name)); + return Optional.ofNullable(req.getHeader(name)); } private RequestParameters() {} diff --git a/java/google/registry/request/Router.java b/java/google/registry/request/Router.java index 4c05fd5a1..d4bdc8ec6 100644 --- a/java/google/registry/request/Router.java +++ b/java/google/registry/request/Router.java @@ -18,12 +18,12 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Throwables.throwIfUnchecked; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Ordering; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; +import java.util.Optional; import java.util.TreeMap; /** @@ -62,7 +62,7 @@ final class Router { return Optional.of(floor.getValue()); } } - return Optional.absent(); + return Optional.empty(); } static ImmutableSortedMap extractRoutesFromComponent(Class componentClass) { diff --git a/java/google/registry/request/auth/AuthResult.java b/java/google/registry/request/auth/AuthResult.java index 925dd09f8..c9e0ac4ec 100644 --- a/java/google/registry/request/auth/AuthResult.java +++ b/java/google/registry/request/auth/AuthResult.java @@ -17,7 +17,7 @@ package google.registry.request.auth; import static com.google.common.base.Preconditions.checkNotNull; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; +import java.util.Optional; import javax.annotation.Nullable; /** @@ -37,14 +37,14 @@ public abstract class AuthResult { } public static AuthResult create(AuthLevel authLevel) { - return new AutoValue_AuthResult(authLevel, Optional.absent()); + return new AutoValue_AuthResult(authLevel, Optional.empty()); } public static AuthResult create(AuthLevel authLevel, @Nullable UserAuthInfo userAuthInfo) { if (authLevel == AuthLevel.USER) { checkNotNull(userAuthInfo); } - return new AutoValue_AuthResult(authLevel, Optional.fromNullable(userAuthInfo)); + return new AutoValue_AuthResult(authLevel, Optional.ofNullable(userAuthInfo)); } /** diff --git a/java/google/registry/request/auth/RequestAuthenticator.java b/java/google/registry/request/auth/RequestAuthenticator.java index 1245496c3..3d3596b4c 100644 --- a/java/google/registry/request/auth/RequestAuthenticator.java +++ b/java/google/registry/request/auth/RequestAuthenticator.java @@ -18,11 +18,11 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.auto.value.AutoValue; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.Ordering; import com.google.errorprone.annotations.Immutable; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -117,14 +117,14 @@ public class RequestAuthenticator { case APP: if (!authResult.isAuthenticated()) { logger.warning("Not authorized; no authentication found"); - return Optional.absent(); + return Optional.empty(); } break; case USER: if (authResult.authLevel() != AuthLevel.USER) { logger.warning("Not authorized; no authenticated user"); // TODO(mountford): change this so that the caller knows to return a more helpful error - return Optional.absent(); + return Optional.empty(); } break; } @@ -132,7 +132,7 @@ public class RequestAuthenticator { case IGNORED: if (authResult.authLevel() == AuthLevel.USER) { logger.warning("Not authorized; user policy is IGNORED, but a user was found"); - return Optional.absent(); + return Optional.empty(); } break; case PUBLIC: @@ -142,7 +142,7 @@ public class RequestAuthenticator { if (authResult.userAuthInfo().isPresent() && !authResult.userAuthInfo().get().isUserAdmin()) { logger.warning("Not authorized; user policy is ADMIN, but the user was not an admin"); - return Optional.absent(); + return Optional.empty(); } break; } diff --git a/java/google/registry/request/auth/UserAuthInfo.java b/java/google/registry/request/auth/UserAuthInfo.java index d171ec4de..1b160466a 100644 --- a/java/google/registry/request/auth/UserAuthInfo.java +++ b/java/google/registry/request/auth/UserAuthInfo.java @@ -16,7 +16,7 @@ package google.registry.request.auth; import com.google.appengine.api.users.User; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; +import java.util.Optional; /** Extra information provided by the authentication mechanism about the user. */ @AutoValue @@ -39,7 +39,7 @@ public abstract class UserAuthInfo { public static UserAuthInfo create( User user, boolean isUserAdmin) { - return new AutoValue_UserAuthInfo(user, isUserAdmin, Optional.absent()); + return new AutoValue_UserAuthInfo(user, isUserAdmin, Optional.empty()); } public static UserAuthInfo create( diff --git a/java/google/registry/request/lock/LockHandlerImpl.java b/java/google/registry/request/lock/LockHandlerImpl.java index 6b5712512..df45f4fc4 100644 --- a/java/google/registry/request/lock/LockHandlerImpl.java +++ b/java/google/registry/request/lock/LockHandlerImpl.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Throwables.throwIfUnchecked; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSortedSet; import com.google.common.util.concurrent.UncheckedExecutionException; @@ -27,6 +26,7 @@ import google.registry.util.AppEngineTimeLimiter; import google.registry.util.FormattingLogger; import google.registry.util.RequestStatusChecker; import java.util.HashSet; +import java.util.Optional; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; diff --git a/java/google/registry/tldconfig/idn/IdnLabelValidator.java b/java/google/registry/tldconfig/idn/IdnLabelValidator.java index d21d16e54..2c9d842bd 100644 --- a/java/google/registry/tldconfig/idn/IdnLabelValidator.java +++ b/java/google/registry/tldconfig/idn/IdnLabelValidator.java @@ -17,11 +17,11 @@ package google.registry.tldconfig.idn; import static google.registry.tldconfig.idn.IdnTableEnum.EXTENDED_LATIN; import static google.registry.tldconfig.idn.IdnTableEnum.JA; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import google.registry.util.Idn; import google.registry.util.NonFinalForTesting; +import java.util.Optional; /** Validates whether a given IDN label can be provisioned for a particular TLD. */ public final class IdnLabelValidator { @@ -44,12 +44,12 @@ public final class IdnLabelValidator { public static Optional findValidIdnTableForTld(String label, String tld) { String unicodeString = Idn.toUnicode(label); for (IdnTableEnum idnTable - : Optional.fromNullable(idnTableListsPerTld.get(tld)).or(DEFAULT_IDN_TABLES)) { + : Optional.ofNullable(idnTableListsPerTld.get(tld)).orElse(DEFAULT_IDN_TABLES)) { if (idnTable.getTable().isValidLabel(unicodeString)) { return Optional.of(idnTable.getTable().getName()); } } - return Optional.absent(); + return Optional.empty(); } private IdnLabelValidator() {} diff --git a/java/google/registry/tldconfig/idn/IdnTable.java b/java/google/registry/tldconfig/idn/IdnTable.java index aec0f5ea6..e8df114b3 100644 --- a/java/google/registry/tldconfig/idn/IdnTable.java +++ b/java/google/registry/tldconfig/idn/IdnTable.java @@ -17,13 +17,13 @@ package google.registry.tldconfig.idn; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableRangeSet; import com.google.common.collect.Range; import com.google.common.collect.RangeSet; import com.google.re2j.Matcher; import com.google.re2j.Pattern; import java.net.URI; +import java.util.Optional; /** An IDN table for a particular TLD. */ public final class IdnTable { diff --git a/java/google/registry/tldconfig/idn/LanguageValidator.java b/java/google/registry/tldconfig/idn/LanguageValidator.java index 24d1e484b..af3608f32 100644 --- a/java/google/registry/tldconfig/idn/LanguageValidator.java +++ b/java/google/registry/tldconfig/idn/LanguageValidator.java @@ -14,8 +14,8 @@ package google.registry.tldconfig.idn; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; +import java.util.Optional; abstract class LanguageValidator { @@ -25,7 +25,7 @@ abstract class LanguageValidator { /** Return the language validator for the given language code (if one exists). */ static Optional get(String language) { - return Optional.fromNullable(LANGUAGE_VALIDATORS.get(language)); + return Optional.ofNullable(LANGUAGE_VALIDATORS.get(language)); } /** Returns true if the label meets the context rules for this language. */ diff --git a/java/google/registry/tmch/LordnRequestInitializer.java b/java/google/registry/tmch/LordnRequestInitializer.java index 5e3bc64b9..272ed8f4b 100644 --- a/java/google/registry/tmch/LordnRequestInitializer.java +++ b/java/google/registry/tmch/LordnRequestInitializer.java @@ -18,9 +18,9 @@ import static com.google.common.base.Verify.verifyNotNull; import static google.registry.util.UrlFetchUtils.setAuthorizationHeader; import com.google.appengine.api.urlfetch.HTTPRequest; -import com.google.common.base.Optional; import google.registry.keyring.api.KeyModule.Key; import google.registry.model.registry.Registry; +import java.util.Optional; import javax.inject.Inject; /** Helper class for setting the authorization header on a MarksDB LORDN request. */ @@ -41,7 +41,7 @@ final class LordnRequestInitializer { "lordnUsername is not set for %s.", Registry.get(tld).getTld()); return Optional.of(String.format("%s:%s", lordnUsername, marksdbLordnPassword.get())); } else { - return Optional.absent(); + return Optional.empty(); } } } diff --git a/java/google/registry/tmch/LordnTask.java b/java/google/registry/tmch/LordnTask.java index 02b65f7fd..6a726b4f3 100644 --- a/java/google/registry/tmch/LordnTask.java +++ b/java/google/registry/tmch/LordnTask.java @@ -27,7 +27,6 @@ import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TransientFailureException; import com.google.apphosting.api.DeadlineExceededException; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Uninterruptibles; @@ -35,6 +34,7 @@ import google.registry.model.domain.DomainResource; import google.registry.model.registrar.Registrar; import google.registry.util.NonFinalForTesting; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import org.joda.time.DateTime; import org.joda.time.Duration; diff --git a/java/google/registry/tmch/Marksdb.java b/java/google/registry/tmch/Marksdb.java index 7c996ac2c..07fe2337e 100644 --- a/java/google/registry/tmch/Marksdb.java +++ b/java/google/registry/tmch/Marksdb.java @@ -24,7 +24,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.URLFetchService; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import google.registry.config.RegistryConfig.Config; import google.registry.keyring.api.KeyModule.Key; @@ -35,6 +34,7 @@ import java.net.URL; import java.security.Security; import java.security.SignatureException; import java.util.List; +import java.util.Optional; import javax.annotation.Tainted; import javax.inject.Inject; import org.bouncycastle.jce.provider.BouncyCastleProvider; diff --git a/java/google/registry/tmch/NordnUploadAction.java b/java/google/registry/tmch/NordnUploadAction.java index 515e520b8..075a81636 100644 --- a/java/google/registry/tmch/NordnUploadAction.java +++ b/java/google/registry/tmch/NordnUploadAction.java @@ -34,7 +34,6 @@ import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.URLFetchService; -import com.google.common.base.Optional; import google.registry.config.RegistryConfig.Config; import google.registry.request.Action; import google.registry.request.Parameter; @@ -46,6 +45,7 @@ import google.registry.util.UrlFetchException; import java.io.IOException; import java.net.URL; import java.util.List; +import java.util.Optional; import java.util.Random; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/tmch/TmchCrlAction.java b/java/google/registry/tmch/TmchCrlAction.java index 4f47fc8fd..af9dcde16 100644 --- a/java/google/registry/tmch/TmchCrlAction.java +++ b/java/google/registry/tmch/TmchCrlAction.java @@ -17,13 +17,13 @@ package google.registry.tmch; import static google.registry.request.Action.Method.POST; import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.common.base.Optional; import google.registry.config.RegistryConfig.Config; import google.registry.request.Action; import google.registry.request.auth.Auth; import java.io.IOException; import java.net.URL; import java.security.GeneralSecurityException; +import java.util.Optional; import javax.inject.Inject; /** Action to download the latest ICANN TMCH CRL from MarksDB. */ @@ -45,7 +45,7 @@ public final class TmchCrlAction implements Runnable { public void run() { try { tmchCertificateAuthority.updateCrl( - new String(marksdb.fetch(tmchCrlUrl, Optional.absent()), UTF_8), + new String(marksdb.fetch(tmchCrlUrl, Optional.empty()), UTF_8), tmchCrlUrl.toString()); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Failed to update ICANN TMCH CRL.", e); diff --git a/java/google/registry/tmch/TmchDnlAction.java b/java/google/registry/tmch/TmchDnlAction.java index 102cfd1b3..9f7c7ef60 100644 --- a/java/google/registry/tmch/TmchDnlAction.java +++ b/java/google/registry/tmch/TmchDnlAction.java @@ -16,7 +16,6 @@ package google.registry.tmch; import static google.registry.request.Action.Method.POST; -import com.google.common.base.Optional; import google.registry.keyring.api.KeyModule.Key; import google.registry.model.tmch.ClaimsListShard; import google.registry.request.Action; @@ -25,6 +24,7 @@ import google.registry.util.FormattingLogger; import java.io.IOException; import java.security.SignatureException; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.bouncycastle.openpgp.PGPException; diff --git a/java/google/registry/tmch/TmchSmdrlAction.java b/java/google/registry/tmch/TmchSmdrlAction.java index c024f56c9..584811072 100644 --- a/java/google/registry/tmch/TmchSmdrlAction.java +++ b/java/google/registry/tmch/TmchSmdrlAction.java @@ -16,7 +16,6 @@ package google.registry.tmch; import static google.registry.request.Action.Method.POST; -import com.google.common.base.Optional; import google.registry.keyring.api.KeyModule.Key; import google.registry.model.smd.SignedMarkRevocationList; import google.registry.request.Action; @@ -25,6 +24,7 @@ import google.registry.util.FormattingLogger; import java.io.IOException; import java.security.SignatureException; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.bouncycastle.openpgp.PGPException; diff --git a/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java b/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java index ef527129f..23da14fe4 100644 --- a/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java +++ b/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java @@ -26,7 +26,6 @@ import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.Parameter; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -48,6 +47,7 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.money.CurrencyUnit; @@ -282,16 +282,16 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand { builder.setRegistrarName(registrarName); } if (email != null) { - builder.setEmailAddress(email.orNull()); + builder.setEmailAddress(email.orElse(null)); } if (url != null) { - builder.setUrl(url.orNull()); + builder.setUrl(url.orElse(null)); } if (phone != null) { - builder.setPhoneNumber(phone.orNull()); + builder.setPhoneNumber(phone.orElse(null)); } if (fax != null) { - builder.setFaxNumber(fax.orNull()); + builder.setFaxNumber(fax.orElse(null)); } if (registrarType != null) { builder.setType(registrarType); @@ -300,7 +300,7 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand { builder.setState(registrarState); } if (driveFolderId != null) { - builder.setDriveFolderId(driveFolderId.orNull()); + builder.setDriveFolderId(driveFolderId.orElse(null)); } if (!allowedTlds.isEmpty()) { checkArgument(addAllowedTlds.isEmpty(), @@ -348,10 +348,10 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand { builder.setClientCertificateHash(clientCertificateHash); } if (ianaId != null) { - builder.setIanaIdentifier(ianaId.orNull()); + builder.setIanaIdentifier(ianaId.orElse(null)); } if (billingId != null) { - builder.setBillingIdentifier(billingId.orNull()); + builder.setBillingIdentifier(billingId.orElse(null)); } if (billingAccountMap != null) { LinkedHashMap newBillingAccountMap = new LinkedHashMap<>(); diff --git a/java/google/registry/tools/CreateOrUpdateTldCommand.java b/java/google/registry/tools/CreateOrUpdateTldCommand.java index de4099704..93c31fee6 100644 --- a/java/google/registry/tools/CreateOrUpdateTldCommand.java +++ b/java/google/registry/tools/CreateOrUpdateTldCommand.java @@ -21,7 +21,6 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName; import com.beust.jcommander.Parameter; import com.google.common.base.CharMatcher; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; @@ -39,6 +38,7 @@ import google.registry.tools.params.TransitionListParameter.BillingCostTransitio import google.registry.tools.params.TransitionListParameter.TldStateTransitions; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import javax.inject.Inject; @@ -338,7 +338,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } if (driveFolderId != null) { - builder.setDriveFolderId(driveFolderId.orNull()); + builder.setDriveFolderId(driveFolderId.orElse(null)); } if (createBillingCost != null) { @@ -366,7 +366,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } if (lordnUsername != null) { - builder.setLordnUsername(lordnUsername.orNull()); + builder.setLordnUsername(lordnUsername.orElse(null)); } if (claimsPeriodEnd != null) { @@ -400,7 +400,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } if (lrpPeriod != null) { - builder.setLrpPeriod(lrpPeriod.orNull()); + builder.setLrpPeriod(lrpPeriod.orElse(null)); } ImmutableSet newReservedListNames = getReservedLists(oldRegistry); diff --git a/java/google/registry/tools/CreateRegistrarCommand.java b/java/google/registry/tools/CreateRegistrarCommand.java index 7c68f2638..c84a03d94 100644 --- a/java/google/registry/tools/CreateRegistrarCommand.java +++ b/java/google/registry/tools/CreateRegistrarCommand.java @@ -28,12 +28,12 @@ import static java.util.stream.Collectors.toCollection; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; import google.registry.model.registrar.Registrar; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; /** Command to create a Registrar. */ @@ -65,7 +65,7 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand checkArgumentNotNull(icannReferralEmail, "--icann_referral_email is a required field"); checkArgumentNotNull(street, "Address fields are required when creating a registrar"); // Default new registrars to active. - registrarState = Optional.fromNullable(registrarState).or(ACTIVE); + registrarState = Optional.ofNullable(registrarState).orElse(ACTIVE); } @Nullable diff --git a/java/google/registry/tools/CreateTldCommand.java b/java/google/registry/tools/CreateTldCommand.java index 37d5b5b1b..78edf5179 100644 --- a/java/google/registry/tools/CreateTldCommand.java +++ b/java/google/registry/tools/CreateTldCommand.java @@ -22,7 +22,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; @@ -30,6 +29,7 @@ import com.google.common.collect.Maps; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -109,6 +109,6 @@ class CreateTldCommand extends CreateOrUpdateTldCommand { Optional> getTldStateTransitionToAdd() { return initialTldState != null ? Optional.of(Maps.immutableEntry(START_OF_TIME, initialTldState)) - : Optional.>absent(); + : Optional.>empty(); } } diff --git a/java/google/registry/tools/GenerateApplicationsReportCommand.java b/java/google/registry/tools/GenerateApplicationsReportCommand.java index efd3e4b9a..02cd5b736 100644 --- a/java/google/registry/tools/GenerateApplicationsReportCommand.java +++ b/java/google/registry/tools/GenerateApplicationsReportCommand.java @@ -26,7 +26,6 @@ import static java.util.Collections.emptyList; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import com.googlecode.objectify.cmd.LoadType; import com.googlecode.objectify.cmd.Query; @@ -46,6 +45,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.annotation.CheckReturnValue; import javax.inject.Inject; import org.joda.time.DateTime; @@ -91,14 +91,14 @@ final class GenerateApplicationsReportCommand implements RemoteApiCommand { System.err.printf("Application ID %d not found\n", applicationId); continue; } - result.addAll(validate(domainApplication, now).asSet()); + validate(domainApplication, now).ifPresent(result::add); } } else { LoadType loader = ofy().load().type(DomainApplication.class); Query domainApplications = (tld == null) ? loader : loader.filter("tld", tld); for (DomainApplication domainApplication : domainApplications) { - result.addAll(validate(domainApplication, now).asSet()); + validate(domainApplication, now).ifPresent(result::add); } } Files.write(output, result, UTF_8); @@ -113,7 +113,7 @@ final class GenerateApplicationsReportCommand implements RemoteApiCommand { // Ignore deleted applications. if (isBeforeOrAt(domainApplication.getDeletionTime(), now)) { - return Optional.absent(); + return Optional.empty(); } // Defensive invalid punycode check. diff --git a/java/google/registry/tools/GenerateAuctionDataCommand.java b/java/google/registry/tools/GenerateAuctionDataCommand.java index 830653758..99e168084 100644 --- a/java/google/registry/tools/GenerateAuctionDataCommand.java +++ b/java/google/registry/tools/GenerateAuctionDataCommand.java @@ -31,7 +31,6 @@ import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; @@ -57,6 +56,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import org.joda.time.DateTime; @@ -186,13 +186,14 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand { /** Return a record line for the given application. */ private String emitApplication(DomainApplication domainApplication, ContactResource registrant) { Optional postalInfo = - Optional.fromNullable(registrant.getInternationalizedPostalInfo()) - .or(Optional.fromNullable(registrant.getLocalizedPostalInfo())); + Optional.ofNullable( + Optional.ofNullable(registrant.getInternationalizedPostalInfo()) + .orElse(registrant.getLocalizedPostalInfo())); Optional address = - Optional.fromNullable(postalInfo.isPresent() ? postalInfo.get().getAddress() : null); + Optional.ofNullable(postalInfo.isPresent() ? postalInfo.get().getAddress() : null); List street = address.isPresent() ? address.get().getStreet() : ImmutableList.of(); - Optional phoneNumber = Optional.fromNullable(registrant.getVoiceNumber()); + Optional phoneNumber = Optional.ofNullable(registrant.getVoiceNumber()); // Each line containing an auction participant has the following format: // @@ -228,9 +229,11 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand { private static String emitRegistrar(Registrar registrar) { // TODO(b/19016140): Determine if this set-up is required. Optional contact = - Optional.fromNullable(Iterables.getFirst(registrar.getContacts(), null)); - Optional address = Optional.fromNullable(registrar.getLocalizedAddress()) - .or(Optional.fromNullable(registrar.getInternationalizedAddress())); + Optional.ofNullable(Iterables.getFirst(registrar.getContacts(), null)); + Optional address = + Optional.ofNullable( + Optional.ofNullable(registrar.getLocalizedAddress()) + .orElse(registrar.getInternationalizedAddress())); List street = address.isPresent() ? address.get().getStreet() : ImmutableList.of(); diff --git a/java/google/registry/tools/ListCreditsCommand.java b/java/google/registry/tools/ListCreditsCommand.java index 4cf24bb74..03b093e0a 100644 --- a/java/google/registry/tools/ListCreditsCommand.java +++ b/java/google/registry/tools/ListCreditsCommand.java @@ -19,13 +19,13 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.Work; import google.registry.model.billing.RegistrarCredit; import google.registry.model.billing.RegistrarCreditBalance.BalanceMap; import google.registry.model.registrar.Registrar; import google.registry.tools.Command.RemoteApiCommand; +import java.util.Optional; import org.joda.money.Money; /** Command to list registrar credits and balances. */ diff --git a/java/google/registry/tools/MakeBillingTablesCommand.java b/java/google/registry/tools/MakeBillingTablesCommand.java index 08339f2dd..a2b70e197 100644 --- a/java/google/registry/tools/MakeBillingTablesCommand.java +++ b/java/google/registry/tools/MakeBillingTablesCommand.java @@ -21,11 +21,11 @@ import static google.registry.util.ResourceUtils.readResourceUtf8; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import google.registry.bigquery.BigqueryUtils.TableType; import google.registry.tools.BigqueryCommandUtilities.TableCreationException; import google.registry.util.SqlTemplate; import java.util.List; +import java.util.Optional; /** Command to make synthetic billing tables and views in Bigquery. */ @Parameters(separators = " =", commandDescription = "Make synthetic billing tables in Bigquery") @@ -55,7 +55,7 @@ final class MakeBillingTablesCommand extends BigqueryCommand { @Override public void runWithBigquery() throws Exception { // Make the source dataset default to the default destination dataset if it has not been set. - sourceDatasetId = Optional.fromNullable(sourceDatasetId).or(bigquery().getDatasetId()); + sourceDatasetId = Optional.ofNullable(sourceDatasetId).orElse(bigquery().getDatasetId()); checkArgument(!tlds.isEmpty(), "Must specify at least 1 TLD to include in billing data table"); // TODO(b/19016191): Should check that input tables exist up front, and avoid later errors. try { diff --git a/java/google/registry/tools/MutatingCommand.java b/java/google/registry/tools/MutatingCommand.java index 9685f47ad..2f1d7bdb5 100644 --- a/java/google/registry/tools/MutatingCommand.java +++ b/java/google/registry/tools/MutatingCommand.java @@ -27,7 +27,6 @@ import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff; import static java.util.stream.Collectors.joining; import com.google.common.base.MoreObjects; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -40,6 +39,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; @@ -104,7 +104,7 @@ public abstract class MutatingCommand extends ConfirmingCommand implements Remot if (type == ChangeType.UPDATE) { String diffText = prettyPrintEntityDeepDiff( oldEntity.toDiffableFieldMap(), newEntity.toDiffableFieldMap()); - changeText = Optional.fromNullable(emptyToNull(diffText)).or("[no changes]\n"); + changeText = Optional.ofNullable(emptyToNull(diffText)).orElse("[no changes]\n"); } else { changeText = MoreObjects.firstNonNull(oldEntity, newEntity) + "\n"; } diff --git a/java/google/registry/tools/RegistrarContactCommand.java b/java/google/registry/tools/RegistrarContactCommand.java index 8372c17e5..1e9012a8f 100644 --- a/java/google/registry/tools/RegistrarContactCommand.java +++ b/java/google/registry/tools/RegistrarContactCommand.java @@ -27,7 +27,6 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Enums; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.common.GaeUserIdConverter; @@ -45,6 +44,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; @@ -240,10 +240,10 @@ final class RegistrarContactCommand extends MutatingCommand { builder.setName(name); builder.setEmailAddress(email); if (phone != null) { - builder.setPhoneNumber(phone.orNull()); + builder.setPhoneNumber(phone.orElse(null)); } if (fax != null) { - builder.setFaxNumber(fax.orNull()); + builder.setFaxNumber(fax.orElse(null)); } builder.setTypes(nullToEmpty(contactTypes)); @@ -276,10 +276,10 @@ final class RegistrarContactCommand extends MutatingCommand { builder.setEmailAddress(email); } if (phone != null) { - builder.setPhoneNumber(phone.orNull()); + builder.setPhoneNumber(phone.orElse(null)); } if (fax != null) { - builder.setFaxNumber(fax.orNull()); + builder.setFaxNumber(fax.orElse(null)); } if (contactTypes != null) { builder.setTypes(contactTypes); diff --git a/java/google/registry/tools/SetupOteCommand.java b/java/google/registry/tools/SetupOteCommand.java index 7cad6d72e..f6fb6955f 100644 --- a/java/google/registry/tools/SetupOteCommand.java +++ b/java/google/registry/tools/SetupOteCommand.java @@ -20,7 +20,6 @@ import static google.registry.util.X509Utils.loadCertificate; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.re2j.Pattern; import google.registry.config.RegistryEnvironment; @@ -32,6 +31,7 @@ import google.registry.util.StringGenerator; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; import javax.inject.Named; diff --git a/java/google/registry/tools/UpdateReservedListCommand.java b/java/google/registry/tools/UpdateReservedListCommand.java index 0b3b042ed..6d6ab0a2b 100644 --- a/java/google/registry/tools/UpdateReservedListCommand.java +++ b/java/google/registry/tools/UpdateReservedListCommand.java @@ -19,12 +19,12 @@ import static google.registry.util.ListNamingUtils.convertFilePathToName; import static java.nio.charset.StandardCharsets.UTF_8; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import com.google.common.base.Strings; import google.registry.model.registry.label.ReservedList; import google.registry.model.registry.label.ReservedList.Builder; import google.registry.util.SystemClock; import java.nio.file.Files; +import java.util.Optional; /** Command to safely update {@link ReservedList} on Datastore. */ @Parameters(separators = " =", commandDescription = "Update a ReservedList in Datastore.") diff --git a/java/google/registry/tools/UpdateTldCommand.java b/java/google/registry/tools/UpdateTldCommand.java index a7c2a66ff..f39e74233 100644 --- a/java/google/registry/tools/UpdateTldCommand.java +++ b/java/google/registry/tools/UpdateTldCommand.java @@ -24,7 +24,6 @@ import static google.registry.util.CollectionUtils.nullToEmpty; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.googlecode.objectify.Key; @@ -33,6 +32,7 @@ import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -123,7 +123,7 @@ class UpdateTldCommand extends CreateOrUpdateTldCommand { Optional> getTldStateTransitionToAdd() { return setCurrentTldState != null ? Optional.of(Maps.immutableEntry(DateTime.now(DateTimeZone.UTC), setCurrentTldState)) - : Optional.>absent(); + : Optional.>empty(); } @Override diff --git a/java/google/registry/tools/ValidateLoginCredentialsCommand.java b/java/google/registry/tools/ValidateLoginCredentialsCommand.java index 6c2d67c17..9b6eacf17 100644 --- a/java/google/registry/tools/ValidateLoginCredentialsCommand.java +++ b/java/google/registry/tools/ValidateLoginCredentialsCommand.java @@ -24,13 +24,13 @@ import static java.nio.charset.StandardCharsets.US_ASCII; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.base.Optional; import google.registry.flows.TlsCredentials; import google.registry.model.registrar.Registrar; import google.registry.tools.Command.RemoteApiCommand; import google.registry.tools.params.PathParameter; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Optional; import javax.annotation.Nullable; /** A command to test registrar login credentials. */ diff --git a/java/google/registry/tools/params/OptionalParameterConverterValidator.java b/java/google/registry/tools/params/OptionalParameterConverterValidator.java index 50f18dc64..644571b49 100644 --- a/java/google/registry/tools/params/OptionalParameterConverterValidator.java +++ b/java/google/registry/tools/params/OptionalParameterConverterValidator.java @@ -14,8 +14,8 @@ package google.registry.tools.params; -import com.google.common.base.Optional; import google.registry.util.TypeUtils.TypeInstantiator; +import java.util.Optional; /** * Class for parameters that can handle special string "null" or empty values to @@ -39,7 +39,7 @@ public class OptionalParameterConverterValidator convert(String value) { if (value.equals(NULL_STRING) || value.isEmpty()) { - return Optional.absent(); + return Optional.empty(); } else { return Optional.of(validator.convert(value)); } diff --git a/java/google/registry/tools/server/CreateGroupsAction.java b/java/google/registry/tools/server/CreateGroupsAction.java index 77fa416d9..d99185fab 100644 --- a/java/google/registry/tools/server/CreateGroupsAction.java +++ b/java/google/registry/tools/server/CreateGroupsAction.java @@ -19,7 +19,6 @@ import static google.registry.request.Action.Method.POST; import static java.util.Arrays.asList; import static javax.servlet.http.HttpServletResponse.SC_OK; -import com.google.common.base.Optional; import google.registry.config.RegistryConfig.Config; import google.registry.groups.GroupsConnection; import google.registry.groups.GroupsConnection.Role; @@ -36,6 +35,7 @@ import google.registry.util.FormattingLogger; import java.io.PrintWriter; import java.io.StringWriter; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Inject; @@ -83,13 +83,13 @@ public class CreateGroupsAction implements Runnable { // that type. groupsConnection.createGroup(groupKey); groupsConnection.addMemberToGroup(parentGroup, groupKey, Role.MEMBER); - return Optional.absent(); + return Optional.empty(); } catch (Exception e) { return Optional.of(e); } }); // Return the correct server response based on the results of the group creations. - if (Optional.presentInstances(results).iterator().hasNext()) { + if (results.stream().filter(Optional::isPresent).count() > 0) { StringWriter responseString = new StringWriter(); PrintWriter responseWriter = new PrintWriter(responseString); for (int i = 0; i < results.size(); i++) { diff --git a/java/google/registry/tools/server/DeleteEntityAction.java b/java/google/registry/tools/server/DeleteEntityAction.java index 485bc34d0..d8ed5d275 100644 --- a/java/google/registry/tools/server/DeleteEntityAction.java +++ b/java/google/registry/tools/server/DeleteEntityAction.java @@ -22,7 +22,6 @@ import com.google.appengine.api.datastore.Entity; import com.google.appengine.api.datastore.EntityNotFoundException; import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.KeyFactory; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.VoidWork; @@ -33,6 +32,7 @@ import google.registry.request.Parameter; import google.registry.request.Response; import google.registry.request.auth.Auth; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.inject.Inject; /** @@ -105,16 +105,16 @@ public class DeleteEntityAction implements Runnable { private Optional loadOfyEntity(Key rawKey) { EntityMetadata metadata = ofy().factory().getMetadata(rawKey.getKind()); - return Optional.fromNullable(metadata == null ? null : ofy().load().key(create(rawKey)).now()); + return Optional.ofNullable(metadata == null ? null : ofy().load().key(create(rawKey)).now()); } private Optional loadRawEntity(Key rawKey) { try { - return Optional.fromNullable(getDatastoreService().get(rawKey)); + return Optional.ofNullable(getDatastoreService().get(rawKey)); } catch (EntityNotFoundException e) { logger.warningfmt(e, "Could not load entity from Datastore service with key %s", rawKey.toString()); - return Optional.absent(); + return Optional.empty(); } } } diff --git a/java/google/registry/tools/server/ListObjectsAction.java b/java/google/registry/tools/server/ListObjectsAction.java index 3577393ba..79d41dc9d 100644 --- a/java/google/registry/tools/server/ListObjectsAction.java +++ b/java/google/registry/tools/server/ListObjectsAction.java @@ -21,7 +21,6 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.ImmutableBiMap; @@ -41,6 +40,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.stream.Stream; import javax.inject.Inject; diff --git a/java/google/registry/tools/server/ToolsServerModule.java b/java/google/registry/tools/server/ToolsServerModule.java index 54a681324..8dfd3a2bf 100644 --- a/java/google/registry/tools/server/ToolsServerModule.java +++ b/java/google/registry/tools/server/ToolsServerModule.java @@ -19,12 +19,12 @@ import static google.registry.request.RequestParameters.extractBooleanParameter; import static google.registry.request.RequestParameters.extractOptionalParameter; import static google.registry.request.RequestParameters.extractRequiredParameter; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import dagger.Module; import dagger.Provides; import google.registry.request.Parameter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; /** @@ -36,7 +36,7 @@ public class ToolsServerModule { @Provides @Parameter("clientId") static Optional provideClientId(HttpServletRequest req) { - return Optional.fromNullable(emptyToNull(req.getParameter(CreateGroupsAction.CLIENT_ID_PARAM))); + return Optional.ofNullable(emptyToNull(req.getParameter(CreateGroupsAction.CLIENT_ID_PARAM))); } @Provides @@ -49,7 +49,7 @@ public class ToolsServerModule { @Parameter("fullFieldNames") static Optional provideFullFieldNames(HttpServletRequest req) { String s = emptyToNull(req.getParameter(ListObjectsAction.FULL_FIELD_NAMES_PARAM)); - return (s == null) ? Optional.absent() : Optional.of(Boolean.parseBoolean(s)); + return (s == null) ? Optional.empty() : Optional.of(Boolean.parseBoolean(s)); } @Provides @@ -74,7 +74,7 @@ public class ToolsServerModule { @Parameter("printHeaderRow") static Optional providePrintHeaderRow(HttpServletRequest req) { String s = emptyToNull(req.getParameter(ListObjectsAction.PRINT_HEADER_ROW_PARAM)); - return (s == null) ? Optional.absent() : Optional.of(Boolean.parseBoolean(s)); + return (s == null) ? Optional.empty() : Optional.of(Boolean.parseBoolean(s)); } @Provides diff --git a/java/google/registry/tools/server/UpdatePremiumListAction.java b/java/google/registry/tools/server/UpdatePremiumListAction.java index ec550e085..1eee150a2 100644 --- a/java/google/registry/tools/server/UpdatePremiumListAction.java +++ b/java/google/registry/tools/server/UpdatePremiumListAction.java @@ -18,13 +18,13 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.model.registry.label.PremiumListUtils.savePremiumListAndEntries; import static google.registry.request.Action.Method.POST; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import google.registry.model.registry.label.PremiumList; import google.registry.request.Action; import google.registry.request.auth.Auth; import java.util.List; +import java.util.Optional; import javax.inject.Inject; /** diff --git a/java/google/registry/tools/server/VerifyOteAction.java b/java/google/registry/tools/server/VerifyOteAction.java index e66cd7e69..c9be6de90 100644 --- a/java/google/registry/tools/server/VerifyOteAction.java +++ b/java/google/registry/tools/server/VerifyOteAction.java @@ -25,7 +25,6 @@ import static google.registry.util.DomainNameUtils.ACE_PREFIX; import com.google.common.base.Ascii; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.FluentIterable; @@ -51,6 +50,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Stream; import javax.inject.Inject; @@ -205,7 +205,7 @@ public class VerifyOteAction implements Runnable, JsonAction { this.requirement = requirement; this.typeFilter = typeFilter; if (eppInputFilter == null) { - this.eppInputFilter = Optional.>absent(); + this.eppInputFilter = Optional.>empty(); } else { this.eppInputFilter = Optional.of(eppInputFilter); } @@ -260,7 +260,7 @@ public class VerifyOteAction implements Runnable, JsonAction { // xmlBytes can be null on contact create and update for safe-harbor compliance. final Optional eppInput = (xmlBytes == null) - ? Optional.absent() + ? Optional.empty() : Optional.of(unmarshal(EppInput.class, xmlBytes)); if (!statCounts.addAll( EnumSet.allOf(StatType.class) diff --git a/java/google/registry/ui/forms/FormField.java b/java/google/registry/ui/forms/FormField.java index e6c026388..e9955925b 100644 --- a/java/google/registry/ui/forms/FormField.java +++ b/java/google/registry/ui/forms/FormField.java @@ -24,7 +24,6 @@ import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; import com.google.common.base.Function; import com.google.common.base.Functions; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -35,6 +34,7 @@ import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.annotation.Detainted; import javax.annotation.Nullable; @@ -189,7 +189,7 @@ public final class FormField { @Detainted public Optional convert(@Tainted @Nullable I value) { try { - return Optional.fromNullable(converter.apply(value)); + return Optional.ofNullable(converter.apply(value)); } catch (FormFieldException e) { throw e.propagate(name); } @@ -359,7 +359,7 @@ public final class FormField { public Builder matches(Pattern pattern, @Nullable String errorMessage) { checkState(CharSequence.class.isAssignableFrom(typeOut)); return transform( - new MatchesFunction(checkNotNull(pattern), Optional.fromNullable(errorMessage))); + new MatchesFunction(checkNotNull(pattern), Optional.ofNullable(errorMessage))); } /** Alias for {@link #matches(Pattern, String) matches(pattern, null)} */ @@ -652,7 +652,7 @@ public final class FormField { return null; } if (!pattern.matcher((CharSequence) input).matches()) { - throw new FormFieldException(errorMessage.or("Must match pattern: " + pattern)); + throw new FormFieldException(errorMessage.orElse("Must match pattern: " + pattern)); } return input; } diff --git a/java/google/registry/ui/server/RegistrarFormFields.java b/java/google/registry/ui/server/RegistrarFormFields.java index c423b68b9..923dc4ac0 100644 --- a/java/google/registry/ui/server/RegistrarFormFields.java +++ b/java/google/registry/ui/server/RegistrarFormFields.java @@ -36,6 +36,7 @@ import google.registry.util.X509Utils; import java.security.cert.CertificateParsingException; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; /** Form fields for validating input for the {@code Registrar} class. */ @@ -229,38 +230,21 @@ public final class RegistrarFormFields { return null; } RegistrarContact.Builder builder = new RegistrarContact.Builder(); - for (String name : CONTACT_NAME_FIELD.extractUntyped(args).asSet()) { - builder.setName(name); - } - for (String emailAddress : CONTACT_EMAIL_ADDRESS_FIELD.extractUntyped(args).asSet()) { - builder.setEmailAddress(emailAddress); - } - for (Boolean visible : - CONTACT_VISIBLE_IN_WHOIS_AS_ADMIN_FIELD.extractUntyped(args).asSet()) { - builder.setVisibleInWhoisAsAdmin(visible); - } - for (Boolean visible : - CONTACT_VISIBLE_IN_WHOIS_AS_TECH_FIELD.extractUntyped(args).asSet()) { - builder.setVisibleInWhoisAsTech(visible); - } - for (Boolean visible : - PHONE_AND_EMAIL_VISIBLE_IN_DOMAIN_WHOIS_AS_ABUSE_FIELD - .extractUntyped(args) - .asSet()) { - builder.setVisibleInDomainWhoisAsAbuse(visible); - } - for (String phoneNumber : CONTACT_PHONE_NUMBER_FIELD.extractUntyped(args).asSet()) { - builder.setPhoneNumber(phoneNumber); - } - for (String faxNumber : CONTACT_FAX_NUMBER_FIELD.extractUntyped(args).asSet()) { - builder.setFaxNumber(faxNumber); - } - for (Set types : CONTACT_TYPES.extractUntyped(args).asSet()) { - builder.setTypes(types); - } - for (String gaeUserId : CONTACT_GAE_USER_ID_FIELD.extractUntyped(args).asSet()) { - builder.setGaeUserId(gaeUserId); - } + CONTACT_NAME_FIELD.extractUntyped(args).ifPresent(builder::setName); + CONTACT_EMAIL_ADDRESS_FIELD.extractUntyped(args).ifPresent(builder::setEmailAddress); + CONTACT_VISIBLE_IN_WHOIS_AS_ADMIN_FIELD + .extractUntyped(args) + .ifPresent(builder::setVisibleInWhoisAsAdmin); + CONTACT_VISIBLE_IN_WHOIS_AS_TECH_FIELD + .extractUntyped(args) + .ifPresent(builder::setVisibleInWhoisAsTech); + PHONE_AND_EMAIL_VISIBLE_IN_DOMAIN_WHOIS_AS_ABUSE_FIELD + .extractUntyped(args) + .ifPresent(builder::setVisibleInDomainWhoisAsAbuse); + CONTACT_PHONE_NUMBER_FIELD.extractUntyped(args).ifPresent(builder::setPhoneNumber); + CONTACT_FAX_NUMBER_FIELD.extractUntyped(args).ifPresent(builder::setFaxNumber); + CONTACT_TYPES.extractUntyped(args).ifPresent(builder::setTypes); + CONTACT_GAE_USER_ID_FIELD.extractUntyped(args).ifPresent(builder::setGaeUserId); return builder; }; @@ -343,13 +327,13 @@ public final class RegistrarFormFields { RegistrarAddress.Builder builder = new RegistrarAddress.Builder(); String countryCode = COUNTRY_CODE_FIELD.extractUntyped(args).get(); builder.setCountryCode(countryCode); - for (List streets : streetField.extractUntyped(args).asSet()) { - builder.setStreet(ImmutableList.copyOf(streets)); - } - for (String city : cityField.extractUntyped(args).asSet()) { - builder.setCity(city); - } - for (String state : stateField.extractUntyped(args).asSet()) { + streetField + .extractUntyped(args) + .ifPresent(streets -> builder.setStreet(ImmutableList.copyOf(streets))); + cityField.extractUntyped(args).ifPresent(builder::setCity); + Optional stateFieldValue = stateField.extractUntyped(args); + if (stateFieldValue.isPresent()) { + String state = stateFieldValue.get(); if ("US".equals(countryCode)) { state = Ascii.toUpperCase(state); if (!StateCode.US_MAP.containsKey(state)) { @@ -358,9 +342,7 @@ public final class RegistrarFormFields { } builder.setState(state); } - for (String zip : zipField.extractUntyped(args).asSet()) { - builder.setZip(zip); - } + zipField.extractUntyped(args).ifPresent(builder::setZip); return builder.build(); }; } diff --git a/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java b/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java index 2eaf24dc4..840e874d5 100644 --- a/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java +++ b/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java @@ -15,19 +15,16 @@ package google.registry.ui.server.registrar; import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Sets.difference; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.security.JsonResponseHelper.Status.ERROR; import static google.registry.security.JsonResponseHelper.Status.SUCCESS; -import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; import com.google.common.collect.Streams; import com.googlecode.objectify.Work; @@ -35,6 +32,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.export.sheet.SyncRegistrarsSheetAction; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarContact.Builder; import google.registry.model.registrar.RegistrarContact.Type; import google.registry.request.Action; import google.registry.request.HttpException.BadRequestException; @@ -50,7 +48,9 @@ import google.registry.util.CollectionUtils; import google.registry.util.DiffUtils; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -97,10 +97,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult); // Process the operation. Though originally derived from a CRUD // handler, registrar-settings really only supports read and update. - String op = Optional.fromNullable((String) input.get(OP_PARAM)).or("read"); + String op = Optional.ofNullable((String) input.get(OP_PARAM)).orElse("read"); @SuppressWarnings("unchecked") Map args = (Map) - Optional.fromNullable(input.get(ARGS_PARAM)).or(ImmutableMap.of()); + Optional.ofNullable(input.get(ARGS_PARAM)).orElse(ImmutableMap.of()); try { switch (op) { case "update": @@ -175,43 +175,44 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA // WHOIS builder.setWhoisServer( - RegistrarFormFields.WHOIS_SERVER_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.WHOIS_SERVER_FIELD.extractUntyped(args).orElse(null)); builder.setReferralUrl( - RegistrarFormFields.REFERRAL_URL_FIELD.extractUntyped(args).orNull()); - for (String email : - RegistrarFormFields.EMAIL_ADDRESS_FIELD.extractUntyped(args).asSet()) { - builder.setEmailAddress(email); - } + RegistrarFormFields.REFERRAL_URL_FIELD.extractUntyped(args).orElse(null)); + RegistrarFormFields.EMAIL_ADDRESS_FIELD + .extractUntyped(args) + .ifPresent(builder::setEmailAddress); builder.setPhoneNumber( - RegistrarFormFields.PHONE_NUMBER_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.PHONE_NUMBER_FIELD.extractUntyped(args).orElse(null)); builder.setFaxNumber( - RegistrarFormFields.FAX_NUMBER_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.FAX_NUMBER_FIELD.extractUntyped(args).orElse(null)); builder.setLocalizedAddress( - RegistrarFormFields.L10N_ADDRESS_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.L10N_ADDRESS_FIELD.extractUntyped(args).orElse(null)); // Security builder.setIpAddressWhitelist( - RegistrarFormFields.IP_ADDRESS_WHITELIST_FIELD.extractUntyped(args).or( - ImmutableList.of())); - for (String certificate - : RegistrarFormFields.CLIENT_CERTIFICATE_FIELD.extractUntyped(args).asSet()) { - builder.setClientCertificate(certificate, ofy().getTransactionTime()); - } - for (String certificate - : RegistrarFormFields.FAILOVER_CLIENT_CERTIFICATE_FIELD.extractUntyped(args).asSet()) { - builder.setFailoverClientCertificate(certificate, ofy().getTransactionTime()); - } + RegistrarFormFields.IP_ADDRESS_WHITELIST_FIELD + .extractUntyped(args) + .orElse(ImmutableList.of())); + RegistrarFormFields.CLIENT_CERTIFICATE_FIELD + .extractUntyped(args) + .ifPresent( + certificate -> builder.setClientCertificate(certificate, ofy().getTransactionTime())); + RegistrarFormFields.FAILOVER_CLIENT_CERTIFICATE_FIELD + .extractUntyped(args) + .ifPresent( + certificate -> + builder.setFailoverClientCertificate(certificate, ofy().getTransactionTime())); builder.setUrl( - RegistrarFormFields.URL_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.URL_FIELD.extractUntyped(args).orElse(null)); builder.setReferralUrl( - RegistrarFormFields.REFERRAL_URL_FIELD.extractUntyped(args).orNull()); + RegistrarFormFields.REFERRAL_URL_FIELD.extractUntyped(args).orElse(null)); // Contact ImmutableSet.Builder contacts = new ImmutableSet.Builder<>(); - for (RegistrarContact.Builder contactBuilder - : concat(RegistrarFormFields.CONTACTS_FIELD.extractUntyped(args).asSet())) { - contacts.add(contactBuilder.setParent(existingRegistrarObj).build()); + Optional> builders = RegistrarFormFields.CONTACTS_FIELD.extractUntyped(args); + if (builders.isPresent()) { + builders.get().forEach(c -> contacts.add(c.setParent(existingRegistrarObj).build())); } return contacts.build(); @@ -298,7 +299,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA */ private static Optional getDomainWhoisVisibleAbuseContact( Set contacts) { - return Iterables.tryFind(contacts, RegistrarContact::getVisibleInDomainWhoisAsAbuse); + return contacts.stream().filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse).findFirst(); } /** diff --git a/java/google/registry/ui/server/registrar/SessionUtils.java b/java/google/registry/ui/server/registrar/SessionUtils.java index d8e7f88bf..e013352fc 100644 --- a/java/google/registry/ui/server/registrar/SessionUtils.java +++ b/java/google/registry/ui/server/registrar/SessionUtils.java @@ -20,7 +20,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.PreconditionsUtils.checkArgumentPresent; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.googlecode.objectify.Key; import google.registry.config.RegistryConfig.Config; @@ -30,6 +29,7 @@ import google.registry.request.HttpException.ForbiddenException; import google.registry.request.auth.AuthResult; import google.registry.request.auth.UserAuthInfo; import google.registry.util.FormattingLogger; +import java.util.Optional; import javax.annotation.CheckReturnValue; import javax.annotation.concurrent.Immutable; import javax.inject.Inject; @@ -167,7 +167,7 @@ public class SessionUtils { .filter("gaeUserId", gaeUserId) .first().now(); if (contact == null) { - return Optional.absent(); + return Optional.empty(); } String registrarClientId = contact.getParent().getName(); Optional result = Registrar.loadByClientIdCached(registrarClientId); diff --git a/java/google/registry/util/DatastoreServiceUtils.java b/java/google/registry/util/DatastoreServiceUtils.java index 8ae2976ac..71fdec1ac 100644 --- a/java/google/registry/util/DatastoreServiceUtils.java +++ b/java/google/registry/util/DatastoreServiceUtils.java @@ -16,7 +16,7 @@ package google.registry.util; import com.google.appengine.api.datastore.Key; import com.google.common.base.Function; -import com.google.common.base.Optional; +import java.util.Optional; /** Utility methods for working with the App Engine Datastore service. */ public class DatastoreServiceUtils { @@ -26,6 +26,6 @@ public class DatastoreServiceUtils { /** Returns the name or id of a key, which may be a string or a long. */ public static Object getNameOrId(Key key) { - return Optional.fromNullable(key.getName()).or(key.getId()); + return Optional.ofNullable(key.getName()).orElse(key.getId()); } } diff --git a/java/google/registry/util/PreconditionsUtils.java b/java/google/registry/util/PreconditionsUtils.java index 4411f4466..73161e3d9 100644 --- a/java/google/registry/util/PreconditionsUtils.java +++ b/java/google/registry/util/PreconditionsUtils.java @@ -16,7 +16,7 @@ package google.registry.util; import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.base.Optional; +import java.util.Optional; import javax.annotation.Nullable; /** Utility methods related to preconditions checking. */ diff --git a/java/google/registry/util/UrlFetchUtils.java b/java/google/registry/util/UrlFetchUtils.java index d0fbe04f5..1ca2bc881 100644 --- a/java/google/registry/util/UrlFetchUtils.java +++ b/java/google/registry/util/UrlFetchUtils.java @@ -27,9 +27,9 @@ import com.google.appengine.api.urlfetch.HTTPHeader; import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.common.base.Ascii; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.net.MediaType; +import java.util.Optional; import java.util.Random; /** Helper methods for the App Engine URL fetch service. */ @@ -55,7 +55,7 @@ public final class UrlFetchUtils { return Optional.of(header.getValue()); } } - return Optional.absent(); + return Optional.empty(); } /** diff --git a/java/google/registry/whois/DomainLookupCommand.java b/java/google/registry/whois/DomainLookupCommand.java index 2c9ca86b7..46986f331 100644 --- a/java/google/registry/whois/DomainLookupCommand.java +++ b/java/google/registry/whois/DomainLookupCommand.java @@ -16,9 +16,9 @@ package google.registry.whois; import static google.registry.model.EppResourceUtils.loadByForeignKey; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import google.registry.model.domain.DomainResource; +import java.util.Optional; import org.joda.time.DateTime; /** Represents a WHOIS lookup on a domain name (i.e. SLD). */ @@ -32,7 +32,7 @@ public class DomainLookupCommand extends DomainOrHostLookupCommand { protected Optional getResponse(InternetDomainName domainName, DateTime now) { final DomainResource domainResource = loadByForeignKey(DomainResource.class, domainName.toString(), now); - return Optional.fromNullable( + return Optional.ofNullable( domainResource == null ? null : new DomainWhoisResponse(domainResource, now)); } } diff --git a/java/google/registry/whois/DomainOrHostLookupCommand.java b/java/google/registry/whois/DomainOrHostLookupCommand.java index a03966dab..f97d46e30 100644 --- a/java/google/registry/whois/DomainOrHostLookupCommand.java +++ b/java/google/registry/whois/DomainOrHostLookupCommand.java @@ -20,8 +20,8 @@ import static google.registry.model.registry.Registries.getTlds; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; +import java.util.Optional; import org.joda.time.DateTime; /** Represents a WHOIS lookup on a domain name (i.e. SLD) or a nameserver. */ diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index d6587a391..d99b2b937 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -16,15 +16,12 @@ package google.registry.whois; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.tryFind; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.xml.UtcDateTimeAdapter.getFormattedString; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.googlecode.objectify.Key; import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactResource; @@ -39,6 +36,7 @@ import google.registry.model.registrar.RegistrarContact; import google.registry.model.translators.EnumToAttributeAdapter.EppEnum; import google.registry.util.FormattingLogger; import java.util.Objects; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -74,8 +72,11 @@ final class DomainWhoisResponse extends WhoisResponseImpl { domain.getCurrentSponsorClientId()); Registrar registrar = registrarOptional.get(); Optional abuseContact = - Iterables.tryFind( - registrar.getContacts(), RegistrarContact::getVisibleInDomainWhoisAsAbuse); + registrar + .getContacts() + .stream() + .filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse) + .findFirst(); String plaintext = new DomainEmitter() .emitField( @@ -121,7 +122,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl { @Nullable private Key getContactReference(final Type type) { Optional contactOfType = - tryFind(domain.getContacts(), d -> d.getType() == type); + domain.getContacts().stream().filter(d -> d.getType() == type).findFirst(); return contactOfType.isPresent() ? contactOfType.get().getContactKey() : null; } diff --git a/java/google/registry/whois/NameserverLookupByHostCommand.java b/java/google/registry/whois/NameserverLookupByHostCommand.java index 022bdf6f1..ec9636ab6 100644 --- a/java/google/registry/whois/NameserverLookupByHostCommand.java +++ b/java/google/registry/whois/NameserverLookupByHostCommand.java @@ -16,9 +16,9 @@ package google.registry.whois; import static google.registry.model.EppResourceUtils.loadByForeignKey; -import com.google.common.base.Optional; import com.google.common.net.InternetDomainName; import google.registry.model.host.HostResource; +import java.util.Optional; import org.joda.time.DateTime; /** Represents a WHOIS lookup on a nameserver based on its hostname. */ @@ -32,7 +32,7 @@ public class NameserverLookupByHostCommand extends DomainOrHostLookupCommand { protected Optional getResponse(InternetDomainName hostName, DateTime now) { final HostResource hostResource = loadByForeignKey(HostResource.class, hostName.toString(), now); - return Optional.fromNullable( + return Optional.ofNullable( hostResource == null ? null : new NameserverWhoisResponse(hostResource, now)); } } diff --git a/java/google/registry/whois/NameserverWhoisResponse.java b/java/google/registry/whois/NameserverWhoisResponse.java index 57362fc9f..d17a81e96 100644 --- a/java/google/registry/whois/NameserverWhoisResponse.java +++ b/java/google/registry/whois/NameserverWhoisResponse.java @@ -18,11 +18,11 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static google.registry.model.ofy.ObjectifyService.ofy; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.InetAddresses; import google.registry.model.host.HostResource; import google.registry.model.registrar.Registrar; +import java.util.Optional; import org.joda.time.DateTime; /** Container for WHOIS responses to a nameserver lookup queries. */ diff --git a/java/google/registry/whois/WhoisMetrics.java b/java/google/registry/whois/WhoisMetrics.java index 1142277bb..6a995e66b 100644 --- a/java/google/registry/whois/WhoisMetrics.java +++ b/java/google/registry/whois/WhoisMetrics.java @@ -18,13 +18,13 @@ import static com.google.common.base.Preconditions.checkState; import static google.registry.monitoring.metrics.EventMetric.DEFAULT_FITTER; import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import google.registry.monitoring.metrics.EventMetric; import google.registry.monitoring.metrics.IncrementableMetric; import google.registry.monitoring.metrics.LabelDescriptor; import google.registry.monitoring.metrics.MetricRegistryImpl; import google.registry.util.Clock; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; @@ -62,12 +62,12 @@ public class WhoisMetrics { /** Records the given {@link WhoisMetric} and its associated processing time. */ public void recordWhoisMetric(WhoisMetric metric) { whoisRequests.increment( - metric.commandName().or(""), + metric.commandName().orElse(""), Integer.toString(metric.numResults()), Integer.toString(metric.status())); processingTime.record( metric.endTimestamp().getMillis() - metric.startTimestamp().getMillis(), - metric.commandName().or(""), + metric.commandName().orElse(""), Integer.toString(metric.numResults()), Integer.toString(metric.status())); } diff --git a/java/google/registry/whois/WhoisReader.java b/java/google/registry/whois/WhoisReader.java index ace952aba..455046142 100644 --- a/java/google/registry/whois/WhoisReader.java +++ b/java/google/registry/whois/WhoisReader.java @@ -21,7 +21,6 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.io.CharStreams; import com.google.common.net.InetAddresses; import com.google.common.net.InternetDomainName; @@ -31,6 +30,7 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.inject.Inject; import org.joda.time.DateTime; diff --git a/java/google/registry/whois/WhoisResponseImpl.java b/java/google/registry/whois/WhoisResponseImpl.java index a440c10d2..a56e5ef25 100644 --- a/java/google/registry/whois/WhoisResponseImpl.java +++ b/java/google/registry/whois/WhoisResponseImpl.java @@ -21,11 +21,11 @@ import static com.google.common.html.HtmlEscapers.htmlEscaper; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import google.registry.model.eppcommon.Address; import google.registry.util.Idn; import google.registry.xml.UtcDateTimeAdapter; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -64,9 +64,9 @@ abstract class WhoisResponseImpl implements WhoisResponse { static T chooseByUnicodePreference( boolean preferUnicode, @Nullable T localized, @Nullable T internationalized) { if (preferUnicode) { - return Optional.fromNullable(localized).or(Optional.fromNullable(internationalized)).orNull(); + return Optional.ofNullable(localized).orElse(internationalized); } else { - return Optional.fromNullable(internationalized).or(Optional.fromNullable(localized)).orNull(); + return Optional.ofNullable(internationalized).orElse(localized); } } diff --git a/javatests/google/registry/backup/BUILD b/javatests/google/registry/backup/BUILD index 0f24032d3..d04d5eef3 100644 --- a/javatests/google/registry/backup/BUILD +++ b/javatests/google/registry/backup/BUILD @@ -18,12 +18,13 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/testing/mapreduce", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_code_findbugs_jsr305", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/backup/GcsDiffFileListerTest.java b/javatests/google/registry/backup/GcsDiffFileListerTest.java index 6649298ee..ecd6e587a 100644 --- a/javatests/google/registry/backup/GcsDiffFileListerTest.java +++ b/javatests/google/registry/backup/GcsDiffFileListerTest.java @@ -16,6 +16,7 @@ package google.registry.backup; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static google.registry.backup.BackupUtils.GcsMetadataKeys.LOWER_BOUND_CHECKPOINT; import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX; diff --git a/javatests/google/registry/backup/RestoreCommitLogsActionTest.java b/javatests/google/registry/backup/RestoreCommitLogsActionTest.java index 3274b0598..ee091a39e 100644 --- a/javatests/google/registry/backup/RestoreCommitLogsActionTest.java +++ b/javatests/google/registry/backup/RestoreCommitLogsActionTest.java @@ -19,6 +19,7 @@ import static com.google.common.base.Functions.constant; import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Maps.toMap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static google.registry.backup.BackupUtils.GcsMetadataKeys.LOWER_BOUND_CHECKPOINT; import static google.registry.backup.BackupUtils.serializeEntity; diff --git a/javatests/google/registry/batch/BUILD b/javatests/google/registry/batch/BUILD index fa9f4cea4..0ad96ff6e 100644 --- a/javatests/google/registry/batch/BUILD +++ b/javatests/google/registry/batch/BUILD @@ -20,7 +20,6 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/testing/mapreduce", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_apis_google_api_services_bigquery", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_stubs", @@ -32,6 +31,8 @@ java_library( "@com_google_guava", "@com_google_http_client", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java index fba1ffb5f..e2322c661 100644 --- a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java +++ b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java @@ -17,6 +17,7 @@ package google.registry.batch; import static com.google.appengine.api.taskqueue.QueueFactory.getQueue; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.async.AsyncFlowEnqueuer.QUEUE_ASYNC_DELETE; import static google.registry.flows.async.AsyncFlowEnqueuer.QUEUE_ASYNC_HOST_RENAME; import static google.registry.flows.async.AsyncFlowMetrics.OperationResult.STALE; diff --git a/javatests/google/registry/batch/DeleteProberDataActionTest.java b/javatests/google/registry/batch/DeleteProberDataActionTest.java index 006aa798a..3a5409985 100644 --- a/javatests/google/registry/batch/DeleteProberDataActionTest.java +++ b/javatests/google/registry/batch/DeleteProberDataActionTest.java @@ -16,6 +16,7 @@ package google.registry.batch; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java index 5d0e16f50..0f67ce1ad 100644 --- a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java +++ b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java @@ -15,6 +15,7 @@ package google.registry.batch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.Cursor.CursorType.RECURRING_BILLING; import static google.registry.model.domain.Period.Unit.YEARS; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -32,7 +33,6 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.USD; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Iterables; @@ -57,6 +57,7 @@ import google.registry.testing.InjectRule; import google.registry.testing.mapreduce.MapreduceTestCase; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.Before; @@ -89,7 +90,7 @@ public class ExpandRecurringBillingEventsActionTest action = new ExpandRecurringBillingEventsAction(); action.mrRunner = makeDefaultRunner(); action.clock = clock; - action.cursorTimeParam = Optional.absent(); + action.cursorTimeParam = Optional.empty(); createTld("tld"); domain = persistActiveDomain("example.tld"); historyEntry = persistResource(new HistoryEntry.Builder().setParent(domain).build()); diff --git a/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java b/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java index 2b6e4a7f8..7a918e81a 100644 --- a/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java +++ b/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java @@ -17,6 +17,7 @@ package google.registry.batch; import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_OK; import static org.joda.time.DateTimeZone.UTC; @@ -45,13 +46,13 @@ import com.google.appengine.tools.pipeline.impl.model.JobInstanceRecord; import com.google.appengine.tools.pipeline.impl.model.JobRecord; import com.google.appengine.tools.pipeline.impl.model.ShardedValue; import com.google.appengine.tools.pipeline.impl.model.Slot; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.mapreduce.MapreduceTestCase; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; @@ -120,22 +121,22 @@ public class MapreduceEntityCleanupActionTest private void setAnyJobAndDaysOld(int daysOld) { setJobIdJobNameAndDaysOld( - Optional.absent(), Optional.absent(), Optional.of(daysOld)); + Optional.empty(), Optional.empty(), Optional.of(daysOld)); } private void setJobId(String jobId) { setJobIdJobNameAndDaysOld( - Optional.of(jobId), Optional.absent(), Optional.absent()); + Optional.of(jobId), Optional.empty(), Optional.empty()); } private void setJobName(String jobName) { setJobIdJobNameAndDaysOld( - Optional.absent(), Optional.of(jobName), Optional.absent()); + Optional.empty(), Optional.of(jobName), Optional.empty()); } private void setJobNameAndDaysOld(String jobName, int daysOld) { setJobIdJobNameAndDaysOld( - Optional.absent(), Optional.of(jobName), Optional.of(daysOld)); + Optional.empty(), Optional.of(jobName), Optional.of(daysOld)); } private void setJobIdJobNameAndDaysOld( @@ -144,9 +145,9 @@ public class MapreduceEntityCleanupActionTest action = new MapreduceEntityCleanupAction( jobId, jobName, - Optional.absent(), // numJobsToDelete + Optional.empty(), // numJobsToDelete daysOld, - Optional.absent(), // force + Optional.empty(), // force mapreduceEntityCleanupUtil, clock, DatastoreServiceFactory.getDatastoreService(), @@ -269,7 +270,7 @@ public class MapreduceEntityCleanupActionTest createMapreduce("jobname"); executeTasksUntilEmpty(QUEUE_NAME, clock); setJobIdJobNameAndDaysOld( - Optional.absent(), Optional.absent(), Optional.absent()); + Optional.empty(), Optional.empty(), Optional.empty()); action.run(); @@ -353,11 +354,11 @@ public class MapreduceEntityCleanupActionTest executeTasksUntilEmpty(QUEUE_NAME, clock); clock.setTo(DateTime.now(UTC)); action = new MapreduceEntityCleanupAction( - Optional.absent(), // jobId - Optional.absent(), // jobName + Optional.empty(), // jobId + Optional.empty(), // jobName Optional.of(1), // numJobsToDelete Optional.of(0), // daysOld - Optional.absent(), // force + Optional.empty(), // force mapreduceEntityCleanupUtil, clock, DatastoreServiceFactory.getDatastoreService(), @@ -432,10 +433,10 @@ public class MapreduceEntityCleanupActionTest clock.setTo(DateTime.now(UTC)); action = new MapreduceEntityCleanupAction( Optional.of(jobId2), // jobId - Optional.absent(), // jobName - Optional.absent(), // numJobsToDelete - Optional.absent(), // daysOld - Optional.absent(), // force + Optional.empty(), // jobName + Optional.empty(), // numJobsToDelete + Optional.empty(), // daysOld + Optional.empty(), // force mapreduceEntityCleanupUtil, clock, DatastoreServiceFactory.getDatastoreService(), @@ -477,9 +478,9 @@ public class MapreduceEntityCleanupActionTest clock.setTo(DateTime.now(UTC)); action = new MapreduceEntityCleanupAction( Optional.of(jobId), - Optional.absent(), // jobName - Optional.absent(), // numJobsToDelete - Optional.absent(), // daysOld + Optional.empty(), // jobName + Optional.empty(), // numJobsToDelete + Optional.empty(), // daysOld Optional.of(true), // force mapreduceEntityCleanupUtil, clock, @@ -501,7 +502,7 @@ public class MapreduceEntityCleanupActionTest @Test public void testJobIdAndJobName_fails() throws Exception { setJobIdJobNameAndDaysOld( - Optional.of("jobid"), Optional.of("jobname"), Optional.absent()); + Optional.of("jobid"), Optional.of("jobname"), Optional.empty()); action.run(); @@ -513,7 +514,7 @@ public class MapreduceEntityCleanupActionTest @Test public void testJobIdAndDaysOld_fails() throws Exception { - setJobIdJobNameAndDaysOld(Optional.of("jobid"), Optional.absent(), Optional.of(0)); + setJobIdJobNameAndDaysOld(Optional.of("jobid"), Optional.empty(), Optional.of(0)); action.run(); @@ -528,10 +529,10 @@ public class MapreduceEntityCleanupActionTest public void testJobIdAndNumJobs_fails() throws Exception { action = new MapreduceEntityCleanupAction( Optional.of("jobid"), - Optional.absent(), // jobName + Optional.empty(), // jobName Optional.of(1), // numJobsToDelete - Optional.absent(), // daysOld - Optional.absent(), // force + Optional.empty(), // daysOld + Optional.empty(), // force mapreduceEntityCleanupUtil, clock, DatastoreServiceFactory.getDatastoreService(), @@ -549,11 +550,11 @@ public class MapreduceEntityCleanupActionTest @Test public void testDeleteZeroJobs_throwsUsageError() throws Exception { new MapreduceEntityCleanupAction( - Optional.absent(), // jobId - Optional.absent(), // jobName + Optional.empty(), // jobId + Optional.empty(), // jobName Optional.of(0), // numJobsToDelete - Optional.absent(), // daysOld - Optional.absent(), // force + Optional.empty(), // daysOld + Optional.empty(), // force mapreduceEntityCleanupUtil, clock, DatastoreServiceFactory.getDatastoreService(), diff --git a/javatests/google/registry/batch/ResaveAllEppResourcesActionTest.java b/javatests/google/registry/batch/ResaveAllEppResourcesActionTest.java index 1d39f76c7..cd3bc31ae 100644 --- a/javatests/google/registry/batch/ResaveAllEppResourcesActionTest.java +++ b/javatests/google/registry/batch/ResaveAllEppResourcesActionTest.java @@ -15,6 +15,7 @@ package google.registry.batch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistContactWithPendingTransfer; diff --git a/javatests/google/registry/batch/TestMapreduceEntityCleanupUtil.java b/javatests/google/registry/batch/TestMapreduceEntityCleanupUtil.java index fb8fd83da..6f0b3a168 100644 --- a/javatests/google/registry/batch/TestMapreduceEntityCleanupUtil.java +++ b/javatests/google/registry/batch/TestMapreduceEntityCleanupUtil.java @@ -14,7 +14,7 @@ package google.registry.batch; -import com.google.common.base.Optional; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.time.DateTime; diff --git a/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java index 163f4067f..f0001061c 100644 --- a/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java +++ b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java @@ -15,6 +15,7 @@ package google.registry.batch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.newContactResource; @@ -37,7 +38,6 @@ import com.google.api.services.bigquery.Bigquery; import com.google.api.services.bigquery.model.TableDataInsertAllRequest; import com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows; import com.google.api.services.bigquery.model.TableDataInsertAllResponse; -import com.google.common.base.Optional; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -57,6 +57,7 @@ import google.registry.testing.InjectRule; import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.util.Retrier; import java.util.Map; +import java.util.Optional; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.Before; diff --git a/javatests/google/registry/bigquery/BUILD b/javatests/google/registry/bigquery/BUILD index d3aced35c..fa667c057 100644 --- a/javatests/google/registry/bigquery/BUILD +++ b/javatests/google/registry/bigquery/BUILD @@ -15,11 +15,12 @@ java_library( "//java/google/registry/bigquery", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_apis_google_api_services_bigquery", "@com_google_code_findbugs_jsr305", "@com_google_guava", "@com_google_http_client", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/bigquery/BigqueryFactoryTest.java b/javatests/google/registry/bigquery/BigqueryFactoryTest.java index 7206f95f0..85dd88c36 100644 --- a/javatests/google/registry/bigquery/BigqueryFactoryTest.java +++ b/javatests/google/registry/bigquery/BigqueryFactoryTest.java @@ -15,6 +15,7 @@ package google.registry.bigquery; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.bigquery.BigqueryUtils.FieldType.STRING; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; diff --git a/javatests/google/registry/bigquery/BigqueryUtilsTest.java b/javatests/google/registry/bigquery/BigqueryUtilsTest.java index e69050434..fd38c82d5 100644 --- a/javatests/google/registry/bigquery/BigqueryUtilsTest.java +++ b/javatests/google/registry/bigquery/BigqueryUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.bigquery; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.bigquery.BigqueryUtils.fromBigqueryTimestampString; import static google.registry.bigquery.BigqueryUtils.toBigqueryTimestamp; import static google.registry.bigquery.BigqueryUtils.toBigqueryTimestampString; diff --git a/javatests/google/registry/config/BUILD b/javatests/google/registry/config/BUILD index 16ff9d256..c60e0f080 100644 --- a/javatests/google/registry/config/BUILD +++ b/javatests/google/registry/config/BUILD @@ -12,8 +12,9 @@ java_library( srcs = glob(["*.java"]), deps = [ "//java/google/registry/config", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", ], ) diff --git a/javatests/google/registry/config/RegistryConfigTest.java b/javatests/google/registry/config/RegistryConfigTest.java index 6faaddf29..cf5c4105d 100644 --- a/javatests/google/registry/config/RegistryConfigTest.java +++ b/javatests/google/registry/config/RegistryConfigTest.java @@ -15,6 +15,7 @@ package google.registry.config; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/config/YamlUtilsTest.java b/javatests/google/registry/config/YamlUtilsTest.java index 51f4e5960..55c307b3b 100644 --- a/javatests/google/registry/config/YamlUtilsTest.java +++ b/javatests/google/registry/config/YamlUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.config; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.YamlUtils.mergeYaml; import com.google.common.base.Joiner; diff --git a/javatests/google/registry/cron/BUILD b/javatests/google/registry/cron/BUILD index 62783a48f..0e4d31259 100644 --- a/javatests/google/registry/cron/BUILD +++ b/javatests/google/registry/cron/BUILD @@ -16,11 +16,12 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_stubs", "@com_google_appengine_testing", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/cron/CommitLogFanoutActionTest.java b/javatests/google/registry/cron/CommitLogFanoutActionTest.java index ccf22888c..6f007940a 100644 --- a/javatests/google/registry/cron/CommitLogFanoutActionTest.java +++ b/javatests/google/registry/cron/CommitLogFanoutActionTest.java @@ -18,7 +18,6 @@ import static google.registry.cron.CommitLogFanoutAction.BUCKET_PARAM; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import google.registry.model.ofy.CommitLogBucket; import google.registry.testing.AppEngineRule; import google.registry.testing.ExceptionRule; @@ -27,6 +26,7 @@ import google.registry.util.Retrier; import google.registry.util.TaskEnqueuer; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,7 +61,7 @@ public class CommitLogFanoutActionTest { action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1)); action.endpoint = ENDPOINT; action.queue = QUEUE; - action.jitterSeconds = Optional.absent(); + action.jitterSeconds = Optional.empty(); action.run(); List matchers = new ArrayList<>(); for (int bucketId : CommitLogBucket.getBucketIds()) { diff --git a/javatests/google/registry/cron/TldFanoutActionTest.java b/javatests/google/registry/cron/TldFanoutActionTest.java index 7cd50e8b7..cffe1c70a 100644 --- a/javatests/google/registry/cron/TldFanoutActionTest.java +++ b/javatests/google/registry/cron/TldFanoutActionTest.java @@ -17,6 +17,7 @@ package google.registry.cron; import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Lists.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued; @@ -26,7 +27,6 @@ import static java.util.Arrays.asList; import com.google.appengine.api.taskqueue.dev.QueueStateInfo.TaskStateInfo; import com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableSet; @@ -39,6 +39,7 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.util.Retrier; import google.registry.util.TaskEnqueuer; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -92,7 +93,7 @@ public class TldFanoutActionTest { action.runInEmpty = params.containsKey("runInEmpty"); action.forEachRealTld = params.containsKey("forEachRealTld"); action.forEachTestTld = params.containsKey("forEachTestTld"); - action.jitterSeconds = Optional.absent(); + action.jitterSeconds = Optional.empty(); action.run(); } diff --git a/javatests/google/registry/dns/BUILD b/javatests/google/registry/dns/BUILD index 8561208f9..388cd8a3f 100644 --- a/javatests/google/registry/dns/BUILD +++ b/javatests/google/registry/dns/BUILD @@ -23,12 +23,13 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_stubs", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/dns/ReadDnsQueueActionTest.java b/javatests/google/registry/dns/ReadDnsQueueActionTest.java index 93d3cd38f..09da23eb3 100644 --- a/javatests/google/registry/dns/ReadDnsQueueActionTest.java +++ b/javatests/google/registry/dns/ReadDnsQueueActionTest.java @@ -30,7 +30,6 @@ import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.dev.QueueStateInfo.TaskStateInfo; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; @@ -47,6 +46,7 @@ import google.registry.util.TaskEnqueuer; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import java.util.Optional; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.Duration; @@ -106,7 +106,7 @@ public class ReadDnsQueueActionTest { action.dnsQueue = dnsQueue; action.dnsPublishPushQueue = QueueFactory.getQueue(DNS_PUBLISH_PUSH_QUEUE_NAME); action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1)); - action.jitterSeconds = Optional.absent(); + action.jitterSeconds = Optional.empty(); action.keepTasks = keepTasks; // Advance the time a little, to ensure that leaseTasks() returns all tasks. clock.setTo(DateTime.now(DateTimeZone.UTC).plusMillis(1)); diff --git a/javatests/google/registry/dns/writer/clouddns/BUILD b/javatests/google/registry/dns/writer/clouddns/BUILD index be477189f..c4229e502 100644 --- a/javatests/google/registry/dns/writer/clouddns/BUILD +++ b/javatests/google/registry/dns/writer/clouddns/BUILD @@ -16,10 +16,11 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_apis_google_api_services_dns", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java index e48673ea5..71dcf7268 100644 --- a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java +++ b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java @@ -17,6 +17,7 @@ package google.registry.dns.writer.clouddns; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.testing.DatastoreHelper.newHostResource; diff --git a/javatests/google/registry/dns/writer/dnsupdate/BUILD b/javatests/google/registry/dns/writer/dnsupdate/BUILD index 40e9b9d04..53f4c80f0 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/BUILD +++ b/javatests/google/registry/dns/writer/dnsupdate/BUILD @@ -15,11 +15,12 @@ java_library( "//java/google/registry/model", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@dnsjava", "@javax_servlet_api", "@joda_time", diff --git a/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java b/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java index 2fe235e08..82f2b9a66 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java +++ b/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java @@ -16,6 +16,7 @@ package google.registry.dns.writer.dnsupdate; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java index 0cf6276c9..12f636c7f 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java +++ b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java @@ -17,6 +17,7 @@ package google.registry.dns.writer.dnsupdate; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.testing.DatastoreHelper.newHostResource; diff --git a/javatests/google/registry/export/BUILD b/javatests/google/registry/export/BUILD index b73772d02..7de0082e2 100644 --- a/javatests/google/registry/export/BUILD +++ b/javatests/google/registry/export/BUILD @@ -28,7 +28,6 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/testing/mapreduce", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_apis_google_api_services_bigquery", "@com_google_apis_google_api_services_drive", "@com_google_appengine_api_1_0_sdk//:testonly", @@ -39,6 +38,8 @@ java_library( "@com_google_guava", "@com_google_http_client", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/export/BigqueryPollJobActionTest.java b/javatests/google/registry/export/BigqueryPollJobActionTest.java index 99eac5a4d..dfddd2411 100644 --- a/javatests/google/registry/export/BigqueryPollJobActionTest.java +++ b/javatests/google/registry/export/BigqueryPollJobActionTest.java @@ -18,6 +18,7 @@ import static com.google.appengine.api.taskqueue.QueueFactory.getQueue; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.logging.Level.INFO; diff --git a/javatests/google/registry/export/CheckSnapshotActionTest.java b/javatests/google/registry/export/CheckSnapshotActionTest.java index 0812178a3..eb56684e5 100644 --- a/javatests/google/registry/export/CheckSnapshotActionTest.java +++ b/javatests/google/registry/export/CheckSnapshotActionTest.java @@ -15,6 +15,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_KINDS_TO_LOAD_PARAM; import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_NAME_PARAM; import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued; @@ -23,7 +24,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.request.Action.Method; @@ -36,6 +36,7 @@ import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; +import java.util.Optional; import org.joda.time.DateTime; import org.joda.time.Duration; import org.junit.Before; @@ -88,7 +89,7 @@ public class CheckSnapshotActionTest { new DatastoreBackupInfo( backupInfo.getName(), backupInfo.getStartTime(), - Optional.absent(), + Optional.empty(), backupInfo.getKinds(), backupInfo.getGcsFilename()); diff --git a/javatests/google/registry/export/DatastoreBackupInfoTest.java b/javatests/google/registry/export/DatastoreBackupInfoTest.java index 22e256a6a..13053bd39 100644 --- a/javatests/google/registry/export/DatastoreBackupInfoTest.java +++ b/javatests/google/registry/export/DatastoreBackupInfoTest.java @@ -16,6 +16,7 @@ package google.registry.export; import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.api.datastore.Entity; import com.google.appengine.api.datastore.EntityNotFoundException; @@ -77,8 +78,8 @@ public class DatastoreBackupInfoTest { assertThat(backup.getName()).isEqualTo("backup1"); assertThat(backup.getKinds()).containsExactly("one", "two", "three"); assertThat(backup.getStartTime()).isEqualTo(startTime); - assertThat(backup.getCompleteTime()).isAbsent(); - assertThat(backup.getGcsFilename()).isAbsent(); + assertThat(backup.getCompleteTime()).isEmpty(); + assertThat(backup.getGcsFilename()).isEmpty(); assertThat(backup.getStatus()).isEqualTo(BackupStatus.PENDING); clock.setTo(startTime.plusMinutes(1)); diff --git a/javatests/google/registry/export/DatastoreBackupServiceTest.java b/javatests/google/registry/export/DatastoreBackupServiceTest.java index 0bdffbae5..10d60d51e 100644 --- a/javatests/google/registry/export/DatastoreBackupServiceTest.java +++ b/javatests/google/registry/export/DatastoreBackupServiceTest.java @@ -17,6 +17,7 @@ package google.registry.export; import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/javatests/google/registry/export/ExportConstantsTest.java b/javatests/google/registry/export/ExportConstantsTest.java index aaccc9639..56bc4d1c6 100644 --- a/javatests/google/registry/export/ExportConstantsTest.java +++ b/javatests/google/registry/export/ExportConstantsTest.java @@ -19,6 +19,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.io.Resources.getResource; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.ExportConstants.getBackupKinds; import static google.registry.export.ExportConstants.getReportingKinds; import static google.registry.util.ResourceUtils.readResourceUtf8; diff --git a/javatests/google/registry/export/ExportDomainListsActionTest.java b/javatests/google/registry/export/ExportDomainListsActionTest.java index 2f02656a5..1b6a34be3 100644 --- a/javatests/google/registry/export/ExportDomainListsActionTest.java +++ b/javatests/google/registry/export/ExportDomainListsActionTest.java @@ -17,6 +17,7 @@ package google.registry.export; import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication; diff --git a/javatests/google/registry/export/ExportReservedTermsActionTest.java b/javatests/google/registry/export/ExportReservedTermsActionTest.java index 5c4db7010..87e071886 100644 --- a/javatests/google/registry/export/ExportReservedTermsActionTest.java +++ b/javatests/google/registry/export/ExportReservedTermsActionTest.java @@ -16,6 +16,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE; import static google.registry.export.ExportReservedTermsAction.RESERVED_TERMS_FILENAME; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/export/ExportSnapshotActionTest.java b/javatests/google/registry/export/ExportSnapshotActionTest.java index e5ae3c060..c34731212 100644 --- a/javatests/google/registry/export/ExportSnapshotActionTest.java +++ b/javatests/google/registry/export/ExportSnapshotActionTest.java @@ -15,6 +15,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_KINDS_TO_LOAD_PARAM; import static google.registry.export.CheckSnapshotAction.CHECK_SNAPSHOT_NAME_PARAM; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; diff --git a/javatests/google/registry/export/ExportUtilsTest.java b/javatests/google/registry/export/ExportUtilsTest.java index c5fc5a65c..651f8e8b5 100644 --- a/javatests/google/registry/export/ExportUtilsTest.java +++ b/javatests/google/registry/export/ExportUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistReservedList; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/export/LoadSnapshotActionTest.java b/javatests/google/registry/export/LoadSnapshotActionTest.java index a2eb35f6a..55df4cb06 100644 --- a/javatests/google/registry/export/LoadSnapshotActionTest.java +++ b/javatests/google/registry/export/LoadSnapshotActionTest.java @@ -16,6 +16,7 @@ package google.registry.export; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.LoadSnapshotAction.LOAD_SNAPSHOT_FILE_PARAM; import static google.registry.export.LoadSnapshotAction.LOAD_SNAPSHOT_ID_PARAM; import static google.registry.export.LoadSnapshotAction.LOAD_SNAPSHOT_KINDS_PARAM; diff --git a/javatests/google/registry/export/PublishDetailReportActionTest.java b/javatests/google/registry/export/PublishDetailReportActionTest.java index ccd5c1b3f..380271495 100644 --- a/javatests/google/registry/export/PublishDetailReportActionTest.java +++ b/javatests/google/registry/export/PublishDetailReportActionTest.java @@ -15,6 +15,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.PublishDetailReportAction.DETAIL_REPORT_NAME_PARAM; import static google.registry.export.PublishDetailReportAction.GCS_BUCKET_PARAM; import static google.registry.export.PublishDetailReportAction.GCS_FOLDER_PREFIX_PARAM; diff --git a/javatests/google/registry/export/SyncGroupMembersActionTest.java b/javatests/google/registry/export/SyncGroupMembersActionTest.java index 13aa2e08e..a8c0b68f6 100644 --- a/javatests/google/registry/export/SyncGroupMembersActionTest.java +++ b/javatests/google/registry/export/SyncGroupMembersActionTest.java @@ -15,6 +15,7 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.SyncGroupMembersAction.getGroupEmailAddressForContactType; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registrar.RegistrarContact.Type.ADMIN; diff --git a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java index a28be2a92..47da39d15 100644 --- a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java +++ b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java @@ -16,6 +16,7 @@ package google.registry.export; import static com.google.appengine.api.taskqueue.QueueFactory.getQueue; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.export.UpdateSnapshotViewAction.QUEUE; import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_DATASET_ID_PARAM; import static google.registry.export.UpdateSnapshotViewAction.UPDATE_SNAPSHOT_KIND_PARAM; diff --git a/javatests/google/registry/export/sheet/BUILD b/javatests/google/registry/export/sheet/BUILD index b5f32c4f2..0b19b52df 100644 --- a/javatests/google/registry/export/sheet/BUILD +++ b/javatests/google/registry/export/sheet/BUILD @@ -14,10 +14,11 @@ java_library( "//java/google/registry/model", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_apis_google_api_services_sheets", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/export/sheet/SyncRegistrarsSheetActionTest.java b/javatests/google/registry/export/sheet/SyncRegistrarsSheetActionTest.java index 436d24a25..3210c4df8 100644 --- a/javatests/google/registry/export/sheet/SyncRegistrarsSheetActionTest.java +++ b/javatests/google/registry/export/sheet/SyncRegistrarsSheetActionTest.java @@ -16,6 +16,7 @@ package google.registry.export.sheet; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -23,10 +24,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeLockHandler; import google.registry.testing.FakeResponse; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.time.Duration; import org.junit.Before; @@ -51,8 +52,8 @@ public class SyncRegistrarsSheetActionTest { private SyncRegistrarsSheetAction action; private void runAction(@Nullable String idConfig, @Nullable String idParam) { - action.idConfig = Optional.fromNullable(idConfig); - action.idParam = Optional.fromNullable(idParam); + action.idConfig = Optional.ofNullable(idConfig); + action.idParam = Optional.ofNullable(idParam); action.run(); } diff --git a/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java b/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java index 9c12f66b1..6c5c77b3a 100644 --- a/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java +++ b/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java @@ -16,6 +16,7 @@ package google.registry.export.sheet; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getDefaultRegistrarReferralUrl; import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer; import static google.registry.model.common.Cursor.CursorType.SYNC_REGISTRAR_SHEET; diff --git a/javatests/google/registry/flows/BUILD b/javatests/google/registry/flows/BUILD index bb8b43418..794f455f1 100644 --- a/javatests/google/registry/flows/BUILD +++ b/javatests/google/registry/flows/BUILD @@ -40,7 +40,6 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/xml", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_testing", "@com_google_code_findbugs_jsr305", @@ -48,6 +47,8 @@ java_library( "@com_google_guava", "@com_google_guava_testlib", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_servlet_api", "@joda_time", diff --git a/javatests/google/registry/flows/CheckApiActionTest.java b/javatests/google/registry/flows/CheckApiActionTest.java index 8029d5a68..5e78899c1 100644 --- a/javatests/google/registry/flows/CheckApiActionTest.java +++ b/javatests/google/registry/flows/CheckApiActionTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistActiveDomain; diff --git a/javatests/google/registry/flows/EppCommitLogsTest.java b/javatests/google/registry/flows/EppCommitLogsTest.java index ae4f2913b..1c37db0b7 100644 --- a/javatests/google/registry/flows/EppCommitLogsTest.java +++ b/javatests/google/registry/flows/EppCommitLogsTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadAtPointInTime; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/EppConsoleActionTest.java b/javatests/google/registry/flows/EppConsoleActionTest.java index dc1938810..1da9a7667 100644 --- a/javatests/google/registry/flows/EppConsoleActionTest.java +++ b/javatests/google/registry/flows/EppConsoleActionTest.java @@ -14,8 +14,10 @@ package google.registry.flows; + import static com.google.appengine.api.users.UserServiceFactory.getUserService; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; diff --git a/javatests/google/registry/flows/EppControllerTest.java b/javatests/google/registry/flows/EppControllerTest.java index 74af55074..eb4a770ea 100644 --- a/javatests/google/registry/flows/EppControllerTest.java +++ b/javatests/google/registry/flows/EppControllerTest.java @@ -16,6 +16,7 @@ package google.registry.flows; import static com.google.common.io.BaseEncoding.base64; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.marshal; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.LogsSubject.assertAboutLogs; diff --git a/javatests/google/registry/flows/EppLifecycleHostTest.java b/javatests/google/registry/flows/EppLifecycleHostTest.java index 0a7218ecf..3f9e06692 100644 --- a/javatests/google/registry/flows/EppLifecycleHostTest.java +++ b/javatests/google/registry/flows/EppLifecycleHostTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; diff --git a/javatests/google/registry/flows/EppLoginTlsTest.java b/javatests/google/registry/flows/EppLoginTlsTest.java index 0f38442b2..149b543da 100644 --- a/javatests/google/registry/flows/EppLoginTlsTest.java +++ b/javatests/google/registry/flows/EppLoginTlsTest.java @@ -18,9 +18,9 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static org.joda.time.DateTimeZone.UTC; -import com.google.common.base.Optional; import google.registry.testing.AppEngineRule; import google.registry.testing.CertificateSamples; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; diff --git a/javatests/google/registry/flows/EppTlsActionTest.java b/javatests/google/registry/flows/EppTlsActionTest.java index b911f28a4..129abbdbe 100644 --- a/javatests/google/registry/flows/EppTlsActionTest.java +++ b/javatests/google/registry/flows/EppTlsActionTest.java @@ -16,6 +16,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.same; diff --git a/javatests/google/registry/flows/EppToolActionTest.java b/javatests/google/registry/flows/EppToolActionTest.java index f290e2a37..38b19d9cc 100644 --- a/javatests/google/registry/flows/EppToolActionTest.java +++ b/javatests/google/registry/flows/EppToolActionTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.isA; diff --git a/javatests/google/registry/flows/EppXmlTransformerTest.java b/javatests/google/registry/flows/EppXmlTransformerTest.java index b0ff472bd..48108f588 100644 --- a/javatests/google/registry/flows/EppXmlTransformerTest.java +++ b/javatests/google/registry/flows/EppXmlTransformerTest.java @@ -16,6 +16,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.unmarshal; import static google.registry.util.ResourceUtils.readResourceBytes; diff --git a/javatests/google/registry/flows/ExtensionManagerTest.java b/javatests/google/registry/flows/ExtensionManagerTest.java index 312f6b736..0625a92a1 100644 --- a/javatests/google/registry/flows/ExtensionManagerTest.java +++ b/javatests/google/registry/flows/ExtensionManagerTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/flows/FlowReporterTest.java b/javatests/google/registry/flows/FlowReporterTest.java index 8591b5c6d..84633d7b8 100644 --- a/javatests/google/registry/flows/FlowReporterTest.java +++ b/javatests/google/registry/flows/FlowReporterTest.java @@ -16,13 +16,13 @@ package google.registry.flows; import static com.google.common.io.BaseEncoding.base64; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static google.registry.testing.TestLogHandlerUtils.findFirstLogMessageByPrefix; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.testing.TestLogHandler; @@ -34,6 +34,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.testing.ShardableTestCase; import java.util.Map; +import java.util.Optional; import java.util.logging.Logger; import org.json.simple.JSONValue; import org.junit.Before; @@ -139,7 +140,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.absent()); + when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.empty()); flowReporter.recordToLogs(); Map json = parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-METADATA: ")); @@ -179,7 +180,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.absent()); + 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(); diff --git a/javatests/google/registry/flows/FlowRunnerTest.java b/javatests/google/registry/flows/FlowRunnerTest.java index 4a41d66a5..5280909bf 100644 --- a/javatests/google/registry/flows/FlowRunnerTest.java +++ b/javatests/google/registry/flows/FlowRunnerTest.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static google.registry.testing.TestLogHandlerUtils.findFirstLogMessageByPrefix; import static java.nio.charset.StandardCharsets.UTF_8; @@ -24,7 +25,6 @@ import static org.mockito.Mockito.verify; import com.google.appengine.api.users.User; import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -39,6 +39,7 @@ import google.registry.testing.FakeHttpSession; import google.registry.testing.Providers; import google.registry.testing.ShardableTestCase; import java.util.List; +import java.util.Optional; import java.util.logging.Logger; import org.junit.Before; import org.junit.Rule; diff --git a/javatests/google/registry/flows/FlowTestCase.java b/javatests/google/registry/flows/FlowTestCase.java index 7ccfca824..b59644eaf 100644 --- a/javatests/google/registry/flows/FlowTestCase.java +++ b/javatests/google/registry/flows/FlowTestCase.java @@ -18,6 +18,7 @@ import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Sets.difference; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.marshal; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.BILLING_EVENT_ID_STRIPPER; diff --git a/javatests/google/registry/flows/ResourceCheckFlowTestCase.java b/javatests/google/registry/flows/ResourceCheckFlowTestCase.java index 309fc4b33..31937dba1 100644 --- a/javatests/google/registry/flows/ResourceCheckFlowTestCase.java +++ b/javatests/google/registry/flows/ResourceCheckFlowTestCase.java @@ -15,6 +15,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import google.registry.model.EppResource; diff --git a/javatests/google/registry/flows/ResourceFlowTestCase.java b/javatests/google/registry/flows/ResourceFlowTestCase.java index 83a4e0740..076561904 100644 --- a/javatests/google/registry/flows/ResourceFlowTestCase.java +++ b/javatests/google/registry/flows/ResourceFlowTestCase.java @@ -16,6 +16,7 @@ package google.registry.flows; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard; diff --git a/javatests/google/registry/flows/TlsCredentialsTest.java b/javatests/google/registry/flows/TlsCredentialsTest.java index 94d43c957..1b9eed855 100644 --- a/javatests/google/registry/flows/TlsCredentialsTest.java +++ b/javatests/google/registry/flows/TlsCredentialsTest.java @@ -15,13 +15,13 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import google.registry.request.HttpException.BadRequestException; import google.registry.testing.ExceptionRule; import javax.servlet.http.HttpServletRequest; - import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java index 0108c6b33..4e47f6c71 100644 --- a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.contact; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.isDeleted; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/contact/ContactTransferApproveFlowTest.java b/javatests/google/registry/flows/contact/ContactTransferApproveFlowTest.java index a841d62b9..b7594f206 100644 --- a/javatests/google/registry/flows/contact/ContactTransferApproveFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactTransferApproveFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.contact; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/contact/ContactTransferCancelFlowTest.java b/javatests/google/registry/flows/contact/ContactTransferCancelFlowTest.java index 563cfe246..ef878ee1c 100644 --- a/javatests/google/registry/flows/contact/ContactTransferCancelFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactTransferCancelFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.contact; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.deleteResource; diff --git a/javatests/google/registry/flows/contact/ContactTransferRejectFlowTest.java b/javatests/google/registry/flows/contact/ContactTransferRejectFlowTest.java index 00d767cbb..8b05a00e8 100644 --- a/javatests/google/registry/flows/contact/ContactTransferRejectFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactTransferRejectFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.contact; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.deleteResource; diff --git a/javatests/google/registry/flows/contact/ContactTransferRequestFlowTest.java b/javatests/google/registry/flows/contact/ContactTransferRequestFlowTest.java index d68d84c7f..01e1319bd 100644 --- a/javatests/google/registry/flows/contact/ContactTransferRequestFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactTransferRequestFlowTest.java @@ -19,6 +19,7 @@ import static com.google.common.base.Predicates.not; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getContactAutomaticTransferLength; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.ContactResourceSubject.assertAboutContacts; diff --git a/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java b/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java index f76e41af8..a53309e18 100644 --- a/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.domain; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadDomainApplication; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.assertBillingEvents; diff --git a/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java index 9a071c23e..1ae33918c 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java @@ -18,6 +18,7 @@ import static com.google.common.collect.Iterables.getLast; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; diff --git a/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java index 69d41b6cb..6dc13433c 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.isLinked; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey; diff --git a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java index 317111e3f..c47092c1f 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java @@ -14,7 +14,6 @@ package google.registry.flows.domain; -import static com.google.common.base.Predicates.equalTo; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -26,7 +25,6 @@ import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -343,9 +341,11 @@ public class DomainApplicationInfoFlowTest keys.stream() .map(KEY_TO_KIND_FUNCTION) .anyMatch( - Predicates.or( - equalTo(Key.getKind(ContactResource.class)), - equalTo(Key.getKind(HostResource.class))))) + kind -> + ImmutableSet.of( + Key.getKind(ContactResource.class), + Key.getKind(HostResource.class)) + .contains(kind))) .count(); assertThat(numReadsWithContactsOrHosts).isEqualTo(1); } diff --git a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java index 09c90be73..1e371ee1e 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java @@ -17,6 +17,7 @@ package google.registry.flows.domain; import static com.google.common.collect.Sets.union; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index 4ecbef0f8..fd2c6d48f 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -17,6 +17,7 @@ package google.registry.flows.domain; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS; import static google.registry.model.eppcommon.StatusValue.OK; import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED; diff --git a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java index fc670efad..b9d25f5af 100644 --- a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.domain; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; diff --git a/javatests/google/registry/flows/domain/DomainInfoFlowTest.java b/javatests/google/registry/flows/domain/DomainInfoFlowTest.java index 36fed8ce3..a24fe683a 100644 --- a/javatests/google/registry/flows/domain/DomainInfoFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainInfoFlowTest.java @@ -14,7 +14,6 @@ package google.registry.flows.domain; -import static com.google.common.base.Predicates.equalTo; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -27,7 +26,6 @@ import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; @@ -648,9 +646,11 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase + ImmutableSet.of( + Key.getKind(ContactResource.class), + Key.getKind(HostResource.class)) + .contains(kind))) .count(); assertThat(numReadsWithContactsOrHosts).isEqualTo(1); } diff --git a/javatests/google/registry/flows/domain/DomainRenewFlowTest.java b/javatests/google/registry/flows/domain/DomainRenewFlowTest.java index 10830ce91..ab32a1e17 100644 --- a/javatests/google/registry/flows/domain/DomainRenewFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainRenewFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.assertBillingEvents; diff --git a/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java b/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java index c54ce0a64..36f745048 100644 --- a/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java index 433e360db..c88869a99 100644 --- a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.domain; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_ADDS_4_YR; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; diff --git a/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java index c027e754b..2832f16ba 100644 --- a/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.RESTORED_DOMAINS; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE; diff --git a/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java b/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java index 5743ab32d..c2641cca5 100644 --- a/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java +++ b/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java @@ -16,6 +16,7 @@ package google.registry.flows.domain; import static com.google.common.base.Preconditions.checkState; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.createBillingEventForTransfer; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java index 3e395316d..36d10a3a5 100644 --- a/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.getPollMessages; diff --git a/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java index 6d413e21f..82f510eb3 100644 --- a/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.domain; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_RENEWS_3_YR; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_NACKED; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; diff --git a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java index aeb729e0f..02b99a9cf 100644 --- a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -14,7 +14,6 @@ package google.registry.flows.domain; -import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -35,13 +34,13 @@ import static google.registry.testing.DomainResourceSubject.assertAboutDomains; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.HostResourceSubject.assertAboutHosts; import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static java.util.stream.Collectors.toSet; import static org.joda.money.CurrencyUnit.EUR; import static org.joda.money.CurrencyUnit.USD; +import com.google.appengine.repackaged.com.google.common.collect.Sets; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.base.Predicates; -import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -87,6 +86,8 @@ import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferStatus; import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Stream; import org.joda.money.Money; import org.joda.time.DateTime; @@ -269,13 +270,13 @@ public class DomainTransferRequestFlowTest .setBillingTime( implicitTransferTime.plus(registry.getTransferGracePeriodLength())) .setClientId("NewRegistrar") - .setCost(transferCost.or(Money.of(USD, 11))) + .setCost(transferCost.orElse(Money.of(USD, 11))) .setPeriodYears(1) .setParent(historyEntryTransferRequest) .build()); } else { // Superuser transfers with no bundled renewal have no transfer billing event. - optionalTransferBillingEvent = Optional.absent(); + optionalTransferBillingEvent = Optional.empty(); } // Construct the autorenew events for the losing/existing client and the gaining one. Note that // all of the other transfer flow tests happen on day 3 of the transfer, but the initial @@ -290,18 +291,17 @@ public class DomainTransferRequestFlowTest .setEventTime(expectedExpirationTime) .build(); // Construct extra billing events expected by the specific test. - ImmutableList extraBillingEvents = + Set extraBillingEvents = Stream.of(extraExpectedBillingEvents) .map( (Function) builder -> builder.setParent(historyEntryTransferRequest).build()) - .collect(toImmutableList()); - // Assert that the billing events we constructed above actually exist in datastore. - assertBillingEvents(FluentIterable.from(extraBillingEvents) - .append(optionalTransferBillingEvent.asSet()) - .append(losingClientAutorenew) - .append(gainingClientAutorenew) - .toArray(BillingEvent.class)); + .collect(toSet()); + // Assert that the billing events we constructed above actually exist in Datastore. + Set expectedBillingEvents = + Sets.newHashSet(losingClientAutorenew, gainingClientAutorenew); + optionalTransferBillingEvent.ifPresent(expectedBillingEvents::add); + assertBillingEvents(Sets.union(expectedBillingEvents, extraBillingEvents)); // Assert that the domain's TransferData server-approve billing events match the above. if (expectTransferBillingEvent) { assertBillingEventsEqual( @@ -315,16 +315,17 @@ public class DomainTransferRequestFlowTest gainingClientAutorenew); // Assert that the full set of server-approve billing events is exactly the extra ones plus // the transfer billing event (if present) and the gaining client autorenew. + Set expectedServeApproveBillingEvents = Sets.newHashSet(gainingClientAutorenew); + optionalTransferBillingEvent.ifPresent(expectedServeApproveBillingEvents::add); assertBillingEventsEqual( Iterables.filter( - ofy().load() + ofy() + .load() // Use toArray() to coerce the type to something keys() will accept. - .keys(domain.getTransferData().getServerApproveEntities().toArray(new Key[]{})) + .keys(domain.getTransferData().getServerApproveEntities().toArray(new Key[] {})) .values(), BillingEvent.class), - FluentIterable.from(extraBillingEvents) - .append(optionalTransferBillingEvent.asSet()) - .append(gainingClientAutorenew)); + Sets.union(expectedServeApproveBillingEvents, extraBillingEvents)); // The domain's autorenew billing event should still point to the losing client's event. BillingEvent.Recurring domainAutorenewEvent = ofy().load().key(domain.getAutorenewBillingEvent()).now(); @@ -469,7 +470,7 @@ public class DomainTransferRequestFlowTest expectedXmlFilename, expectedExpirationTime, ImmutableMap.of(), - Optional.absent(), + Optional.empty(), extraExpectedBillingEvents); } @@ -483,7 +484,7 @@ public class DomainTransferRequestFlowTest expectedXmlFilename, domain.getRegistrationExpirationTime().plusYears(1), substitutions, - Optional.absent()); + Optional.empty()); } private void doSuccessfulTest(String commandFilename, String expectedXmlFilename) @@ -755,7 +756,7 @@ public class DomainTransferRequestFlowTest "domain_transfer_request_response_su_ext_zero_period_nonzero_transfer_length.xml", domain.getRegistrationExpirationTime().plusYears(0), ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5"), - Optional.absent(), + Optional.empty(), Period.create(0, Unit.YEARS), Duration.standardDays(5)); } @@ -771,7 +772,7 @@ public class DomainTransferRequestFlowTest "domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml", domain.getRegistrationExpirationTime().plusYears(0), ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"), - Optional.absent(), + Optional.empty(), Period.create(0, Unit.YEARS), Duration.ZERO); } @@ -787,7 +788,7 @@ public class DomainTransferRequestFlowTest "domain_transfer_request_response_su_ext_one_year_period_nonzero_transfer_length.xml", domain.getRegistrationExpirationTime().plusYears(1), ImmutableMap.of("PERIOD", "1", "AUTOMATIC_TRANSFER_LENGTH", "5"), - Optional.absent(), + Optional.empty(), Period.create(1, Unit.YEARS), Duration.standardDays(5)); } @@ -817,7 +818,7 @@ public class DomainTransferRequestFlowTest "domain_transfer_request_response_su_ext_zero_period_autorenew_grace.xml", domain.getRegistrationExpirationTime(), ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"), - Optional.absent(), + Optional.empty(), Period.create(0, Unit.YEARS), Duration.ZERO); } @@ -1085,7 +1086,6 @@ public class DomainTransferRequestFlowTest doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_12_MAP); } - private void runWrongFeeAmountTest(Map substitutions) throws Exception { persistResource( Registry.get("tld") diff --git a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java index 929357b45..c8f999381 100644 --- a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -17,6 +17,7 @@ package google.registry.flows.domain; import static com.google.common.collect.Sets.union; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.assertBillingEvents; diff --git a/javatests/google/registry/flows/host/HostCreateFlowTest.java b/javatests/google/registry/flows/host/HostCreateFlowTest.java index 476dc15ad..269073081 100644 --- a/javatests/google/registry/flows/host/HostCreateFlowTest.java +++ b/javatests/google/registry/flows/host/HostCreateFlowTest.java @@ -15,6 +15,7 @@ package google.registry.flows.host; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/flows/host/HostFlowUtilsTest.java b/javatests/google/registry/flows/host/HostFlowUtilsTest.java index 8bcabfcf7..543044020 100644 --- a/javatests/google/registry/flows/host/HostFlowUtilsTest.java +++ b/javatests/google/registry/flows/host/HostFlowUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.flows.host; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.host.HostFlowUtils.validateHostName; import com.google.common.base.Strings; diff --git a/javatests/google/registry/flows/host/HostUpdateFlowTest.java b/javatests/google/registry/flows/host/HostUpdateFlowTest.java index 7900e5d00..6b7bbe49e 100644 --- a/javatests/google/registry/flows/host/HostUpdateFlowTest.java +++ b/javatests/google/registry/flows/host/HostUpdateFlowTest.java @@ -16,6 +16,7 @@ package google.registry.flows.host; import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.async.AsyncFlowEnqueuer.QUEUE_ASYNC_HOST_RENAME; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; diff --git a/javatests/google/registry/flows/session/LoginFlowViaTlsTest.java b/javatests/google/registry/flows/session/LoginFlowViaTlsTest.java index f185296a0..3717dad17 100644 --- a/javatests/google/registry/flows/session/LoginFlowViaTlsTest.java +++ b/javatests/google/registry/flows/session/LoginFlowViaTlsTest.java @@ -16,7 +16,6 @@ package google.registry.flows.session; import static google.registry.testing.DatastoreHelper.persistResource; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.net.InetAddresses; import google.registry.flows.TlsCredentials; @@ -27,6 +26,7 @@ import google.registry.flows.TlsCredentials.NoSniException; import google.registry.model.registrar.Registrar; import google.registry.testing.CertificateSamples; import google.registry.util.CidrAddressBlock; +import java.util.Optional; import org.junit.Test; /** Unit tests for {@link LoginFlow} when accessed via a TLS transport. */ @@ -116,7 +116,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase { CidrAddressBlock.create(InetAddresses.forString("192.168.1.1"), 32), CidrAddressBlock.create(InetAddresses.forString("2001:db8::1"), 128))) .build()); - credentials = new TlsCredentials(GOOD_CERT, Optional.absent(), "goo.example"); + credentials = new TlsCredentials(GOOD_CERT, Optional.empty(), "goo.example"); doFailingTest("login_valid.xml", BadRegistrarIpAddressException.class); } diff --git a/javatests/google/registry/groups/BUILD b/javatests/google/registry/groups/BUILD index 75c4243bc..e80912446 100644 --- a/javatests/google/registry/groups/BUILD +++ b/javatests/google/registry/groups/BUILD @@ -15,7 +15,6 @@ java_library( "//java/google/registry/groups", "//java/google/registry/model", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_api_client", "@com_google_apis_google_api_services_admin_directory", "@com_google_apis_google_api_services_groupssettings", @@ -25,6 +24,8 @@ java_library( "@com_google_guava", "@com_google_http_client", "@com_google_http_client_jackson2", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java index 83fbea313..df8de7270 100644 --- a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java +++ b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java @@ -15,6 +15,7 @@ package google.registry.groups; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.groups.DirectoryGroupsConnection.getDefaultGroupPermissions; import static javax.servlet.http.HttpServletResponse.SC_CONFLICT; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; diff --git a/javatests/google/registry/keyring/api/BUILD b/javatests/google/registry/keyring/api/BUILD index 8915a0d15..1b49d0997 100644 --- a/javatests/google/registry/keyring/api/BUILD +++ b/javatests/google/registry/keyring/api/BUILD @@ -13,8 +13,9 @@ java_library( deps = [ "//java/google/registry/keyring/api", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_bouncycastle_bcpg_jdk15on", "@org_bouncycastle_bcpkix_jdk15on", diff --git a/javatests/google/registry/keyring/api/ComparatorKeyringTest.java b/javatests/google/registry/keyring/api/ComparatorKeyringTest.java index db12dd9e8..18b630013 100644 --- a/javatests/google/registry/keyring/api/ComparatorKeyringTest.java +++ b/javatests/google/registry/keyring/api/ComparatorKeyringTest.java @@ -15,6 +15,7 @@ package google.registry.keyring.api; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.LogsSubject.assertAboutLogs; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; diff --git a/javatests/google/registry/keyring/api/KeySerializerTest.java b/javatests/google/registry/keyring/api/KeySerializerTest.java index 71e47c067..230edf864 100644 --- a/javatests/google/registry/keyring/api/KeySerializerTest.java +++ b/javatests/google/registry/keyring/api/KeySerializerTest.java @@ -15,6 +15,7 @@ package google.registry.keyring.api; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import google.registry.testing.BouncyCastleProviderRule; diff --git a/javatests/google/registry/keyring/kms/BUILD b/javatests/google/registry/keyring/kms/BUILD index 07c48534f..7fed01d4c 100644 --- a/javatests/google/registry/keyring/kms/BUILD +++ b/javatests/google/registry/keyring/kms/BUILD @@ -21,13 +21,14 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_api_client", "@com_google_apis_google_api_services_cloudkms", "@com_google_code_findbugs_jsr305", "@com_google_guava", "@com_google_http_client", "@com_google_http_client_jackson2", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_bouncycastle_bcpg_jdk15on", "@org_bouncycastle_bcpkix_jdk15on", diff --git a/javatests/google/registry/keyring/kms/KmsConnectionImplTest.java b/javatests/google/registry/keyring/kms/KmsConnectionImplTest.java index c752ca6ed..52ea5f5a2 100644 --- a/javatests/google/registry/keyring/kms/KmsConnectionImplTest.java +++ b/javatests/google/registry/keyring/kms/KmsConnectionImplTest.java @@ -15,6 +15,7 @@ package google.registry.keyring.kms; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; diff --git a/javatests/google/registry/keyring/kms/KmsKeyringTest.java b/javatests/google/registry/keyring/kms/KmsKeyringTest.java index 4a8025b55..d34ebd5c7 100644 --- a/javatests/google/registry/keyring/kms/KmsKeyringTest.java +++ b/javatests/google/registry/keyring/kms/KmsKeyringTest.java @@ -15,7 +15,9 @@ package google.registry.keyring.kms; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.persistResources; + import com.google.common.collect.ImmutableList; import google.registry.keyring.api.KeySerializer; import google.registry.model.server.KmsSecret; diff --git a/javatests/google/registry/keyring/kms/KmsUpdaterTest.java b/javatests/google/registry/keyring/kms/KmsUpdaterTest.java index 0592b591b..985d9bcfb 100644 --- a/javatests/google/registry/keyring/kms/KmsUpdaterTest.java +++ b/javatests/google/registry/keyring/kms/KmsUpdaterTest.java @@ -15,8 +15,10 @@ package google.registry.keyring.kms; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; + import com.googlecode.objectify.Key; import google.registry.keyring.api.KeySerializer; import google.registry.model.server.KmsSecret; diff --git a/javatests/google/registry/mapreduce/inputs/BUILD b/javatests/google/registry/mapreduce/inputs/BUILD index 202af68a6..8c53770b9 100644 --- a/javatests/google/registry/mapreduce/inputs/BUILD +++ b/javatests/google/registry/mapreduce/inputs/BUILD @@ -17,11 +17,12 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_testing", "@com_google_appengine_tools_appengine_mapreduce", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_joda_money", diff --git a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java index 7bb3ea64d..6ecdfa109 100644 --- a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java +++ b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java @@ -16,6 +16,7 @@ package google.registry.mapreduce.inputs; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.mapreduce.inputs.EppResourceInputs.createChildEntityInput; import static google.registry.model.index.EppResourceIndexBucket.getBucketKey; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/mapreduce/inputs/CommitLogManifestInputTest.java b/javatests/google/registry/mapreduce/inputs/CommitLogManifestInputTest.java index 158021fe2..d0ee6ffe1 100644 --- a/javatests/google/registry/mapreduce/inputs/CommitLogManifestInputTest.java +++ b/javatests/google/registry/mapreduce/inputs/CommitLogManifestInputTest.java @@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assert_; import com.google.appengine.tools.mapreduce.Input; import com.google.appengine.tools.mapreduce.InputReader; -import com.google.common.base.Optional; import com.googlecode.objectify.Key; import google.registry.model.ofy.CommitLogBucket; import google.registry.model.ofy.CommitLogManifest; @@ -58,8 +57,7 @@ public final class CommitLogManifestInputTest { created.add(createManifest(CommitLogBucket.getBucketKey(i), DATE_TIME_OLD)); } List> seen = new ArrayList<>(); - Input> input = - new CommitLogManifestInput(Optional.of(DATE_TIME_THRESHOLD)); + Input> input = new CommitLogManifestInput(DATE_TIME_THRESHOLD); for (InputReader> reader : input.createReaders()) { reader.beginShard(); @@ -84,8 +82,7 @@ public final class CommitLogManifestInputTest { old.add(createManifest(CommitLogBucket.getBucketKey(i), DATE_TIME_OLD2)); } List> seen = new ArrayList<>(); - Input> input = - new CommitLogManifestInput(Optional.of(DATE_TIME_THRESHOLD)); + Input> input = new CommitLogManifestInput(DATE_TIME_THRESHOLD); for (InputReader> reader : input.createReaders()) { reader.beginShard(); @@ -111,7 +108,7 @@ public final class CommitLogManifestInputTest { created.add(createManifest(CommitLogBucket.getBucketKey(i), DATE_TIME_OLD2)); } List> seen = new ArrayList<>(); - Input> input = new CommitLogManifestInput(Optional.absent()); + Input> input = new CommitLogManifestInput(); for (InputReader> reader : input.createReaders()) { reader.beginShard(); diff --git a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java index 1ea2866b5..bc765555a 100644 --- a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java +++ b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java @@ -16,6 +16,7 @@ package google.registry.mapreduce.inputs; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput; import static google.registry.mapreduce.inputs.EppResourceInputs.createKeyInput; import static google.registry.model.index.EppResourceIndexBucket.getBucketKey; diff --git a/javatests/google/registry/model/BUILD b/javatests/google/registry/model/BUILD index d464e6ba2..18b9339c0 100644 --- a/javatests/google/registry/model/BUILD +++ b/javatests/google/registry/model/BUILD @@ -29,12 +29,13 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/xml", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_testing", "@com_google_code_findbugs_jsr305", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_joda_money", diff --git a/javatests/google/registry/model/CreateAutoTimestampTest.java b/javatests/google/registry/model/CreateAutoTimestampTest.java index 8d17f34c3..ecf453c90 100644 --- a/javatests/google/registry/model/CreateAutoTimestampTest.java +++ b/javatests/google/registry/model/CreateAutoTimestampTest.java @@ -15,6 +15,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static org.joda.time.DateTimeZone.UTC; diff --git a/javatests/google/registry/model/EntityClassesTest.java b/javatests/google/registry/model/EntityClassesTest.java index 2754edeed..4d02afef6 100644 --- a/javatests/google/registry/model/EntityClassesTest.java +++ b/javatests/google/registry/model/EntityClassesTest.java @@ -16,6 +16,7 @@ package google.registry.model; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EntityClasses.ALL_CLASSES; import static google.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION; import static google.registry.util.TypeUtils.hasAnnotation; diff --git a/javatests/google/registry/model/EntityTestCase.java b/javatests/google/registry/model/EntityTestCase.java index 494e97e2a..f82e2675f 100644 --- a/javatests/google/registry/model/EntityTestCase.java +++ b/javatests/google/registry/model/EntityTestCase.java @@ -17,6 +17,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static org.joda.time.DateTimeZone.UTC; diff --git a/javatests/google/registry/model/EppResourceUtilsTest.java b/javatests/google/registry/model/EppResourceUtilsTest.java index 78bbb7c71..81475b341 100644 --- a/javatests/google/registry/model/EppResourceUtilsTest.java +++ b/javatests/google/registry/model/EppResourceUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadAtPointInTime; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newHostResource; diff --git a/javatests/google/registry/model/ImmutableObjectTest.java b/javatests/google/registry/model/ImmutableObjectTest.java index 7b31d1b68..6434923eb 100644 --- a/javatests/google/registry/model/ImmutableObjectTest.java +++ b/javatests/google/registry/model/ImmutableObjectTest.java @@ -18,6 +18,7 @@ import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Sets.newHashSet; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ImmutableObject.cloneEmptyToNull; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; diff --git a/javatests/google/registry/model/ModelUtilsTest.java b/javatests/google/registry/model/ModelUtilsTest.java index b8d71ed5f..5f3f97feb 100644 --- a/javatests/google/registry/model/ModelUtilsTest.java +++ b/javatests/google/registry/model/ModelUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.annotation.Id; diff --git a/javatests/google/registry/model/UpdateAutoTimestampTest.java b/javatests/google/registry/model/UpdateAutoTimestampTest.java index 61b8cd515..57f99e5ce 100644 --- a/javatests/google/registry/model/UpdateAutoTimestampTest.java +++ b/javatests/google/registry/model/UpdateAutoTimestampTest.java @@ -15,6 +15,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static org.joda.time.DateTimeZone.UTC; diff --git a/javatests/google/registry/model/billing/BillingEventTest.java b/javatests/google/registry/model/billing/BillingEventTest.java index afccfb5f2..7ab34c564 100644 --- a/javatests/google/registry/model/billing/BillingEventTest.java +++ b/javatests/google/registry/model/billing/BillingEventTest.java @@ -15,6 +15,7 @@ package google.registry.model.billing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveDomain; diff --git a/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java b/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java index 0359a617e..ae87e153a 100644 --- a/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java +++ b/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java @@ -15,6 +15,7 @@ package google.registry.model.billing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static org.joda.money.CurrencyUnit.USD; diff --git a/javatests/google/registry/model/billing/RegistrarBillingUtilsTest.java b/javatests/google/registry/model/billing/RegistrarBillingUtilsTest.java index 554c82da4..8bc0606d6 100644 --- a/javatests/google/registry/model/billing/RegistrarBillingUtilsTest.java +++ b/javatests/google/registry/model/billing/RegistrarBillingUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.model.billing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java b/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java index 68ccc4823..2ebc841ef 100644 --- a/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java +++ b/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java @@ -15,6 +15,7 @@ package google.registry.model.billing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; @@ -127,19 +128,19 @@ public class RegistrarCreditBalanceTest extends EntityTestCase { @Test public void testSuccess_balanceMap_getActiveBalance_emptyMap() throws Exception { BalanceMap map = new BalanceMap(ImmutableMap.>of()); - assertThat(map.getActiveBalanceAtTime(START_OF_TIME)).isAbsent(); - assertThat(map.getActiveBalanceAtTime(clock.nowUtc())).isAbsent(); - assertThat(map.getActiveBalanceAtTime(END_OF_TIME)).isAbsent(); - assertThat(map.getActiveBalanceBeforeTime(START_OF_TIME)).isAbsent(); - assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc())).isAbsent(); - assertThat(map.getActiveBalanceBeforeTime(END_OF_TIME)).isAbsent(); + assertThat(map.getActiveBalanceAtTime(START_OF_TIME)).isEmpty(); + assertThat(map.getActiveBalanceAtTime(clock.nowUtc())).isEmpty(); + assertThat(map.getActiveBalanceAtTime(END_OF_TIME)).isEmpty(); + assertThat(map.getActiveBalanceBeforeTime(START_OF_TIME)).isEmpty(); + assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc())).isEmpty(); + assertThat(map.getActiveBalanceBeforeTime(END_OF_TIME)).isEmpty(); } @Test public void testSuccess_balanceMap_getActiveBalanceAtTime() throws Exception { BalanceMap map = new BalanceMap(rawBalanceMap); - assertThat(map.getActiveBalanceAtTime(START_OF_TIME)).isAbsent(); - assertThat(map.getActiveBalanceAtTime(clock.nowUtc().minusMillis(1))).isAbsent(); + assertThat(map.getActiveBalanceAtTime(START_OF_TIME)).isEmpty(); + assertThat(map.getActiveBalanceAtTime(clock.nowUtc().minusMillis(1))).isEmpty(); assertThat(map.getActiveBalanceAtTime(clock.nowUtc()).get()).isEqualTo(Money.parse("USD 70")); assertThat(map.getActiveBalanceAtTime(clock.nowUtc().plusMillis(1)).get()) .isEqualTo(Money.parse("USD 70")); @@ -154,9 +155,9 @@ public class RegistrarCreditBalanceTest extends EntityTestCase { @Test public void testSuccess_balanceMap_getActiveBalanceBeforeTime() throws Exception { BalanceMap map = new BalanceMap(rawBalanceMap); - assertThat(map.getActiveBalanceBeforeTime(START_OF_TIME)).isAbsent(); - assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc().minusMillis(1))).isAbsent(); - assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc())).isAbsent(); + assertThat(map.getActiveBalanceBeforeTime(START_OF_TIME)).isEmpty(); + assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc().minusMillis(1))).isEmpty(); + assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc())).isEmpty(); assertThat(map.getActiveBalanceBeforeTime(clock.nowUtc().plusMillis(1)).get()) .isEqualTo(Money.parse("USD 70")); assertThat(map.getActiveBalanceBeforeTime(then.minusMillis(1)).get()) diff --git a/javatests/google/registry/model/billing/RegistrarCreditTest.java b/javatests/google/registry/model/billing/RegistrarCreditTest.java index a54d0c681..76667f9ed 100644 --- a/javatests/google/registry/model/billing/RegistrarCreditTest.java +++ b/javatests/google/registry/model/billing/RegistrarCreditTest.java @@ -15,6 +15,7 @@ package google.registry.model.billing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/common/CursorTest.java b/javatests/google/registry/model/common/CursorTest.java index c14e250bf..9865dfba1 100644 --- a/javatests/google/registry/model/common/CursorTest.java +++ b/javatests/google/registry/model/common/CursorTest.java @@ -15,6 +15,7 @@ package google.registry.model.common; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.Cursor.CursorType.BRDA; import static google.registry.model.common.Cursor.CursorType.RDE_UPLOAD; import static google.registry.model.common.Cursor.CursorType.RECURRING_BILLING; diff --git a/javatests/google/registry/model/common/GaeUserIdConverterTest.java b/javatests/google/registry/model/common/GaeUserIdConverterTest.java index 39e830899..9a8c48595 100644 --- a/javatests/google/registry/model/common/GaeUserIdConverterTest.java +++ b/javatests/google/registry/model/common/GaeUserIdConverterTest.java @@ -15,6 +15,7 @@ package google.registry.model.common; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import com.googlecode.objectify.VoidWork; diff --git a/javatests/google/registry/model/common/TimeOfYearTest.java b/javatests/google/registry/model/common/TimeOfYearTest.java index a03b24515..55c7c9852 100644 --- a/javatests/google/registry/model/common/TimeOfYearTest.java +++ b/javatests/google/registry/model/common/TimeOfYearTest.java @@ -15,6 +15,7 @@ package google.registry.model.common; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; diff --git a/javatests/google/registry/model/common/TimedTransitionPropertyTest.java b/javatests/google/registry/model/common/TimedTransitionPropertyTest.java index a0ba934ba..370a5b66d 100644 --- a/javatests/google/registry/model/common/TimedTransitionPropertyTest.java +++ b/javatests/google/registry/model/common/TimedTransitionPropertyTest.java @@ -15,6 +15,7 @@ package google.registry.model.common; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.TimedTransitionProperty.forMapify; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; diff --git a/javatests/google/registry/model/contact/ContactResourceTest.java b/javatests/google/registry/model/contact/ContactResourceTest.java index f43b9a473..d5c96d0c8 100644 --- a/javatests/google/registry/model/contact/ContactResourceTest.java +++ b/javatests/google/registry/model/contact/ContactResourceTest.java @@ -15,6 +15,7 @@ package google.registry.model.contact; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; diff --git a/javatests/google/registry/model/domain/DomainApplicationTest.java b/javatests/google/registry/model/domain/DomainApplicationTest.java index afad3a615..4c39ea1a1 100644 --- a/javatests/google/registry/model/domain/DomainApplicationTest.java +++ b/javatests/google/registry/model/domain/DomainApplicationTest.java @@ -15,6 +15,7 @@ package google.registry.model.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadDomainApplication; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/domain/DomainResourceTest.java b/javatests/google/registry/model/domain/DomainResourceTest.java index 5f1e55a7c..1b687ca6b 100644 --- a/javatests/google/registry/model/domain/DomainResourceTest.java +++ b/javatests/google/registry/model/domain/DomainResourceTest.java @@ -17,6 +17,7 @@ package google.registry.model.domain; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/domain/GracePeriodTest.java b/javatests/google/registry/model/domain/GracePeriodTest.java index 304371a3b..42a6aa03a 100644 --- a/javatests/google/registry/model/domain/GracePeriodTest.java +++ b/javatests/google/registry/model/domain/GracePeriodTest.java @@ -15,6 +15,7 @@ package google.registry.model.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.joda.time.DateTimeZone.UTC; import com.googlecode.objectify.Key; diff --git a/javatests/google/registry/model/domain/LrpTokenEntityTest.java b/javatests/google/registry/model/domain/LrpTokenEntityTest.java index 620410901..c4b04d8bd 100644 --- a/javatests/google/registry/model/domain/LrpTokenEntityTest.java +++ b/javatests/google/registry/model/domain/LrpTokenEntityTest.java @@ -15,6 +15,7 @@ package google.registry.model.domain; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication; diff --git a/javatests/google/registry/model/eppinput/EppInputTest.java b/javatests/google/registry/model/eppinput/EppInputTest.java index 5a562caad..6d1bac6ab 100644 --- a/javatests/google/registry/model/eppinput/EppInputTest.java +++ b/javatests/google/registry/model/eppinput/EppInputTest.java @@ -15,6 +15,7 @@ package google.registry.model.eppinput; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.unmarshal; import static google.registry.util.ResourceUtils.readResourceBytes; @@ -52,7 +53,7 @@ public class EppInputTest { assertThat(input.getCommandWrapper().getClTrid()).isEqualTo("ABC-12345"); assertThat(input.getCommandType()).isEqualTo("check"); assertThat(input.getResourceType()).hasValue("domain"); - assertThat(input.getSingleTargetId()).isAbsent(); + assertThat(input.getSingleTargetId()).isEmpty(); assertThat(input.getTargetIds()).containsExactly("example.com", "example.net", "example.org"); } @@ -62,8 +63,8 @@ public class EppInputTest { unmarshal(EppInput.class, readResourceBytes(getClass(), "testdata/login_valid.xml").read()); assertThat(input.getCommandWrapper().getClTrid()).isEqualTo("ABC-12345"); assertThat(input.getCommandType()).isEqualTo("login"); - assertThat(input.getResourceType()).isAbsent(); - assertThat(input.getSingleTargetId()).isAbsent(); + assertThat(input.getResourceType()).isEmpty(); + assertThat(input.getSingleTargetId()).isEmpty(); assertThat(input.getTargetIds()).isEmpty(); InnerCommand command = input.getCommandWrapper().getCommand(); assertThat(command).isInstanceOf(Login.class); diff --git a/javatests/google/registry/model/eppoutput/ResultTest.java b/javatests/google/registry/model/eppoutput/ResultTest.java index 1960c8ca4..69ec8f736 100644 --- a/javatests/google/registry/model/eppoutput/ResultTest.java +++ b/javatests/google/registry/model/eppoutput/ResultTest.java @@ -15,6 +15,7 @@ package google.registry.model.eppoutput; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/model/host/HostResourceTest.java b/javatests/google/registry/model/host/HostResourceTest.java index b67395a4c..e50640064 100644 --- a/javatests/google/registry/model/host/HostResourceTest.java +++ b/javatests/google/registry/model/host/HostResourceTest.java @@ -15,6 +15,7 @@ package google.registry.model.host; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/index/DomainApplicationIndexTest.java b/javatests/google/registry/model/index/DomainApplicationIndexTest.java index 239dec05e..3d475c996 100644 --- a/javatests/google/registry/model/index/DomainApplicationIndexTest.java +++ b/javatests/google/registry/model/index/DomainApplicationIndexTest.java @@ -15,6 +15,7 @@ package google.registry.model.index; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.index.DomainApplicationIndex.createUpdatedInstance; import static google.registry.model.index.DomainApplicationIndex.createWithSpecifiedKeys; import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName; diff --git a/javatests/google/registry/model/index/EppResourceIndexTest.java b/javatests/google/registry/model/index/EppResourceIndexTest.java index b3b3085fd..326daa4f6 100644 --- a/javatests/google/registry/model/index/EppResourceIndexTest.java +++ b/javatests/google/registry/model/index/EppResourceIndexTest.java @@ -15,6 +15,7 @@ package google.registry.model.index; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/index/ForeignKeyIndexTest.java b/javatests/google/registry/model/index/ForeignKeyIndexTest.java index 6bf83216b..993d27360 100644 --- a/javatests/google/registry/model/index/ForeignKeyIndexTest.java +++ b/javatests/google/registry/model/index/ForeignKeyIndexTest.java @@ -15,6 +15,7 @@ package google.registry.model.index; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveHost; diff --git a/javatests/google/registry/model/mark/MarkContactTest.java b/javatests/google/registry/model/mark/MarkContactTest.java index 7f7f99e42..7864849b7 100644 --- a/javatests/google/registry/model/mark/MarkContactTest.java +++ b/javatests/google/registry/model/mark/MarkContactTest.java @@ -15,6 +15,7 @@ package google.registry.model.mark; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/model/mark/MarkHolderTest.java b/javatests/google/registry/model/mark/MarkHolderTest.java index 9836801b2..8720f6f24 100644 --- a/javatests/google/registry/model/mark/MarkHolderTest.java +++ b/javatests/google/registry/model/mark/MarkHolderTest.java @@ -15,6 +15,7 @@ package google.registry.model.mark; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/model/mark/MarkProtectionTest.java b/javatests/google/registry/model/mark/MarkProtectionTest.java index 844cbd6c6..096d2b7f1 100644 --- a/javatests/google/registry/model/mark/MarkProtectionTest.java +++ b/javatests/google/registry/model/mark/MarkProtectionTest.java @@ -15,6 +15,7 @@ package google.registry.model.mark; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import org.junit.Test; diff --git a/javatests/google/registry/model/ofy/CommitLogBucketTest.java b/javatests/google/registry/model/ofy/CommitLogBucketTest.java index 8cef3624d..799218b5a 100644 --- a/javatests/google/registry/model/ofy/CommitLogBucketTest.java +++ b/javatests/google/registry/model/ofy/CommitLogBucketTest.java @@ -15,6 +15,7 @@ package google.registry.model.ofy; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.CommitLogBucket.getBucketKey; import static google.registry.model.ofy.CommitLogBucket.loadAllBuckets; import static google.registry.model.ofy.CommitLogBucket.loadBucket; diff --git a/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java b/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java index 4cdf4e848..d54200ebe 100644 --- a/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java +++ b/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java @@ -15,6 +15,7 @@ package google.registry.model.ofy; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.time.DateTimeZone.UTC; diff --git a/javatests/google/registry/model/ofy/CommitLogMutationTest.java b/javatests/google/registry/model/ofy/CommitLogMutationTest.java index ef7f29afb..8af579d1a 100644 --- a/javatests/google/registry/model/ofy/CommitLogMutationTest.java +++ b/javatests/google/registry/model/ofy/CommitLogMutationTest.java @@ -15,6 +15,7 @@ package google.registry.model.ofy; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/model/ofy/OfyCommitLogTest.java b/javatests/google/registry/model/ofy/OfyCommitLogTest.java index 7518aa3d2..e3202a703 100644 --- a/javatests/google/registry/model/ofy/OfyCommitLogTest.java +++ b/javatests/google/registry/model/ofy/OfyCommitLogTest.java @@ -16,6 +16,7 @@ package google.registry.model.ofy; import static com.google.appengine.api.datastore.EntityTranslator.convertToPb; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static com.googlecode.objectify.ObjectifyService.register; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.CommitLogBucket.getBucketKey; diff --git a/javatests/google/registry/model/ofy/OfyFilterTest.java b/javatests/google/registry/model/ofy/OfyFilterTest.java index cfc0104c6..18fefdaec 100644 --- a/javatests/google/registry/model/ofy/OfyFilterTest.java +++ b/javatests/google/registry/model/ofy/OfyFilterTest.java @@ -15,6 +15,7 @@ package google.registry.model.ofy; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.initOfy; import static google.registry.testing.DatastoreHelper.newContactResource; import static org.junit.Assert.fail; diff --git a/javatests/google/registry/model/ofy/OfyTest.java b/javatests/google/registry/model/ofy/OfyTest.java index 11a1650c3..c39448db2 100644 --- a/javatests/google/registry/model/ofy/OfyTest.java +++ b/javatests/google/registry/model/ofy/OfyTest.java @@ -16,6 +16,7 @@ package google.registry.model.ofy; import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; diff --git a/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java b/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java index 86b6cd80c..fa52b9848 100644 --- a/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java +++ b/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java @@ -15,6 +15,7 @@ package google.registry.model.poll; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveDomain; diff --git a/javatests/google/registry/model/poll/PollMessageTest.java b/javatests/google/registry/model/poll/PollMessageTest.java index 90c2b41d9..432af8c4c 100644 --- a/javatests/google/registry/model/poll/PollMessageTest.java +++ b/javatests/google/registry/model/poll/PollMessageTest.java @@ -15,6 +15,7 @@ package google.registry.model.poll; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveDomain; diff --git a/javatests/google/registry/model/rde/RdeNamingUtilsTest.java b/javatests/google/registry/model/rde/RdeNamingUtilsTest.java index 9534a1b34..c338fe427 100644 --- a/javatests/google/registry/model/rde/RdeNamingUtilsTest.java +++ b/javatests/google/registry/model/rde/RdeNamingUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.model.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.rde.RdeMode.FULL; import static google.registry.model.rde.RdeMode.THIN; import static google.registry.model.rde.RdeNamingUtils.makePartialName; diff --git a/javatests/google/registry/model/rde/RdeRevisionTest.java b/javatests/google/registry/model/rde/RdeRevisionTest.java index 2c81ac6a8..577b9ac54 100644 --- a/javatests/google/registry/model/rde/RdeRevisionTest.java +++ b/javatests/google/registry/model/rde/RdeRevisionTest.java @@ -15,6 +15,7 @@ package google.registry.model.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.rde.RdeMode.FULL; import static google.registry.model.rde.RdeRevision.getNextRevision; diff --git a/javatests/google/registry/model/registrar/RegistrarTest.java b/javatests/google/registry/model/registrar/RegistrarTest.java index 45a1dbe70..1231aa7e0 100644 --- a/javatests/google/registry/model/registrar/RegistrarTest.java +++ b/javatests/google/registry/model/registrar/RegistrarTest.java @@ -15,6 +15,7 @@ package google.registry.model.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT2; diff --git a/javatests/google/registry/model/registry/RegistriesTest.java b/javatests/google/registry/model/registry/RegistriesTest.java index 98e95cc93..0ee0d29d1 100644 --- a/javatests/google/registry/model/registry/RegistriesTest.java +++ b/javatests/google/registry/model/registry/RegistriesTest.java @@ -15,6 +15,7 @@ package google.registry.model.registry; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; import com.google.common.net.InternetDomainName; @@ -72,13 +73,13 @@ public class RegistriesTest { assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b.c")).get().toString()) .isEqualTo("a.b.c"); // We don't have an "example" tld. - assertThat(Registries.findTldForName(InternetDomainName.from("foo.example"))).isAbsent(); + assertThat(Registries.findTldForName(InternetDomainName.from("foo.example"))).isEmpty(); // A tld is not a match for itself. - assertThat(Registries.findTldForName(InternetDomainName.from("foo"))).isAbsent(); + assertThat(Registries.findTldForName(InternetDomainName.from("foo"))).isEmpty(); // The name must match the entire tld. - assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b"))).isAbsent(); - assertThat(Registries.findTldForName(InternetDomainName.from("x.y.b.c"))).isAbsent(); + assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b"))).isEmpty(); + assertThat(Registries.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty(); // Substring tld matches aren't considered. - assertThat(Registries.findTldForName(InternetDomainName.from("example.barfoo"))).isAbsent(); + assertThat(Registries.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty(); } } diff --git a/javatests/google/registry/model/registry/RegistryTest.java b/javatests/google/registry/model/registry/RegistryTest.java index 04bc4f8da..3cc9e42c0 100644 --- a/javatests/google/registry/model/registry/RegistryTest.java +++ b/javatests/google/registry/model/registry/RegistryTest.java @@ -17,6 +17,7 @@ package google.registry.model.registry; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION; diff --git a/javatests/google/registry/model/registry/label/PremiumListTest.java b/javatests/google/registry/model/registry/label/PremiumListTest.java index 731674848..cc7e7669f 100644 --- a/javatests/google/registry/model/registry/label/PremiumListTest.java +++ b/javatests/google/registry/model/registry/label/PremiumListTest.java @@ -16,6 +16,7 @@ package google.registry.model.registry.label; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistPremiumList; diff --git a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java index 8762f256d..54dc884b3 100644 --- a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java +++ b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.model.registry.label; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.BLOOM_FILTER_NEGATIVE; import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_NEGATIVE; @@ -102,7 +103,7 @@ public class PremiumListUtilsTest { .setDnsWriters(ImmutableSet.of(VoidDnsWriter.NAME)) .build()); assertThat(Registry.get("ghost").getPremiumList()).isNull(); - assertThat(getPremiumPrice("blah", Registry.get("ghost"))).isAbsent(); + assertThat(getPremiumPrice("blah", Registry.get("ghost"))).isEmpty(); assertThat(premiumListChecks).hasNoOtherValues(); assertThat(premiumListProcessingTime).hasNoOtherValues(); } @@ -160,7 +161,7 @@ public class PremiumListUtilsTest { .build()); // "missingno" shouldn't be in the Bloom filter, thus it should return not premium without // attempting to load the entity that is actually present. - assertThat(getPremiumPrice("missingno", Registry.get("tld"))).isAbsent(); + assertThat(getPremiumPrice("missingno", Registry.get("tld"))).isEmpty(); // However, if we manually query the cache to force an entity load, it should be found. assertThat( PremiumList.cachePremiumListEntries.get( @@ -206,8 +207,8 @@ public class PremiumListUtilsTest { }); ofy().clearSessionCache(); - assertThat(getPremiumPrice("rich", Registry.get("tld"))).isAbsent(); - assertThat(getPremiumPrice("rich", Registry.get("tld"))).isAbsent(); + assertThat(getPremiumPrice("rich", Registry.get("tld"))).isEmpty(); + assertThat(getPremiumPrice("rich", Registry.get("tld"))).isEmpty(); assertThat(premiumListChecks) .hasValueForLabels(1, "tld", "tld", UNCACHED_NEGATIVE.toString()) @@ -241,7 +242,7 @@ public class PremiumListUtilsTest { savePremiumListAndEntries(pl, ImmutableList.of("genius,USD 10", "savant,USD 90")); assertThat(getPremiumPrice("genius", registry)).hasValue(Money.parse("USD 10")); assertThat(getPremiumPrice("savant", registry)).hasValue(Money.parse("USD 90")); - assertThat(getPremiumPrice("dolt", registry)).isAbsent(); + assertThat(getPremiumPrice("dolt", registry)).isEmpty(); assertThat(ofy() .load() .type(PremiumListEntry.class) @@ -272,8 +273,8 @@ public class PremiumListUtilsTest { @Test public void testGetPremiumPrice_allLabelsAreNonPremium_whenNotInList() throws Exception { - assertThat(getPremiumPrice("blah", Registry.get("tld"))).isAbsent(); - assertThat(getPremiumPrice("slinge", Registry.get("tld"))).isAbsent(); + assertThat(getPremiumPrice("blah", Registry.get("tld"))).isEmpty(); + assertThat(getPremiumPrice("slinge", Registry.get("tld"))).isEmpty(); assertMetricOutcomeCount(2, BLOOM_FILTER_NEGATIVE); } @@ -286,7 +287,7 @@ public class PremiumListUtilsTest { createTld("tld"); persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); assertThat(getPremiumPrice("lol", Registry.get("tld"))).hasValue(Money.parse("USD 999")); - assertThat(getPremiumPrice("lol ", Registry.get("tld"))).isAbsent(); + assertThat(getPremiumPrice("lol ", Registry.get("tld"))).isEmpty(); ImmutableMap entries = loadPremiumListEntries(PremiumList.get("tld2").get()); assertThat(entries.keySet()).containsExactly("lol"); @@ -333,7 +334,7 @@ public class PremiumListUtilsTest { assertThat(PremiumList.get("gtld1")).isPresent(); Key parent = PremiumList.get("gtld1").get().getRevisionKey(); deletePremiumList(PremiumList.get("gtld1").get()); - assertThat(PremiumList.get("gtld1")).isAbsent(); + assertThat(PremiumList.get("gtld1")).isEmpty(); assertThat(ofy().load().type(PremiumListEntry.class).ancestor(parent).list()).isEmpty(); } @@ -341,13 +342,7 @@ public class PremiumListUtilsTest { public void testDelete_largeNumberOfEntries_succeeds() { persistHumongousPremiumList("ginormous", 2500); deletePremiumList(PremiumList.get("ginormous").get()); - assertThat(PremiumList.get("ginormous")).isAbsent(); - } - - @Test - public void testDelete_failsWhenListDoesntExist() throws Exception { - thrown.expect(IllegalStateException.class); - deletePremiumList(PremiumList.get("tld-premium-blah").get()); + assertThat(PremiumList.get("ginormous")).isEmpty(); } /** Persists a premium list with a specified number of nonsense entries. */ diff --git a/javatests/google/registry/model/registry/label/ReservedListTest.java b/javatests/google/registry/model/registry/label/ReservedListTest.java index d112361ec..fa31c91e2 100644 --- a/javatests/google/registry/model/registry/label/ReservedListTest.java +++ b/javatests/google/registry/model/registry/label/ReservedListTest.java @@ -16,6 +16,7 @@ package google.registry.model.registry.label; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registry.label.DomainLabelMetrics.reservedListChecks; import static google.registry.model.registry.label.DomainLabelMetrics.reservedListHits; import static google.registry.model.registry.label.DomainLabelMetrics.reservedListProcessingTime; diff --git a/javatests/google/registry/model/reporting/HistoryEntryTest.java b/javatests/google/registry/model/reporting/HistoryEntryTest.java index 7e3309596..7f599453a 100644 --- a/javatests/google/registry/model/reporting/HistoryEntryTest.java +++ b/javatests/google/registry/model/reporting/HistoryEntryTest.java @@ -15,6 +15,7 @@ package google.registry.model.reporting; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newDomainResource; diff --git a/javatests/google/registry/model/server/KmsSecretRevisionTest.java b/javatests/google/registry/model/server/KmsSecretRevisionTest.java index 6547e9133..fb933cf5b 100644 --- a/javatests/google/registry/model/server/KmsSecretRevisionTest.java +++ b/javatests/google/registry/model/server/KmsSecretRevisionTest.java @@ -15,6 +15,7 @@ package google.registry.model.server; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/model/server/KmsSecretTest.java b/javatests/google/registry/model/server/KmsSecretTest.java index 834763cc0..ee520c7de 100644 --- a/javatests/google/registry/model/server/KmsSecretTest.java +++ b/javatests/google/registry/model/server/KmsSecretTest.java @@ -15,6 +15,7 @@ package google.registry.model.server; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/model/server/LockTest.java b/javatests/google/registry/model/server/LockTest.java index 8b7c72350..6733b9969 100644 --- a/javatests/google/registry/model/server/LockTest.java +++ b/javatests/google/registry/model/server/LockTest.java @@ -15,16 +15,17 @@ package google.registry.model.server; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineRule; import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.util.RequestStatusChecker; +import java.util.Optional; import org.joda.time.Duration; import org.junit.Before; import org.junit.Rule; @@ -66,7 +67,7 @@ public class LockTest { Optional lock = acquire("", ONE_DAY); assertThat(lock).isPresent(); // We can't get it again at the same time. - assertThat(acquire("", ONE_DAY)).isAbsent(); + assertThat(acquire("", ONE_DAY)).isEmpty(); // But if we release it, it's available. lock.get().release(); assertThat(acquire("", ONE_DAY)).isPresent(); @@ -78,10 +79,10 @@ public class LockTest { inject.setStaticField(Ofy.class, "clock", clock); assertThat(acquire("", TWO_MILLIS)).isPresent(); // We can't get it again at the same time. - assertThat(acquire("", TWO_MILLIS)).isAbsent(); + assertThat(acquire("", TWO_MILLIS)).isEmpty(); // A second later we still can't get the lock. clock.advanceOneMilli(); - assertThat(acquire("", TWO_MILLIS)).isAbsent(); + assertThat(acquire("", TWO_MILLIS)).isEmpty(); // But two seconds later we can get it. clock.advanceOneMilli(); assertThat(acquire("", TWO_MILLIS)).isPresent(); @@ -91,7 +92,7 @@ public class LockTest { public void testReleasedAfterRequestFinish() throws Exception { assertThat(acquire("", ONE_DAY)).isPresent(); // We can't get it again while request is active - assertThat(acquire("", ONE_DAY)).isAbsent(); + assertThat(acquire("", ONE_DAY)).isEmpty(); // But if request is finished, we can get it. when(requestStatusChecker.isRunning("current-request-id")).thenReturn(false); assertThat(acquire("", ONE_DAY)).isPresent(); @@ -105,10 +106,10 @@ public class LockTest { Optional lockB = acquire("b", ONE_DAY); assertThat(lockB).isPresent(); // We can't get lockB again at the same time. - assertThat(acquire("b", ONE_DAY)).isAbsent(); + assertThat(acquire("b", ONE_DAY)).isEmpty(); // Releasing lockA has no effect on lockB (even though we are still using the "b" tld). lockA.get().release(); - assertThat(acquire("b", ONE_DAY)).isAbsent(); + assertThat(acquire("b", ONE_DAY)).isEmpty(); } @Test diff --git a/javatests/google/registry/model/server/ServerSecretTest.java b/javatests/google/registry/model/server/ServerSecretTest.java index 8e701a679..ac17c73c1 100644 --- a/javatests/google/registry/model/server/ServerSecretTest.java +++ b/javatests/google/registry/model/server/ServerSecretTest.java @@ -15,6 +15,7 @@ package google.registry.model.server; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import google.registry.model.ofy.RequestCapturingAsyncDatastoreService; diff --git a/javatests/google/registry/model/smd/IssuerInfoTest.java b/javatests/google/registry/model/smd/IssuerInfoTest.java index 9bc997b14..0b8547df4 100644 --- a/javatests/google/registry/model/smd/IssuerInfoTest.java +++ b/javatests/google/registry/model/smd/IssuerInfoTest.java @@ -15,6 +15,7 @@ package google.registry.model.smd; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java b/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java index fb889d56c..9a3dd135e 100644 --- a/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java +++ b/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java @@ -15,6 +15,7 @@ package google.registry.model.smd; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.smd.SignedMarkRevocationList.SHARD_SIZE; import static google.registry.util.DateTimeUtils.START_OF_TIME; diff --git a/javatests/google/registry/model/tmch/ClaimsListShardTest.java b/javatests/google/registry/model/tmch/ClaimsListShardTest.java index e773d6a80..d35340a45 100644 --- a/javatests/google/registry/model/tmch/ClaimsListShardTest.java +++ b/javatests/google/registry/model/tmch/ClaimsListShardTest.java @@ -15,6 +15,7 @@ package google.registry.model.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.time.DateTimeZone.UTC; diff --git a/javatests/google/registry/model/tmch/TmchCrlTest.java b/javatests/google/registry/model/tmch/TmchCrlTest.java index 42860a688..797752730 100644 --- a/javatests/google/registry/model/tmch/TmchCrlTest.java +++ b/javatests/google/registry/model/tmch/TmchCrlTest.java @@ -15,6 +15,7 @@ package google.registry.model.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.AppEngineRule; import org.junit.Rule; diff --git a/javatests/google/registry/model/transfer/TransferDataTest.java b/javatests/google/registry/model/transfer/TransferDataTest.java index a7ef433f6..527cfc3e7 100644 --- a/javatests/google/registry/model/transfer/TransferDataTest.java +++ b/javatests/google/registry/model/transfer/TransferDataTest.java @@ -15,6 +15,7 @@ package google.registry.model.transfer; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java b/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java index 615ab6aab..f7d08ce5b 100644 --- a/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java +++ b/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java @@ -15,6 +15,7 @@ package google.registry.model.translators; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static org.joda.time.Duration.standardDays; import static org.joda.time.Duration.standardHours; diff --git a/javatests/google/registry/model/translators/StatusValueAdapterTest.java b/javatests/google/registry/model/translators/StatusValueAdapterTest.java index d703294b2..6e40fb9b1 100644 --- a/javatests/google/registry/model/translators/StatusValueAdapterTest.java +++ b/javatests/google/registry/model/translators/StatusValueAdapterTest.java @@ -15,6 +15,7 @@ package google.registry.model.translators; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/module/backend/BUILD b/javatests/google/registry/module/backend/BUILD index ec3bc65bf..aacb6920f 100644 --- a/javatests/google/registry/module/backend/BUILD +++ b/javatests/google/registry/module/backend/BUILD @@ -18,8 +18,9 @@ java_library( "//java/google/registry/request", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/module/frontend/BUILD b/javatests/google/registry/module/frontend/BUILD index d741fcc5d..cac2f35e6 100644 --- a/javatests/google/registry/module/frontend/BUILD +++ b/javatests/google/registry/module/frontend/BUILD @@ -17,8 +17,9 @@ java_library( "//java/google/registry/module/frontend", "//java/google/registry/request", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/module/tools/BUILD b/javatests/google/registry/module/tools/BUILD index 1b40da498..f2d581269 100644 --- a/javatests/google/registry/module/tools/BUILD +++ b/javatests/google/registry/module/tools/BUILD @@ -17,8 +17,9 @@ java_library( "//java/google/registry/module/tools", "//java/google/registry/request", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/monitoring/metrics/BUILD b/javatests/google/registry/monitoring/metrics/BUILD index 7d5bd4559..522ae8786 100644 --- a/javatests/google/registry/monitoring/metrics/BUILD +++ b/javatests/google/registry/monitoring/metrics/BUILD @@ -12,8 +12,9 @@ java_library( srcs = glob(["*.java"]), deps = [ "//java/google/registry/monitoring/metrics", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/monitoring/metrics/CounterTest.java b/javatests/google/registry/monitoring/metrics/CounterTest.java index 91d67f09a..7b0649365 100644 --- a/javatests/google/registry/monitoring/metrics/CounterTest.java +++ b/javatests/google/registry/monitoring/metrics/CounterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/monitoring/metrics/CustomFitterTest.java b/javatests/google/registry/monitoring/metrics/CustomFitterTest.java index a1d9ec4f6..19d94f28c 100644 --- a/javatests/google/registry/monitoring/metrics/CustomFitterTest.java +++ b/javatests/google/registry/monitoring/metrics/CustomFitterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; diff --git a/javatests/google/registry/monitoring/metrics/EventMetricTest.java b/javatests/google/registry/monitoring/metrics/EventMetricTest.java index 54143a503..4c21677aa 100644 --- a/javatests/google/registry/monitoring/metrics/EventMetricTest.java +++ b/javatests/google/registry/monitoring/metrics/EventMetricTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableRangeMap; diff --git a/javatests/google/registry/monitoring/metrics/ExponentialFitterTest.java b/javatests/google/registry/monitoring/metrics/ExponentialFitterTest.java index df80e9d7b..57f7535c2 100644 --- a/javatests/google/registry/monitoring/metrics/ExponentialFitterTest.java +++ b/javatests/google/registry/monitoring/metrics/ExponentialFitterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Rule; import org.junit.Test; diff --git a/javatests/google/registry/monitoring/metrics/FibonacciFitterTest.java b/javatests/google/registry/monitoring/metrics/FibonacciFitterTest.java index 7b2d57ade..f4f2eafee 100644 --- a/javatests/google/registry/monitoring/metrics/FibonacciFitterTest.java +++ b/javatests/google/registry/monitoring/metrics/FibonacciFitterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; diff --git a/javatests/google/registry/monitoring/metrics/LinearFitterTest.java b/javatests/google/registry/monitoring/metrics/LinearFitterTest.java index 8955029eb..fffacc230 100644 --- a/javatests/google/registry/monitoring/metrics/LinearFitterTest.java +++ b/javatests/google/registry/monitoring/metrics/LinearFitterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import org.junit.Rule; import org.junit.Test; diff --git a/javatests/google/registry/monitoring/metrics/MetricExporterTest.java b/javatests/google/registry/monitoring/metrics/MetricExporterTest.java index 98f097482..614c81d36 100644 --- a/javatests/google/registry/monitoring/metrics/MetricExporterTest.java +++ b/javatests/google/registry/monitoring/metrics/MetricExporterTest.java @@ -15,15 +15,16 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Service.State; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executors; @@ -44,7 +45,7 @@ public class MetricExporterTest { @Mock private MetricPoint point; private MetricExporter exporter; private BlockingQueue>>> writeQueue; - private final Optional>> poisonPill = Optional.absent(); + private final Optional>> poisonPill = Optional.empty(); private final Optional>> emptyBatch = Optional.of(ImmutableList.>of()); diff --git a/javatests/google/registry/monitoring/metrics/MetricRegistryImplTest.java b/javatests/google/registry/monitoring/metrics/MetricRegistryImplTest.java index f3d8542e6..dad3807be 100644 --- a/javatests/google/registry/monitoring/metrics/MetricRegistryImplTest.java +++ b/javatests/google/registry/monitoring/metrics/MetricRegistryImplTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import com.google.common.collect.ImmutableList; diff --git a/javatests/google/registry/monitoring/metrics/MetricReporterTest.java b/javatests/google/registry/monitoring/metrics/MetricReporterTest.java index 9b0022ffd..d72e0ebcd 100644 --- a/javatests/google/registry/monitoring/metrics/MetricReporterTest.java +++ b/javatests/google/registry/monitoring/metrics/MetricReporterTest.java @@ -18,9 +18,9 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ThreadFactory; import org.junit.Test; @@ -65,6 +65,6 @@ public class MetricReporterTest { verify(reporter).runOneIteration(); InOrder interactions = Mockito.inOrder(writeQueue); interactions.verify(writeQueue).offer(Optional.of(ImmutableList.>of())); - interactions.verify(writeQueue).offer(Optional.>>absent()); + interactions.verify(writeQueue).offer(Optional.>>empty()); } } diff --git a/javatests/google/registry/monitoring/metrics/MutableDistributionTest.java b/javatests/google/registry/monitoring/metrics/MutableDistributionTest.java index d87f75f42..847cdf72b 100644 --- a/javatests/google/registry/monitoring/metrics/MutableDistributionTest.java +++ b/javatests/google/registry/monitoring/metrics/MutableDistributionTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableRangeMap; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/monitoring/metrics/StoredMetricTest.java b/javatests/google/registry/monitoring/metrics/StoredMetricTest.java index b41c85b8a..86ead3a30 100644 --- a/javatests/google/registry/monitoring/metrics/StoredMetricTest.java +++ b/javatests/google/registry/monitoring/metrics/StoredMetricTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/monitoring/metrics/VirtualMetricTest.java b/javatests/google/registry/monitoring/metrics/VirtualMetricTest.java index a987f31a6..12218e9a5 100644 --- a/javatests/google/registry/monitoring/metrics/VirtualMetricTest.java +++ b/javatests/google/registry/monitoring/metrics/VirtualMetricTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; diff --git a/javatests/google/registry/monitoring/metrics/contrib/BUILD b/javatests/google/registry/monitoring/metrics/contrib/BUILD index 375c1bd5d..6e1299f85 100644 --- a/javatests/google/registry/monitoring/metrics/contrib/BUILD +++ b/javatests/google/registry/monitoring/metrics/contrib/BUILD @@ -13,8 +13,9 @@ java_library( deps = [ "//java/google/registry/monitoring/metrics", "//java/google/registry/monitoring/metrics/contrib", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", ], ) diff --git a/javatests/google/registry/monitoring/metrics/contrib/DistributionMetricSubjectTest.java b/javatests/google/registry/monitoring/metrics/contrib/DistributionMetricSubjectTest.java index 15be8d8e9..21fef1cd1 100644 --- a/javatests/google/registry/monitoring/metrics/contrib/DistributionMetricSubjectTest.java +++ b/javatests/google/registry/monitoring/metrics/contrib/DistributionMetricSubjectTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics.contrib; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.monitoring.metrics.contrib.DistributionMetricSubject.assertThat; import static org.junit.Assert.fail; diff --git a/javatests/google/registry/monitoring/metrics/contrib/LongMetricSubjectTest.java b/javatests/google/registry/monitoring/metrics/contrib/LongMetricSubjectTest.java index daaece1e0..aa70c1f9f 100644 --- a/javatests/google/registry/monitoring/metrics/contrib/LongMetricSubjectTest.java +++ b/javatests/google/registry/monitoring/metrics/contrib/LongMetricSubjectTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics.contrib; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.monitoring.metrics.contrib.LongMetricSubject.assertThat; import static org.junit.Assert.fail; diff --git a/javatests/google/registry/monitoring/metrics/stackdriver/BUILD b/javatests/google/registry/monitoring/metrics/stackdriver/BUILD index f70fd62db..84e6fd6e8 100644 --- a/javatests/google/registry/monitoring/metrics/stackdriver/BUILD +++ b/javatests/google/registry/monitoring/metrics/stackdriver/BUILD @@ -13,12 +13,13 @@ java_library( deps = [ "//java/google/registry/monitoring/metrics", "//java/google/registry/monitoring/metrics/stackdriver", - "//third_party/java/truth", "@com_google_api_client", "@com_google_apis_google_api_services_monitoring", "@com_google_guava", "@com_google_http_client", "@com_google_http_client_jackson2", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/monitoring/metrics/stackdriver/StackdriverWriterTest.java b/javatests/google/registry/monitoring/metrics/stackdriver/StackdriverWriterTest.java index 51e73f073..240c83700 100644 --- a/javatests/google/registry/monitoring/metrics/stackdriver/StackdriverWriterTest.java +++ b/javatests/google/registry/monitoring/metrics/stackdriver/StackdriverWriterTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.metrics.stackdriver; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; diff --git a/javatests/google/registry/monitoring/whitebox/BUILD b/javatests/google/registry/monitoring/whitebox/BUILD index 56ff1320e..a625891a7 100644 --- a/javatests/google/registry/monitoring/whitebox/BUILD +++ b/javatests/google/registry/monitoring/whitebox/BUILD @@ -20,7 +20,6 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/testing/mapreduce", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_apis_google_api_services_bigquery", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_stubs", @@ -29,6 +28,8 @@ java_library( "@com_google_guava", "@com_google_guava_testlib", "@com_google_http_client", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/monitoring/whitebox/EppMetricTest.java b/javatests/google/registry/monitoring/whitebox/EppMetricTest.java index 0d74b60e0..2f9b6cd6c 100644 --- a/javatests/google/registry/monitoring/whitebox/EppMetricTest.java +++ b/javatests/google/registry/monitoring/whitebox/EppMetricTest.java @@ -15,6 +15,7 @@ package google.registry.monitoring.whitebox; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTlds; @@ -71,7 +72,7 @@ public class EppMetricTest { EppMetric.builderForRequest("request-id-1", new FakeClock()) .setTlds(ImmutableSet.of()) .build(); - assertThat(metric.getTld()).isAbsent(); + assertThat(metric.getTld()).isEmpty(); } @Test diff --git a/javatests/google/registry/pricing/BUILD b/javatests/google/registry/pricing/BUILD index 895806f67..3f94277da 100644 --- a/javatests/google/registry/pricing/BUILD +++ b/javatests/google/registry/pricing/BUILD @@ -15,8 +15,9 @@ java_library( "//java/google/registry/pricing", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_joda_money", diff --git a/javatests/google/registry/pricing/PricingEngineProxyTest.java b/javatests/google/registry/pricing/PricingEngineProxyTest.java index 7773954e9..78a6f3aa6 100644 --- a/javatests/google/registry/pricing/PricingEngineProxyTest.java +++ b/javatests/google/registry/pricing/PricingEngineProxyTest.java @@ -15,6 +15,7 @@ package google.registry.pricing; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.pricing.PricingEngineProxy.isDomainPremium; diff --git a/javatests/google/registry/rdap/BUILD b/javatests/google/registry/rdap/BUILD index b2247a06a..d23bd2ae7 100644 --- a/javatests/google/registry/rdap/BUILD +++ b/javatests/google/registry/rdap/BUILD @@ -21,11 +21,12 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_servlet_api", "@joda_time", diff --git a/javatests/google/registry/rdap/RdapActionBaseTest.java b/javatests/google/registry/rdap/RdapActionBaseTest.java index 55f482c40..ebf66970f 100644 --- a/javatests/google/registry/rdap/RdapActionBaseTest.java +++ b/javatests/google/registry/rdap/RdapActionBaseTest.java @@ -16,6 +16,7 @@ package google.registry.rdap; import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.HEAD; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/rdap/RdapDomainActionTest.java b/javatests/google/registry/rdap/RdapDomainActionTest.java index 7b901238b..ce22cc7f9 100644 --- a/javatests/google/registry/rdap/RdapDomainActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainActionTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; diff --git a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java index 86270b358..a86f4bf3e 100644 --- a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java @@ -16,6 +16,7 @@ package google.registry.rdap; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistDomainAsDeleted; import static google.registry.testing.DatastoreHelper.persistResource; @@ -32,7 +33,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -60,6 +60,7 @@ import java.net.IDN; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -113,23 +114,23 @@ public class RdapDomainSearchActionTest { switch (requestType) { case NAME: action.nameParam = Optional.of(paramValue); - action.nsLdhNameParam = Optional.absent(); - action.nsIpParam = Optional.absent(); + action.nsLdhNameParam = Optional.empty(); + action.nsIpParam = Optional.empty(); break; case NS_LDH_NAME: - action.nameParam = Optional.absent(); + action.nameParam = Optional.empty(); action.nsLdhNameParam = Optional.of(paramValue); - action.nsIpParam = Optional.absent(); + action.nsIpParam = Optional.empty(); break; case NS_IP: - action.nameParam = Optional.absent(); - action.nsLdhNameParam = Optional.absent(); + action.nameParam = Optional.empty(); + action.nsLdhNameParam = Optional.empty(); action.nsIpParam = Optional.of(InetAddresses.forString(paramValue)); break; default: - action.nameParam = Optional.absent(); - action.nsLdhNameParam = Optional.absent(); - action.nsIpParam = Optional.absent(); + action.nameParam = Optional.empty(); + action.nsLdhNameParam = Optional.empty(); + action.nsIpParam = Optional.empty(); break; } action.rdapResultSetMaxSize = 4; @@ -359,8 +360,8 @@ public class RdapDomainSearchActionTest { action.clock = clock; action.request = request; action.response = response; - action.registrarParam = Optional.absent(); - action.includeDeletedParam = Optional.absent(); + action.registrarParam = Optional.empty(); + action.includeDeletedParam = Optional.empty(); action.rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(); action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; diff --git a/javatests/google/registry/rdap/RdapEntityActionTest.java b/javatests/google/registry/rdap/RdapEntityActionTest.java index f99ce9e8c..0e97dc3eb 100644 --- a/javatests/google/registry/rdap/RdapEntityActionTest.java +++ b/javatests/google/registry/rdap/RdapEntityActionTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; @@ -28,7 +29,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -45,6 +45,7 @@ import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; import google.registry.ui.server.registrar.SessionUtils; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -160,8 +161,8 @@ public class RdapEntityActionTest { action.clock = clock; action.request = request; action.response = response; - action.registrarParam = Optional.absent(); - action.includeDeletedParam = Optional.absent(); + action.registrarParam = Optional.empty(); + action.includeDeletedParam = Optional.empty(); action.rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(); action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; diff --git a/javatests/google/registry/rdap/RdapEntitySearchActionTest.java b/javatests/google/registry/rdap/RdapEntitySearchActionTest.java index 7913a0d10..d7920928c 100644 --- a/javatests/google/registry/rdap/RdapEntitySearchActionTest.java +++ b/javatests/google/registry/rdap/RdapEntitySearchActionTest.java @@ -16,6 +16,7 @@ package google.registry.rdap; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResources; @@ -29,7 +30,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import google.registry.model.ImmutableObject; @@ -45,6 +45,7 @@ import google.registry.testing.InjectRule; import google.registry.ui.server.registrar.SessionUtils; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -147,10 +148,10 @@ public class RdapEntitySearchActionTest { action.rdapResultSetMaxSize = 4; action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; - action.fnParam = Optional.absent(); - action.handleParam = Optional.absent(); - action.registrarParam = Optional.absent(); - action.includeDeletedParam = Optional.absent(); + action.fnParam = Optional.empty(); + action.handleParam = Optional.empty(); + action.registrarParam = Optional.empty(); + action.includeDeletedParam = Optional.empty(); action.sessionUtils = sessionUtils; action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); } diff --git a/javatests/google/registry/rdap/RdapHelpActionTest.java b/javatests/google/registry/rdap/RdapHelpActionTest.java index 7700bd6ad..6a1f8047c 100644 --- a/javatests/google/registry/rdap/RdapHelpActionTest.java +++ b/javatests/google/registry/rdap/RdapHelpActionTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import com.google.common.collect.ImmutableMap; diff --git a/javatests/google/registry/rdap/RdapJsonFormatterTest.java b/javatests/google/registry/rdap/RdapJsonFormatterTest.java index 2def5aaf3..f62720fec 100644 --- a/javatests/google/registry/rdap/RdapJsonFormatterTest.java +++ b/javatests/google/registry/rdap/RdapJsonFormatterTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; @@ -26,7 +27,6 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -49,6 +49,7 @@ import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; +import java.util.Optional; import org.joda.time.DateTime; import org.json.simple.JSONValue; import org.junit.Before; @@ -472,7 +473,7 @@ public class RdapJsonFormatterTest { rdapJsonFormatter.makeRdapJsonForContact( contactResourceTech, false, - Optional.absent(), + Optional.empty(), LINK_BASE, WHOIS_SERVER, clock.nowUtc(), @@ -487,7 +488,7 @@ public class RdapJsonFormatterTest { rdapJsonFormatter.makeRdapJsonForContact( contactResourceNotLinked, false, - Optional.absent(), + Optional.empty(), LINK_BASE, WHOIS_SERVER, clock.nowUtc(), diff --git a/javatests/google/registry/rdap/RdapNameserverActionTest.java b/javatests/google/registry/rdap/RdapNameserverActionTest.java index 525d9ef8e..9253bba26 100644 --- a/javatests/google/registry/rdap/RdapNameserverActionTest.java +++ b/javatests/google/registry/rdap/RdapNameserverActionTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; @@ -24,7 +25,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -39,6 +39,7 @@ import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; import google.registry.ui.server.registrar.SessionUtils; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -122,7 +123,7 @@ public class RdapNameserverActionTest { } private Object generateActualJson(String name) { - return generateActualJson(name, Optional.absent(), Optional.absent()); + return generateActualJson(name, Optional.empty(), Optional.empty()); } private Object generateActualJson( @@ -282,7 +283,7 @@ public class RdapNameserverActionTest { public void testNameserver_found_sameRegistrarRequested() throws Exception { assertThat( generateActualJson( - "ns1.cat.lol", Optional.of("TheRegistrar"), Optional.absent())) + "ns1.cat.lol", Optional.of("TheRegistrar"), Optional.empty())) .isEqualTo( generateExpectedJsonWithTopLevelEntries( "ns1.cat.lol", @@ -309,14 +310,14 @@ public class RdapNameserverActionTest { @Test public void testDeletedNameserver_notFound_includeDeletedSetFalse() throws Exception { - generateActualJson("nsdeleted.cat.lol", Optional.absent(), Optional.of(false)); + generateActualJson("nsdeleted.cat.lol", Optional.empty(), Optional.of(false)); assertThat(response.getStatus()).isEqualTo(404); } @Test public void testDeletedNameserver_notFound_notLoggedIn() throws Exception { when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(false); - generateActualJson("nsdeleted.cat.lol", Optional.absent(), Optional.of(true)); + generateActualJson("nsdeleted.cat.lol", Optional.empty(), Optional.of(true)); assertThat(response.getStatus()).isEqualTo(404); } @@ -324,7 +325,7 @@ public class RdapNameserverActionTest { public void testDeletedNameserver_notFound_loggedInAsDifferentRegistrar() throws Exception { when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("otherregistrar"); - generateActualJson("nsdeleted.cat.lol", Optional.absent(), Optional.of(true)); + generateActualJson("nsdeleted.cat.lol", Optional.empty(), Optional.of(true)); assertThat(response.getStatus()).isEqualTo(404); } @@ -333,7 +334,7 @@ public class RdapNameserverActionTest { when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("TheRegistrar"); assertThat( - generateActualJson("nsdeleted.cat.lol", Optional.absent(), Optional.of(true))) + generateActualJson("nsdeleted.cat.lol", Optional.empty(), Optional.of(true))) .isEqualTo( generateExpectedJsonWithTopLevelEntries( "nsdeleted.cat.lol", @@ -352,7 +353,7 @@ public class RdapNameserverActionTest { when(sessionUtils.getRegistrarClientId(request)).thenReturn("irrelevant"); newRdapNameserverAction( "nsdeleted.cat.lol", - Optional.absent(), + Optional.empty(), Optional.of(true), AuthResult.create(AuthLevel.USER, adminUserAuthInfo)) .run(); diff --git a/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java b/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java index f058dfb04..59fc11fb3 100644 --- a/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResources; @@ -30,7 +31,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -48,6 +48,7 @@ import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; import google.registry.ui.server.registrar.SessionUtils; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; @@ -150,10 +151,10 @@ public class RdapNameserverSearchActionTest { action.rdapResultSetMaxSize = 4; action.rdapLinkBase = "https://example.tld/rdap/"; action.rdapWhoisServer = null; - action.ipParam = Optional.absent(); - action.nameParam = Optional.absent(); - action.registrarParam = Optional.absent(); - action.includeDeletedParam = Optional.absent(); + action.ipParam = Optional.empty(); + action.nameParam = Optional.empty(); + action.registrarParam = Optional.empty(); + action.includeDeletedParam = Optional.empty(); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); action.sessionUtils = sessionUtils; } diff --git a/javatests/google/registry/rdap/RdapSearchPatternTest.java b/javatests/google/registry/rdap/RdapSearchPatternTest.java index bdf708fad..d4b51c054 100644 --- a/javatests/google/registry/rdap/RdapSearchPatternTest.java +++ b/javatests/google/registry/rdap/RdapSearchPatternTest.java @@ -15,6 +15,7 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.request.HttpException.UnprocessableEntityException; import google.registry.testing.ExceptionRule; diff --git a/javatests/google/registry/rde/BUILD b/javatests/google/registry/rde/BUILD index 83ebf46cc..740da7b21 100644 --- a/javatests/google/registry/rde/BUILD +++ b/javatests/google/registry/rde/BUILD @@ -29,12 +29,13 @@ java_library( "//javatests/google/registry/xml", "//third_party/java/jsch/v0_1_53", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/rde/BouncyCastleTest.java b/javatests/google/registry/rde/BouncyCastleTest.java index b2ea84aeb..ff1b45580 100644 --- a/javatests/google/registry/rde/BouncyCastleTest.java +++ b/javatests/google/registry/rde/BouncyCastleTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.HexDumper.dumpHex; import static java.nio.charset.StandardCharsets.UTF_8; import static org.bouncycastle.bcpg.CompressionAlgorithmTags.ZIP; diff --git a/javatests/google/registry/rde/BrdaCopyActionTest.java b/javatests/google/registry/rde/BrdaCopyActionTest.java index ffa8e0b36..fc209dab1 100644 --- a/javatests/google/registry/rde/BrdaCopyActionTest.java +++ b/javatests/google/registry/rde/BrdaCopyActionTest.java @@ -16,6 +16,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.GcsTestingUtils.readGcsFile; import static google.registry.testing.SystemInfo.hasCommand; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/rde/ContactResourceToXjcConverterTest.java b/javatests/google/registry/rde/ContactResourceToXjcConverterTest.java index 3e4d13e79..ba3aaecba 100644 --- a/javatests/google/registry/rde/ContactResourceToXjcConverterTest.java +++ b/javatests/google/registry/rde/ContactResourceToXjcConverterTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/rde/DomainResourceToXjcConverterTest.java b/javatests/google/registry/rde/DomainResourceToXjcConverterTest.java index e5f8eb54d..87226f21b 100644 --- a/javatests/google/registry/rde/DomainResourceToXjcConverterTest.java +++ b/javatests/google/registry/rde/DomainResourceToXjcConverterTest.java @@ -16,6 +16,7 @@ package google.registry.rde; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.testing.DatastoreHelper.persistEppResource; diff --git a/javatests/google/registry/rde/EscrowTaskRunnerTest.java b/javatests/google/registry/rde/EscrowTaskRunnerTest.java index 7ec4e3669..753ae6c62 100644 --- a/javatests/google/registry/rde/EscrowTaskRunnerTest.java +++ b/javatests/google/registry/rde/EscrowTaskRunnerTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java b/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java index dc8115be7..b0e872857 100644 --- a/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java +++ b/javatests/google/registry/rde/GhostrydeGpgIntegrationTest.java @@ -17,6 +17,7 @@ package google.registry.rde; import static com.google.common.base.Strings.repeat; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.SystemInfo.hasCommand; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assume.assumeTrue; diff --git a/javatests/google/registry/rde/GhostrydeTest.java b/javatests/google/registry/rde/GhostrydeTest.java index 11fa9a6cc..879d0c6c2 100644 --- a/javatests/google/registry/rde/GhostrydeTest.java +++ b/javatests/google/registry/rde/GhostrydeTest.java @@ -16,6 +16,7 @@ package google.registry.rde; import static com.google.common.base.Strings.repeat; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.keyring.api.PgpHelper.KeyRequirement.ENCRYPT; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.Matchers.greaterThan; diff --git a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java index 3cded701c..f065e9fa7 100644 --- a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java +++ b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.xjc.XjcXmlTransformer.marshalStrict; diff --git a/javatests/google/registry/rde/PendingDepositCheckerTest.java b/javatests/google/registry/rde/PendingDepositCheckerTest.java index 9d1a23f3c..3213174b2 100644 --- a/javatests/google/registry/rde/PendingDepositCheckerTest.java +++ b/javatests/google/registry/rde/PendingDepositCheckerTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.Cursor.CursorType.BRDA; import static google.registry.model.common.Cursor.CursorType.RDE_STAGING; import static google.registry.model.ofy.ObjectifyService.ofy; diff --git a/javatests/google/registry/rde/RdeMarshallerTest.java b/javatests/google/registry/rde/RdeMarshallerTest.java index da587d4dc..28f4dc99b 100644 --- a/javatests/google/registry/rde/RdeMarshallerTest.java +++ b/javatests/google/registry/rde/RdeMarshallerTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.xml.ValidationMode.STRICT; diff --git a/javatests/google/registry/rde/RdeReportActionTest.java b/javatests/google/registry/rde/RdeReportActionTest.java index 75da26bfe..877f964ee 100644 --- a/javatests/google/registry/rde/RdeReportActionTest.java +++ b/javatests/google/registry/rde/RdeReportActionTest.java @@ -17,6 +17,7 @@ package google.registry.rde; import static com.google.appengine.api.urlfetch.HTTPMethod.PUT; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/rde/RdeStagingActionTest.java b/javatests/google/registry/rde/RdeStagingActionTest.java index a1d4270ae..739f5c5bb 100644 --- a/javatests/google/registry/rde/RdeStagingActionTest.java +++ b/javatests/google/registry/rde/RdeStagingActionTest.java @@ -40,7 +40,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.ListItem; import com.google.appengine.tools.cloudstorage.ListOptions; import com.google.appengine.tools.cloudstorage.ListResult; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -83,6 +82,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.xml.bind.JAXBElement; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPrivateKey; @@ -151,11 +151,11 @@ public class RdeStagingActionTest extends MapreduceTestCase { action.pendingDepositChecker.rdeInterval = Duration.standardDays(1); action.response = response; action.transactionCooldown = Duration.ZERO; - action.directory = Optional.absent(); + action.directory = Optional.empty(); action.modeStrings = ImmutableSet.of(); action.tlds = ImmutableSet.of(); action.watermarks = ImmutableSet.of(); - action.revision = Optional.absent(); + action.revision = Optional.empty(); } @Test diff --git a/javatests/google/registry/rde/RdeUploadActionTest.java b/javatests/google/registry/rde/RdeUploadActionTest.java index 4e321a7aa..1709e53ca 100644 --- a/javatests/google/registry/rde/RdeUploadActionTest.java +++ b/javatests/google/registry/rde/RdeUploadActionTest.java @@ -17,6 +17,7 @@ package google.registry.rde; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.rde.RdeMode.FULL; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/rde/RegistrarToXjcConverterTest.java b/javatests/google/registry/rde/RegistrarToXjcConverterTest.java index a8ba98815..b165253fc 100644 --- a/javatests/google/registry/rde/RegistrarToXjcConverterTest.java +++ b/javatests/google/registry/rde/RegistrarToXjcConverterTest.java @@ -15,6 +15,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.xjc.XjcXmlTransformer.marshalStrict; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/rde/RydeGpgIntegrationTest.java b/javatests/google/registry/rde/RydeGpgIntegrationTest.java index d443d2bf9..a34326222 100644 --- a/javatests/google/registry/rde/RydeGpgIntegrationTest.java +++ b/javatests/google/registry/rde/RydeGpgIntegrationTest.java @@ -17,6 +17,7 @@ package google.registry.rde; import static com.google.common.base.Strings.repeat; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.SystemInfo.hasCommand; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assume.assumeTrue; diff --git a/javatests/google/registry/rde/imports/BUILD b/javatests/google/registry/rde/imports/BUILD index f98186bd0..64b088d31 100644 --- a/javatests/google/registry/rde/imports/BUILD +++ b/javatests/google/registry/rde/imports/BUILD @@ -23,12 +23,13 @@ java_library( "//javatests/google/registry/testing", "//javatests/google/registry/testing/mapreduce", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_joda_money", diff --git a/javatests/google/registry/rde/imports/RdeContactImportActionTest.java b/javatests/google/registry/rde/imports/RdeContactImportActionTest.java index 8b207f080..37935ebf3 100644 --- a/javatests/google/registry/rde/imports/RdeContactImportActionTest.java +++ b/javatests/google/registry/rde/imports/RdeContactImportActionTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.getHistoryEntries; import static google.registry.testing.DatastoreHelper.newContactResource; @@ -26,7 +27,6 @@ import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.googlecode.objectify.Key; @@ -43,6 +43,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Test; diff --git a/javatests/google/registry/rde/imports/RdeContactInputTest.java b/javatests/google/registry/rde/imports/RdeContactInputTest.java index cbc2a0f34..71b1098b8 100644 --- a/javatests/google/registry/rde/imports/RdeContactInputTest.java +++ b/javatests/google/registry/rde/imports/RdeContactInputTest.java @@ -15,12 +15,12 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,14 +67,14 @@ public class RdeContactInputTest { @Test public void testZeroContactsDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_0_CONTACT); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with zero contacts results in expected reader configuration */ @Test public void testZeroContactsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_0_CONTACT); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); } /** Escrow file with zero contacts and 75 shards results in one reader */ @@ -87,14 +88,14 @@ public class RdeContactInputTest { @Test public void testOneContactDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_1_CONTACT); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with one contact results in expected reader configuration */ @Test public void testOneContactDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_1_CONTACT); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); } /** Escrow file with one contact and 75 shards results in one reader */ @@ -108,14 +109,14 @@ public class RdeContactInputTest { @Test public void test199ContactsDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_199_CONTACT); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with 199 contacts results in expected reader configuration */ @Test public void test199ContactsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_199_CONTACT); - assertReaderConfigurations(Optional.absent(), 0, 0, 199); + assertReaderConfigurations(Optional.empty(), 0, 0, 199); } /** Escrow file with 199 contacts and 75 shards results in one reader */ @@ -129,15 +130,15 @@ public class RdeContactInputTest { @Test public void test200ContactsDefaultShards_returnsTwoReaders() throws Exception { pushToGcs(DEPOSIT_200_CONTACT); - assertNumberOfReaders(Optional.absent(), 2); + assertNumberOfReaders(Optional.empty(), 2); } /** Escrow file with 200 contacts results in expected reader configurations */ @Test public void test200ContactsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_200_CONTACT); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); - assertReaderConfigurations(Optional.absent(), 1, 100, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 1, 100, 100); } /** Escrow file with 200 contacts and 75 shards results in two readers */ @@ -151,7 +152,7 @@ public class RdeContactInputTest { @Test public void test1000ContactsDefaultShards_returns10Readers() throws Exception { pushToGcs(DEPOSIT_1000_CONTACT); - assertNumberOfReaders(Optional.absent(), 10); + assertNumberOfReaders(Optional.empty(), 10); } /** Escrow file with 1000 contacts results in expected reader configurations */ @@ -159,7 +160,7 @@ public class RdeContactInputTest { public void test1000ContactsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_1000_CONTACT); for (int i = 0; i < 10; i++) { - assertReaderConfigurations(Optional.absent(), i, i * 100, 100); + assertReaderConfigurations(Optional.empty(), i, i * 100, 100); } } @@ -174,7 +175,7 @@ public class RdeContactInputTest { @Test public void test10000ContactsDefaultShards_returns50Readers() throws Exception { pushToGcs(DEPOSIT_10000_CONTACT); - assertNumberOfReaders(Optional.absent(), 50); + assertNumberOfReaders(Optional.empty(), 50); } /** Escrow file with 10000 contacts results in expected reader configurations */ @@ -182,7 +183,7 @@ public class RdeContactInputTest { public void test10000ContactsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_10000_CONTACT); for (int i = 0; i < 50; i++) { - assertReaderConfigurations(Optional.absent(), i, i * 200, 200); + assertReaderConfigurations(Optional.empty(), i, i * 200, 200); } } @@ -203,7 +204,7 @@ public class RdeContactInputTest { /** * Verify bucket, filename, offset and max results for a specific reader * - * @param numberOfShards Number of desired shards ({@code Optional.absent()} uses default of 50) + * @param numberOfShards Number of desired shards ({@code Optional.empty()} uses default of 50) * @param whichReader Index of the reader in the list that is produced by the * {@link RdeContactInput} * @param expectedOffset Expected offset of the reader @@ -234,7 +235,7 @@ public class RdeContactInputTest { /** * Verify the number of readers produced by the {@link RdeContactInput} * - * @param numberOfShards Number of desired shards ({@code Optional.absent()} uses default of 50) + * @param numberOfShards Number of desired shards ({@code Optional.empty()} uses default of 50) * @param expectedNumberOfReaders Expected size of the list returned */ private void assertNumberOfReaders(Optional numberOfShards, @@ -246,7 +247,7 @@ public class RdeContactInputTest { /** * Creates a new testable instance of {@link RdeContactInput} - * @param mapShards Number of desired shards ({@code Optional.absent()} uses default of 50) + * @param mapShards Number of desired shards ({@code Optional.empty()} uses default of 50) */ private RdeContactInput getInput(Optional mapShards) { return new RdeContactInput(mapShards, IMPORT_BUCKET_NAME, IMPORT_FILE_NAME); diff --git a/javatests/google/registry/rde/imports/RdeContactReaderTest.java b/javatests/google/registry/rde/imports/RdeContactReaderTest.java index a4fa20bc6..c7498fb92 100644 --- a/javatests/google/registry/rde/imports/RdeContactReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeContactReaderTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; diff --git a/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java b/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java index b403bd0f6..919c0380e 100644 --- a/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java +++ b/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.getHistoryEntries; @@ -33,7 +34,6 @@ import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.googlecode.objectify.Key; @@ -55,6 +55,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/javatests/google/registry/rde/imports/RdeDomainReaderTest.java b/javatests/google/registry/rde/imports/RdeDomainReaderTest.java index 1327a728d..9e5ab50e2 100644 --- a/javatests/google/registry/rde/imports/RdeDomainReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeDomainReaderTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveContact; diff --git a/javatests/google/registry/rde/imports/RdeHostImportActionTest.java b/javatests/google/registry/rde/imports/RdeHostImportActionTest.java index 1da2e869a..5c0610022 100644 --- a/javatests/google/registry/rde/imports/RdeHostImportActionTest.java +++ b/javatests/google/registry/rde/imports/RdeHostImportActionTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.getHistoryEntries; import static google.registry.testing.DatastoreHelper.newHostResource; @@ -26,7 +27,6 @@ import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.googlecode.objectify.Key; @@ -43,6 +43,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Test; @@ -63,12 +64,12 @@ public class RdeHostImportActionTest extends MapreduceTestCase mapShards = Optional.absent(); + private final Optional mapShards = Optional.empty(); @Before public void before() throws Exception { response = new FakeResponse(); - mrRunner = new MapreduceRunner(Optional.absent(), Optional.absent()); + mrRunner = new MapreduceRunner(Optional.empty(), Optional.empty()); action = new RdeHostImportAction( mrRunner, response, diff --git a/javatests/google/registry/rde/imports/RdeHostInputTest.java b/javatests/google/registry/rde/imports/RdeHostInputTest.java index 5814f8674..a1bbce8ab 100644 --- a/javatests/google/registry/rde/imports/RdeHostInputTest.java +++ b/javatests/google/registry/rde/imports/RdeHostInputTest.java @@ -15,12 +15,12 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -83,14 +84,14 @@ public class RdeHostInputTest { @Test public void testZeroHostsDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_0_HOST); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with zero hosts results in expected reader configuration */ @Test public void testZeroHostsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_0_HOST); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); } /** Escrow file with zero hosts and 75 shards results in one reader */ @@ -104,14 +105,14 @@ public class RdeHostInputTest { @Test public void testOneHostDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_1_HOST); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with one host results in expected reader configuration */ @Test public void testOneHostDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_1_HOST); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); } /** Escrow file with one host and 75 shards results in one reader */ @@ -125,14 +126,14 @@ public class RdeHostInputTest { @Test public void test199HostsDefaultShards_returnsOneReader() throws Exception { pushToGcs(DEPOSIT_199_HOST); - assertNumberOfReaders(Optional.absent(), 1); + assertNumberOfReaders(Optional.empty(), 1); } /** Escrow file with 199 hosts results in expected reader configuration */ @Test public void test199HostsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_199_HOST); - assertReaderConfigurations(Optional.absent(), 0, 0, 199); + assertReaderConfigurations(Optional.empty(), 0, 0, 199); } /** Escrow file with 199 hosts and 75 shards results in one reader */ @@ -146,15 +147,15 @@ public class RdeHostInputTest { @Test public void test200HostsDefaultShards_returnsTwoReaders() throws Exception { pushToGcs(DEPOSIT_200_HOST); - assertNumberOfReaders(Optional.absent(), 2); + assertNumberOfReaders(Optional.empty(), 2); } /** Escrow file with 200 hosts results in expected reader configurations */ @Test public void test200HostsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_200_HOST); - assertReaderConfigurations(Optional.absent(), 0, 0, 100); - assertReaderConfigurations(Optional.absent(), 1, 100, 100); + assertReaderConfigurations(Optional.empty(), 0, 0, 100); + assertReaderConfigurations(Optional.empty(), 1, 100, 100); } /** Escrow file with 200 hosts and 75 shards results in two readers */ @@ -168,7 +169,7 @@ public class RdeHostInputTest { @Test public void test1000HostsDefaultShards_returns10Readers() throws Exception { pushToGcs(DEPOSIT_1000_HOST); - assertNumberOfReaders(Optional.absent(), 10); + assertNumberOfReaders(Optional.empty(), 10); } /** Escrow file with 1000 hosts results in expected reader configurations */ @@ -176,7 +177,7 @@ public class RdeHostInputTest { public void test1000HostsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_1000_HOST); for (int i = 0; i < 10; i++) { - assertReaderConfigurations(Optional.absent(), i, i * 100, 100); + assertReaderConfigurations(Optional.empty(), i, i * 100, 100); } } @@ -191,7 +192,7 @@ public class RdeHostInputTest { @Test public void test10000HostsDefaultShards_returns50Readers() throws Exception { pushToGcs(DEPOSIT_10000_HOST); - assertNumberOfReaders(Optional.absent(), 50); + assertNumberOfReaders(Optional.empty(), 50); } /** Escrow file with 10000 hosts results in expected reader configurations */ @@ -199,7 +200,7 @@ public class RdeHostInputTest { public void test10000HostsDefaultShardsReaderConfigurations() throws Exception { pushToGcs(DEPOSIT_10000_HOST); for (int i = 0; i < 50; i++) { - assertReaderConfigurations(Optional.absent(), i, i * 200, 200); + assertReaderConfigurations(Optional.empty(), i, i * 200, 200); } } diff --git a/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java b/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java index dc5a99bb5..888eeceee 100644 --- a/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java +++ b/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; @@ -28,7 +29,6 @@ import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; import com.google.appengine.tools.cloudstorage.RetryParams; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; @@ -49,6 +49,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; @@ -74,7 +75,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase private Response response; - private final Optional mapShards = Optional.absent(); + private final Optional mapShards = Optional.empty(); private final FakeClock clock = new FakeClock(); @@ -84,7 +85,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase inject.setStaticField(Ofy.class, "clock", clock); createTld("test"); response = new FakeResponse(); - mrRunner = new MapreduceRunner(Optional.absent(), Optional.absent()); + mrRunner = new MapreduceRunner(Optional.empty(), Optional.empty()); action = new RdeHostLinkAction(mrRunner, response, IMPORT_BUCKET_NAME, IMPORT_FILE_NAME, mapShards); } diff --git a/javatests/google/registry/rde/imports/RdeHostReaderTest.java b/javatests/google/registry/rde/imports/RdeHostReaderTest.java index 6a83c9f68..cf88e9af3 100644 --- a/javatests/google/registry/rde/imports/RdeHostReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeHostReaderTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; diff --git a/javatests/google/registry/rde/imports/RdeImportTestUtils.java b/javatests/google/registry/rde/imports/RdeImportTestUtils.java index de5887b1c..432122e9c 100644 --- a/javatests/google/registry/rde/imports/RdeImportTestUtils.java +++ b/javatests/google/registry/rde/imports/RdeImportTestUtils.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.model.eppcommon.Trid; diff --git a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java index bc5a8a41b..e2fcc1350 100644 --- a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java +++ b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java @@ -16,6 +16,7 @@ package google.registry.rde.imports; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistActiveContact; diff --git a/javatests/google/registry/rde/imports/RdeParserTest.java b/javatests/google/registry/rde/imports/RdeParserTest.java index 679287656..414e97cd7 100644 --- a/javatests/google/registry/rde/imports/RdeParserTest.java +++ b/javatests/google/registry/rde/imports/RdeParserTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.io.ByteSource; import google.registry.rde.imports.RdeParser.RdeHeader; diff --git a/javatests/google/registry/rde/imports/XjcToContactResourceConverterTest.java b/javatests/google/registry/rde/imports/XjcToContactResourceConverterTest.java index c88a238ed..c0ed63a2b 100644 --- a/javatests/google/registry/rde/imports/XjcToContactResourceConverterTest.java +++ b/javatests/google/registry/rde/imports/XjcToContactResourceConverterTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.rde.imports.RdeImportTestUtils.checkTrid; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java b/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java index eb60a342d..d0fe72e27 100644 --- a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java +++ b/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java @@ -16,6 +16,7 @@ package google.registry.rde.imports; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.rde.imports.RdeImportTestUtils.checkTrid; import static google.registry.rde.imports.RdeImportUtils.createAutoRenewBillingEventForDomainImport; diff --git a/javatests/google/registry/rde/imports/XjcToHostResourceConverterTest.java b/javatests/google/registry/rde/imports/XjcToHostResourceConverterTest.java index 5266c08ca..088e453dd 100644 --- a/javatests/google/registry/rde/imports/XjcToHostResourceConverterTest.java +++ b/javatests/google/registry/rde/imports/XjcToHostResourceConverterTest.java @@ -15,6 +15,7 @@ package google.registry.rde.imports; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.rde.imports.RdeImportTestUtils.checkTrid; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/reporting/ActivityReportingQueryBuilderTest.java b/javatests/google/registry/reporting/ActivityReportingQueryBuilderTest.java index 0fc73fc6a..508806272 100644 --- a/javatests/google/registry/reporting/ActivityReportingQueryBuilderTest.java +++ b/javatests/google/registry/reporting/ActivityReportingQueryBuilderTest.java @@ -15,6 +15,7 @@ package google.registry.reporting; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/javatests/google/registry/reporting/BUILD b/javatests/google/registry/reporting/BUILD index 7e68d4d2e..7a8d3384b 100644 --- a/javatests/google/registry/reporting/BUILD +++ b/javatests/google/registry/reporting/BUILD @@ -18,13 +18,14 @@ java_library( "//java/google/registry/request", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_apis_google_api_services_bigquery", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_code_findbugs_jsr305", "@com_google_dagger", "@com_google_guava", "@com_google_http_client", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/reporting/IcannHttpReporterTest.java b/javatests/google/registry/reporting/IcannHttpReporterTest.java index b3398f1a2..9d9dc2f7f 100644 --- a/javatests/google/registry/reporting/IcannHttpReporterTest.java +++ b/javatests/google/registry/reporting/IcannHttpReporterTest.java @@ -18,6 +18,7 @@ import static com.google.common.net.MediaType.CSV_UTF_8; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.api.client.http.LowLevelHttpRequest; diff --git a/javatests/google/registry/reporting/IcannReportingStagingActionTest.java b/javatests/google/registry/reporting/IcannReportingStagingActionTest.java index ca1ba8c5d..07d697f11 100644 --- a/javatests/google/registry/reporting/IcannReportingStagingActionTest.java +++ b/javatests/google/registry/reporting/IcannReportingStagingActionTest.java @@ -15,6 +15,7 @@ package google.registry.reporting; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.GcsTestingUtils.readGcsFile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.any; @@ -25,7 +26,6 @@ import com.google.api.services.bigquery.model.TableFieldSchema; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableTable; import com.google.common.util.concurrent.ListenableFuture; import google.registry.bigquery.BigqueryConnection; @@ -35,6 +35,7 @@ import google.registry.gcs.GcsUtils; import google.registry.reporting.IcannReportingModule.ReportType; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeResponse; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; @@ -77,7 +78,7 @@ public class IcannReportingStagingActionTest { action.reportType = reportType; action.reportingBucket = "test-bucket"; action.yearMonth = "2017-06"; - action.subdir = Optional.absent(); + action.subdir = Optional.empty(); action.bigquery = bigquery; action.gcsUtils = new GcsUtils(gcsService, 1024); action.response = response; diff --git a/javatests/google/registry/reporting/IcannReportingUploadActionTest.java b/javatests/google/registry/reporting/IcannReportingUploadActionTest.java index b497312e6..2fac153b9 100644 --- a/javatests/google/registry/reporting/IcannReportingUploadActionTest.java +++ b/javatests/google/registry/reporting/IcannReportingUploadActionTest.java @@ -16,6 +16,7 @@ package google.registry.reporting; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.reporting.IcannReportingModule.ReportType.ACTIVITY; import static google.registry.reporting.IcannReportingModule.ReportType.TRANSACTIONS; import static google.registry.testing.DatastoreHelper.createTld; @@ -30,7 +31,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsServiceFactory; -import com.google.common.base.Optional; import google.registry.gcs.GcsUtils; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; @@ -38,6 +38,7 @@ import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; import google.registry.util.Retrier; import java.io.IOException; +import java.util.Optional; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -64,7 +65,7 @@ public class IcannReportingUploadActionTest { action.retrier = new Retrier(new FakeSleeper(new FakeClock()), 3); action.yearMonth = "2017-06"; action.reportType = TRANSACTIONS; - action.subdir = Optional.absent(); + action.subdir = Optional.empty(); action.tld = "test"; action.icannReportingBucket = "basin"; action.response = response; @@ -172,7 +173,7 @@ public class IcannReportingUploadActionTest { public void testSuccess_CreateBucketname() throws Exception{ assertThat( IcannReportingUploadAction - .createReportingBucketName("gs://my-reporting", Optional.absent(), "2017-06")) + .createReportingBucketName("gs://my-reporting", Optional.empty(), "2017-06")) .isEqualTo("gs://my-reporting/icann/monthly/2017-06"); assertThat( IcannReportingUploadAction diff --git a/javatests/google/registry/reporting/TransactionsReportingQueryBuilderTest.java b/javatests/google/registry/reporting/TransactionsReportingQueryBuilderTest.java index c4670b294..65b2b69c4 100644 --- a/javatests/google/registry/reporting/TransactionsReportingQueryBuilderTest.java +++ b/javatests/google/registry/reporting/TransactionsReportingQueryBuilderTest.java @@ -15,6 +15,7 @@ package google.registry.reporting; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/javatests/google/registry/request/BUILD b/javatests/google/registry/request/BUILD index e313fd624..7ca55c4e5 100644 --- a/javatests/google/registry/request/BUILD +++ b/javatests/google/registry/request/BUILD @@ -15,10 +15,11 @@ java_library( "//java/google/registry/request/auth", "//java/google/registry/security", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_inject", "@javax_servlet_api", diff --git a/javatests/google/registry/request/JsonResponseTest.java b/javatests/google/registry/request/JsonResponseTest.java index aa86a0402..876afa3b3 100644 --- a/javatests/google/registry/request/JsonResponseTest.java +++ b/javatests/google/registry/request/JsonResponseTest.java @@ -15,6 +15,7 @@ package google.registry.request; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.JsonResponse.JSON_SAFETY_PREFIX; import com.google.common.collect.ImmutableMap; diff --git a/javatests/google/registry/request/RequestHandlerTest.java b/javatests/google/registry/request/RequestHandlerTest.java index 689eec73b..10642510e 100644 --- a/javatests/google/registry/request/RequestHandlerTest.java +++ b/javatests/google/registry/request/RequestHandlerTest.java @@ -15,6 +15,7 @@ package google.registry.request; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.POST; import static google.registry.request.auth.Auth.AUTH_INTERNAL_OR_ADMIN; @@ -26,7 +27,6 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; -import com.google.common.base.Optional; import com.google.common.testing.NullPointerTester; import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.request.auth.AuthLevel; @@ -38,6 +38,7 @@ import google.registry.testing.Providers; import google.registry.testing.UserInfo; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.After; @@ -412,7 +413,7 @@ public final class RequestHandlerTest { assertThat(providedAuthResult).isNotNull(); assertThat(providedAuthResult.authLevel()).isEqualTo(AuthLevel.NONE); - assertThat(providedAuthResult.userAuthInfo()).isAbsent(); + assertThat(providedAuthResult.userAuthInfo()).isEmpty(); } @Test @@ -420,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.absent()); + .thenReturn(Optional.empty()); handler.handleRequest(req, rsp); @@ -442,7 +443,7 @@ public final class RequestHandlerTest { assertThat(providedAuthResult.authLevel()).isEqualTo(AuthLevel.USER); assertThat(providedAuthResult.userAuthInfo()).isPresent(); assertThat(providedAuthResult.userAuthInfo().get().user()).isEqualTo(testUser); - assertThat(providedAuthResult.userAuthInfo().get().oauthTokenInfo()).isAbsent(); + assertThat(providedAuthResult.userAuthInfo().get().oauthTokenInfo()).isEmpty(); } } diff --git a/javatests/google/registry/request/RequestModuleTest.java b/javatests/google/registry/request/RequestModuleTest.java index 25d373102..ebd54f677 100644 --- a/javatests/google/registry/request/RequestModuleTest.java +++ b/javatests/google/registry/request/RequestModuleTest.java @@ -15,6 +15,7 @@ package google.registry.request; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.RequestModule.provideJsonPayload; import com.google.common.net.MediaType; diff --git a/javatests/google/registry/request/RequestParametersTest.java b/javatests/google/registry/request/RequestParametersTest.java index 68e8fc0c2..743d8dc85 100644 --- a/javatests/google/registry/request/RequestParametersTest.java +++ b/javatests/google/registry/request/RequestParametersTest.java @@ -15,6 +15,7 @@ package google.registry.request; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.RequestParameters.extractBooleanParameter; import static google.registry.request.RequestParameters.extractEnumParameter; import static google.registry.request.RequestParameters.extractOptionalDatetimeParameter; @@ -70,13 +71,13 @@ public class RequestParametersTest { @Test public void testExtractOptionalParameter_notPresent_returnsAbsent() throws Exception { - assertThat(extractOptionalParameter(req, "spin")).isAbsent(); + assertThat(extractOptionalParameter(req, "spin")).isEmpty(); } @Test public void testExtractOptionalParameter_empty_returnsAbsent() throws Exception { when(req.getParameter("spin")).thenReturn(""); - assertThat(extractOptionalParameter(req, "spin")).isAbsent(); + assertThat(extractOptionalParameter(req, "spin")).isEmpty(); } @Test @@ -177,7 +178,7 @@ public class RequestParametersTest { @Test public void testExtractOptionalDatetimeParameter_empty_returnsAbsent() throws Exception { when(req.getParameter("timeParam")).thenReturn(""); - assertThat(extractOptionalDatetimeParameter(req, "timeParam")).isAbsent(); + assertThat(extractOptionalDatetimeParameter(req, "timeParam")).isEmpty(); } @Test diff --git a/javatests/google/registry/request/ResponseImplTest.java b/javatests/google/registry/request/ResponseImplTest.java index 001423bcd..1d34e86b5 100644 --- a/javatests/google/registry/request/ResponseImplTest.java +++ b/javatests/google/registry/request/ResponseImplTest.java @@ -16,6 +16,7 @@ package google.registry.request; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; diff --git a/javatests/google/registry/request/RouterTest.java b/javatests/google/registry/request/RouterTest.java index 2b9c870bf..5c4857115 100644 --- a/javatests/google/registry/request/RouterTest.java +++ b/javatests/google/registry/request/RouterTest.java @@ -15,11 +15,12 @@ package google.registry.request; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.auth.Auth.AUTH_INTERNAL_ONLY; import com.google.common.base.Function; -import com.google.common.base.Optional; import google.registry.testing.ExceptionRule; +import java.util.Optional; import java.util.concurrent.Callable; import org.junit.Rule; import org.junit.Test; @@ -67,12 +68,12 @@ public final class RouterTest { @Test public void testRoute_pathMismatch_returnsAbsent() throws Exception { - assertThat(Router.create(SlothComponent.class).route("/doge")).isAbsent(); + assertThat(Router.create(SlothComponent.class).route("/doge")).isEmpty(); } @Test public void testRoute_pathIsAPrefix_notAllowedByDefault() throws Exception { - assertThat(Router.create(SlothComponent.class).route("/sloth/extra")).isAbsent(); + assertThat(Router.create(SlothComponent.class).route("/sloth/extra")).isEmpty(); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -95,10 +96,10 @@ public final class RouterTest { @Test public void testRoute_prefixDoesNotMatch_returnsAbsent() throws Exception { - assertThat(Router.create(PrefixComponent.class).route("")).isAbsent(); - assertThat(Router.create(PrefixComponent.class).route("/")).isAbsent(); - assertThat(Router.create(PrefixComponent.class).route("/ulysses")).isAbsent(); - assertThat(Router.create(PrefixComponent.class).route("/man/of/sadness")).isAbsent(); + assertThat(Router.create(PrefixComponent.class).route("")).isEmpty(); + assertThat(Router.create(PrefixComponent.class).route("/")).isEmpty(); + assertThat(Router.create(PrefixComponent.class).route("/ulysses")).isEmpty(); + assertThat(Router.create(PrefixComponent.class).route("/man/of/sadness")).isEmpty(); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/javatests/google/registry/request/auth/BUILD b/javatests/google/registry/request/auth/BUILD index 52b29b327..6fb97a9e1 100644 --- a/javatests/google/registry/request/auth/BUILD +++ b/javatests/google/registry/request/auth/BUILD @@ -17,12 +17,13 @@ java_library( "//java/google/registry/security", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_appengine_tools_sdk", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/request/auth/RequestAuthenticatorTest.java b/javatests/google/registry/request/auth/RequestAuthenticatorTest.java index 86771f4fa..6ec9dd373 100644 --- a/javatests/google/registry/request/auth/RequestAuthenticatorTest.java +++ b/javatests/google/registry/request/auth/RequestAuthenticatorTest.java @@ -16,13 +16,13 @@ package google.registry.request.auth; import static com.google.common.net.HttpHeaders.AUTHORIZATION; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; import com.google.appengine.api.users.UserService; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.request.auth.RequestAuthenticator.AuthMethod; @@ -34,6 +34,7 @@ import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeOAuthService; import google.registry.testing.FakeUserService; +import java.util.Optional; import javax.servlet.http.HttpServletRequest; import org.junit.Before; import org.junit.Rule; @@ -155,7 +156,7 @@ public class RequestAuthenticatorTest { verifyZeroInteractions(mockUserService); assertThat(authResult).isPresent(); assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP); - assertThat(authResult.get().userAuthInfo()).isAbsent(); + assertThat(authResult.get().userAuthInfo()).isEmpty(); } @Test @@ -163,7 +164,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(mockUserService, AUTH_INTERNAL_ONLY); verifyZeroInteractions(mockUserService); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -175,14 +176,14 @@ public class RequestAuthenticatorTest { verifyZeroInteractions(mockUserService); assertThat(authResult).isPresent(); assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP); - assertThat(authResult.get().userAuthInfo()).isAbsent(); + assertThat(authResult.get().userAuthInfo()).isEmpty(); } @Test public void testAnyUserAnyMethod_notLoggedIn() throws Exception { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_ANY_METHOD); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -191,7 +192,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_ANY_METHOD); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -207,7 +208,7 @@ public class RequestAuthenticatorTest { assertThat(authResult.get().userAuthInfo()).isPresent(); assertThat(authResult.get().userAuthInfo().get().user()).isEqualTo(testUser); assertThat(authResult.get().userAuthInfo().get().isUserAdmin()).isFalse(); - assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isAbsent(); + assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isEmpty(); } @Test @@ -221,14 +222,14 @@ public class RequestAuthenticatorTest { assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.USER); assertThat(authResult.get().userAuthInfo()).isPresent(); assertThat(authResult.get().userAuthInfo().get().user()).isEqualTo(testUser); - assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isAbsent(); + assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isEmpty(); } @Test public void testAdminUserAnyMethod_notLoggedIn() throws Exception { Optional authResult = runTest(fakeUserService, AUTH_ADMIN_USER_ANY_METHOD); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -237,7 +238,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ADMIN_USER_ANY_METHOD); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -246,7 +247,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ADMIN_USER_ANY_METHOD); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -262,7 +263,7 @@ public class RequestAuthenticatorTest { assertThat(authResult.get().userAuthInfo()).isPresent(); assertThat(authResult.get().userAuthInfo().get().user()).isEqualTo(testUser); assertThat(authResult.get().userAuthInfo().get().isUserAdmin()).isTrue(); - assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isAbsent(); + assertThat(authResult.get().userAuthInfo().get().oauthTokenInfo()).isEmpty(); } @Test @@ -317,7 +318,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_NO_LEGACY); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -329,7 +330,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_NO_LEGACY); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -341,7 +342,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_NO_LEGACY); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -353,7 +354,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_NO_LEGACY); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test @@ -385,7 +386,7 @@ public class RequestAuthenticatorTest { Optional authResult = runTest(fakeUserService, AUTH_ANY_USER_NO_LEGACY); - assertThat(authResult).isAbsent(); + assertThat(authResult).isEmpty(); } @Test diff --git a/javatests/google/registry/request/lock/BUILD b/javatests/google/registry/request/lock/BUILD index 3db972a51..222db1dc1 100644 --- a/javatests/google/registry/request/lock/BUILD +++ b/javatests/google/registry/request/lock/BUILD @@ -16,12 +16,13 @@ java_library( "//java/google/registry/request/lock", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_tools_appengine_gcs_client", "@com_google_appengine_tools_sdk", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/request/lock/LockHandlerImplTest.java b/javatests/google/registry/request/lock/LockHandlerImplTest.java index 8180f7922..06a44227a 100644 --- a/javatests/google/registry/request/lock/LockHandlerImplTest.java +++ b/javatests/google/registry/request/lock/LockHandlerImplTest.java @@ -15,15 +15,16 @@ package google.registry.request.lock; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.google.common.base.Optional; import google.registry.model.server.Lock; import google.registry.testing.AppEngineRule; import google.registry.testing.ExceptionRule; +import java.util.Optional; import java.util.concurrent.Callable; import javax.annotation.Nullable; import org.joda.time.Duration; @@ -77,7 +78,7 @@ public final class LockHandlerImplTest { assertThat(resourceName).isEqualTo("resourceName"); assertThat(tld).isEqualTo("tld"); assertThat(leaseLength).isEqualTo(ONE_DAY); - return Optional.fromNullable(acquiredLock); + return Optional.ofNullable(acquiredLock); } }; diff --git a/javatests/google/registry/security/BUILD b/javatests/google/registry/security/BUILD index 548573d8a..3f92706cc 100644 --- a/javatests/google/registry/security/BUILD +++ b/javatests/google/registry/security/BUILD @@ -17,10 +17,11 @@ java_library( "//java/google/registry/security", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_testing", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_servlet_api", "@joda_time", diff --git a/javatests/google/registry/security/JsonHttpTest.java b/javatests/google/registry/security/JsonHttpTest.java index 4a78fac1b..e42ee6d51 100644 --- a/javatests/google/registry/security/JsonHttpTest.java +++ b/javatests/google/registry/security/JsonHttpTest.java @@ -19,6 +19,7 @@ import static com.google.common.net.HttpHeaders.X_CONTENT_TYPE_OPTIONS; import static com.google.common.net.MediaType.JSON_UTF_8; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_16; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/javatests/google/registry/security/JsonHttpTestUtils.java b/javatests/google/registry/security/JsonHttpTestUtils.java index 1b33c3868..3910ca837 100644 --- a/javatests/google/registry/security/JsonHttpTestUtils.java +++ b/javatests/google/registry/security/JsonHttpTestUtils.java @@ -17,6 +17,7 @@ package google.registry.security; import static com.google.common.base.Suppliers.memoize; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.security.JsonHttp.JSON_SAFETY_PREFIX; import com.google.common.base.Supplier; diff --git a/javatests/google/registry/security/XsrfTokenManagerTest.java b/javatests/google/registry/security/XsrfTokenManagerTest.java index 53d9d80f7..9476fcbdb 100644 --- a/javatests/google/registry/security/XsrfTokenManagerTest.java +++ b/javatests/google/registry/security/XsrfTokenManagerTest.java @@ -15,6 +15,7 @@ package google.registry.security; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.appengine.api.users.User; diff --git a/javatests/google/registry/server/StaticResourceServlet.java b/javatests/google/registry/server/StaticResourceServlet.java index d934fa789..1480a7d72 100644 --- a/javatests/google/registry/server/StaticResourceServlet.java +++ b/javatests/google/registry/server/StaticResourceServlet.java @@ -19,7 +19,6 @@ import static com.google.common.base.Verify.verify; import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.net.MediaType; import com.google.common.primitives.Ints; @@ -28,6 +27,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Optional; import javax.annotation.PostConstruct; import javax.servlet.ServletConfig; import javax.servlet.http.HttpServlet; @@ -86,7 +86,7 @@ public final class StaticResourceServlet extends HttpServlet { return holder; } - private Optional fileServer = Optional.absent(); + private Optional fileServer = Optional.empty(); @Override @PostConstruct @@ -124,12 +124,12 @@ public final class StaticResourceServlet extends HttpServlet { if (!Files.exists(file)) { logger.infofmt("Not found: %s (%s)", req.getRequestURI(), file); rsp.sendError(SC_NOT_FOUND, "Not found"); - return Optional.absent(); + return Optional.empty(); } if (Files.isDirectory(file)) { logger.infofmt("Directory listing forbidden: %s (%s)", req.getRequestURI(), file); rsp.sendError(SC_FORBIDDEN, "No directory listing"); - return Optional.absent(); + return Optional.empty(); } rsp.setContentType( MIMES_BY_EXTENSION @@ -140,8 +140,9 @@ public final class StaticResourceServlet extends HttpServlet { } void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException { - for (Path file : doHead(req, rsp).asSet()) { - rsp.getOutputStream().write(Files.readAllBytes(file)); + Optional file = doHead(req, rsp); + if (file.isPresent()) { + rsp.getOutputStream().write(Files.readAllBytes(file.get())); } } } diff --git a/javatests/google/registry/storage/drive/BUILD b/javatests/google/registry/storage/drive/BUILD index dc92f7a25..14f041349 100644 --- a/javatests/google/registry/storage/drive/BUILD +++ b/javatests/google/registry/storage/drive/BUILD @@ -13,10 +13,11 @@ java_library( deps = [ "//java/google/registry/storage/drive", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_apis_google_api_services_drive", "@com_google_guava", "@com_google_http_client", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_mockito_all", ], diff --git a/javatests/google/registry/storage/drive/DriveConnectionTest.java b/javatests/google/registry/storage/drive/DriveConnectionTest.java index 5ec47b9f0..ca275105a 100644 --- a/javatests/google/registry/storage/drive/DriveConnectionTest.java +++ b/javatests/google/registry/storage/drive/DriveConnectionTest.java @@ -16,6 +16,7 @@ package google.registry.storage.drive; import static com.google.common.io.ByteStreams.toByteArray; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; diff --git a/javatests/google/registry/testing/AbstractEppResourceSubject.java b/javatests/google/registry/testing/AbstractEppResourceSubject.java index 93c9477a9..17bb056f4 100644 --- a/javatests/google/registry/testing/AbstractEppResourceSubject.java +++ b/javatests/google/registry/testing/AbstractEppResourceSubject.java @@ -16,6 +16,7 @@ package google.registry.testing; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.isActive; import static google.registry.testing.DatastoreHelper.getHistoryEntriesOfType; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; diff --git a/javatests/google/registry/testing/BUILD b/javatests/google/registry/testing/BUILD index f13daaeb4..ebc11d7b4 100644 --- a/javatests/google/registry/testing/BUILD +++ b/javatests/google/registry/testing/BUILD @@ -34,7 +34,6 @@ java_library( "//java/google/registry/util", "//java/google/registry/xml", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_stubs", "@com_google_appengine_testing", @@ -45,6 +44,8 @@ java_library( "@com_google_dagger", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_inject", "@javax_servlet_api", diff --git a/javatests/google/registry/testing/DatastoreHelper.java b/javatests/google/registry/testing/DatastoreHelper.java index 929e6cceb..06a2dcc0c 100644 --- a/javatests/google/registry/testing/DatastoreHelper.java +++ b/javatests/google/registry/testing/DatastoreHelper.java @@ -103,6 +103,7 @@ import google.registry.model.transfer.TransferStatus; import google.registry.tmch.LordnTask; import java.util.Arrays; import java.util.List; +import java.util.Set; import javax.annotation.Nullable; import org.joda.money.Money; import org.joda.time.DateTime; @@ -678,7 +679,7 @@ public class DatastoreHelper { } /** Assert that the expected billing events set is exactly the one found in the fake Datastore. */ - public static void assertBillingEvents(ImmutableSet expected) throws Exception { + public static void assertBillingEvents(Set expected) throws Exception { assertBillingEventsEqual(getBillingEvents(), expected); } diff --git a/javatests/google/registry/testing/DomainApplicationSubject.java b/javatests/google/registry/testing/DomainApplicationSubject.java index d81321d1d..9103dbc8b 100644 --- a/javatests/google/registry/testing/DomainApplicationSubject.java +++ b/javatests/google/registry/testing/DomainApplicationSubject.java @@ -17,6 +17,7 @@ package google.registry.testing; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableSet; import com.google.common.truth.FailureStrategy; diff --git a/javatests/google/registry/testing/EppExceptionSubject.java b/javatests/google/registry/testing/EppExceptionSubject.java index 905456685..d9225aecc 100644 --- a/javatests/google/registry/testing/EppExceptionSubject.java +++ b/javatests/google/registry/testing/EppExceptionSubject.java @@ -16,6 +16,7 @@ package google.registry.testing; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.marshal; import com.google.common.truth.FailureStrategy; diff --git a/javatests/google/registry/testing/EppMetricSubject.java b/javatests/google/registry/testing/EppMetricSubject.java index d6bbbb141..24052ae6c 100644 --- a/javatests/google/registry/testing/EppMetricSubject.java +++ b/javatests/google/registry/testing/EppMetricSubject.java @@ -17,7 +17,6 @@ package google.registry.testing; import static com.google.common.truth.Truth.assertAbout; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; -import com.google.common.base.Optional; import com.google.common.truth.FailureStrategy; import com.google.common.truth.Subject; import com.google.common.truth.SubjectFactory; @@ -25,6 +24,7 @@ import google.registry.model.eppoutput.Result.Code; import google.registry.monitoring.whitebox.EppMetric; import google.registry.testing.TruthChainer.And; import java.util.Objects; +import java.util.Optional; import javax.annotation.Nullable; /** Utility methods for asserting things about {@link EppMetric} instances. */ diff --git a/javatests/google/registry/testing/HistoryEntrySubject.java b/javatests/google/registry/testing/HistoryEntrySubject.java index 8417cb027..07703e67c 100644 --- a/javatests/google/registry/testing/HistoryEntrySubject.java +++ b/javatests/google/registry/testing/HistoryEntrySubject.java @@ -16,7 +16,6 @@ package google.registry.testing; import static com.google.common.truth.Truth.assertAbout; -import com.google.common.base.Optional; import com.google.common.truth.FailureStrategy; import com.google.common.truth.SimpleSubjectBuilder; import com.google.common.truth.Subject; @@ -24,6 +23,7 @@ import google.registry.model.domain.Period; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.TruthChainer.And; import java.util.Objects; +import java.util.Optional; /** Utility methods for asserting things about {@link HistoryEntry} instances. */ public class HistoryEntrySubject extends Subject { @@ -40,7 +40,7 @@ public class HistoryEntrySubject extends Subject new Property(k, Optional.fromNullable(System.getProperty(k)))); - Property property = new Property(key, Optional.fromNullable(value)); + key, k -> new Property(k, Optional.ofNullable(System.getProperty(k)))); + Property property = new Property(key, Optional.ofNullable(value)); if (isRunning) { property.set(); } else { diff --git a/javatests/google/registry/testing/TaskQueueHelper.java b/javatests/google/registry/testing/TaskQueueHelper.java index 8d59e1785..b9f13687f 100644 --- a/javatests/google/registry/testing/TaskQueueHelper.java +++ b/javatests/google/registry/testing/TaskQueueHelper.java @@ -23,6 +23,7 @@ import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Multisets.containsOccurrences; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; diff --git a/javatests/google/registry/testing/mapreduce/BUILD b/javatests/google/registry/testing/mapreduce/BUILD index 5fd5c245d..81083558c 100644 --- a/javatests/google/registry/testing/mapreduce/BUILD +++ b/javatests/google/registry/testing/mapreduce/BUILD @@ -16,7 +16,6 @@ java_library( "//java/google/registry/model", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_stubs", "@com_google_appengine_testing", @@ -24,6 +23,8 @@ java_library( "@com_google_appengine_tools_appengine_pipeline", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/testing/mapreduce/MapreduceTestCase.java b/javatests/google/registry/testing/mapreduce/MapreduceTestCase.java index 2f8868bce..ef57c7d46 100644 --- a/javatests/google/registry/testing/mapreduce/MapreduceTestCase.java +++ b/javatests/google/registry/testing/mapreduce/MapreduceTestCase.java @@ -15,6 +15,7 @@ package google.registry.testing.mapreduce; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount; import static google.registry.model.ofy.ObjectifyService.ofy; import static org.mockito.Mockito.mock; @@ -33,7 +34,6 @@ import com.google.appengine.tools.pipeline.impl.servlets.PipelineServlet; import com.google.appengine.tools.pipeline.impl.servlets.TaskHandler; import com.google.apphosting.api.ApiProxy; import com.google.common.base.CharMatcher; -import com.google.common.base.Optional; import google.registry.mapreduce.MapreduceRunner; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; @@ -47,6 +47,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -178,7 +179,7 @@ public abstract class MapreduceTestCase extends ShardableTestCase { */ protected void executeTasksUntilEmpty(String queueName, @Nullable FakeClock clock) throws Exception { - executeTasks(queueName, clock, Optional.absent()); + executeTasks(queueName, clock, Optional.empty()); } /** diff --git a/javatests/google/registry/tldconfig/idn/BUILD b/javatests/google/registry/tldconfig/idn/BUILD index c478e4d15..de5ebcc54 100644 --- a/javatests/google/registry/tldconfig/idn/BUILD +++ b/javatests/google/registry/tldconfig/idn/BUILD @@ -15,8 +15,9 @@ java_library( deps = [ "//java/google/registry/tldconfig/idn", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", ], ) diff --git a/javatests/google/registry/tldconfig/idn/IdnLabelValidatorTest.java b/javatests/google/registry/tldconfig/idn/IdnLabelValidatorTest.java index 56945d1e2..61d7e5f52 100644 --- a/javatests/google/registry/tldconfig/idn/IdnLabelValidatorTest.java +++ b/javatests/google/registry/tldconfig/idn/IdnLabelValidatorTest.java @@ -15,6 +15,7 @@ package google.registry.tldconfig.idn; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.tldconfig.idn.IdnLabelValidator.findValidIdnTableForTld; import com.google.common.collect.ImmutableList; @@ -45,10 +46,10 @@ public class IdnLabelValidatorTest { // This should fail since it mixes Japanese characters with extended Latin characters. These are // allowed individually, but not together, since they are in separate IDN tables. - assertThat(findValidIdnTableForTld("みんなアシヨわみけæ", tld)).isAbsent(); + assertThat(findValidIdnTableForTld("みんなアシヨわみけæ", tld)).isEmpty(); // This fails because it has Cyrillic characters, which just aren't allowed in either IDN table. - assertThat(findValidIdnTableForTld("aЖЗ", tld)).isAbsent(); + assertThat(findValidIdnTableForTld("aЖЗ", tld)).isEmpty(); assertThat(findValidIdnTableForTld("abcdefghæ", tld)).isPresent(); assertThat(findValidIdnTableForTld("happy", tld)).isPresent(); @@ -69,24 +70,24 @@ public class IdnLabelValidatorTest { // These fail because they have a KATAKANA MIDDLE DOT or IDEOGRAPHIC_CLOSING_MARK without any // Japanese non-exception characters. - assertThat(findValidIdnTableForTld("eco・driving", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("・ー・", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("〆〆example・・", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("abc〆", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("〆xyz", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("〆bar・", tld)).isAbsent(); + assertThat(findValidIdnTableForTld("eco・driving", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("・ー・", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("〆〆example・・", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("abc〆", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("〆xyz", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("〆bar・", tld)).isEmpty(); // This is a Japanese label with exactly 15 characters. assertThat(findValidIdnTableForTld("カレー・ライスaaaaaaaa", tld)).isPresent(); // Should fail since it has Japanese characters but is more than 15 characters long. - assertThat(findValidIdnTableForTld("カレー・ライスaaaaaaaaa", tld)).isAbsent(); + assertThat(findValidIdnTableForTld("カレー・ライスaaaaaaaaa", tld)).isEmpty(); // Should fail since it has a prolonged sound mark that is not preceded by Hiragana or Katakana // characters. - assertThat(findValidIdnTableForTld("aー", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("-ー", tld)).isAbsent(); - assertThat(findValidIdnTableForTld("0ー", tld)).isAbsent(); + assertThat(findValidIdnTableForTld("aー", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("-ー", tld)).isEmpty(); + assertThat(findValidIdnTableForTld("0ー", tld)).isEmpty(); } @Test @@ -112,6 +113,6 @@ public class IdnLabelValidatorTest { "idnTableListsPerTld", ImmutableMap.of("tld", ImmutableList.of(IdnTableEnum.EXTENDED_LATIN))); assertThat(findValidIdnTableForTld("foo", "tld")).isPresent(); - assertThat(findValidIdnTableForTld("みんな", "tld")).isAbsent(); + assertThat(findValidIdnTableForTld("みんな", "tld")).isEmpty(); } } diff --git a/javatests/google/registry/tldconfig/idn/IdnTableTest.java b/javatests/google/registry/tldconfig/idn/IdnTableTest.java index 899b0bba2..d39ed5f08 100644 --- a/javatests/google/registry/tldconfig/idn/IdnTableTest.java +++ b/javatests/google/registry/tldconfig/idn/IdnTableTest.java @@ -15,11 +15,12 @@ package google.registry.tldconfig.idn; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.testing.ExceptionRule; import java.net.URI; +import java.util.Optional; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,7 +49,7 @@ public class IdnTableTest { "U+0038", "U+0039"); IdnTable idnTable = - IdnTable.createFrom("lolcatattack", of, Optional.absent()); + IdnTable.createFrom("lolcatattack", of, Optional.empty()); assertThat(idnTable.isValidLabel("0123456789")).isTrue(); assertThat(idnTable.isValidLabel("54321a")).isFalse(); assertThat(idnTable.isValidLabel("AAA000")).isFalse(); @@ -70,7 +71,7 @@ public class IdnTableTest { "U+0036", "U+0037", "U+0038", - "U+0039"), Optional.absent()); + "U+0039"), Optional.empty()); assertThat(idnTable.isValidLabel("0123456789")).isFalse(); assertThat(idnTable.isValidLabel("023456789")).isTrue(); // Works when you remove 1 } @@ -84,7 +85,7 @@ public class IdnTableTest { "U+0036", "U+0037", "U+2070E", - "U+20731"), Optional.absent()); + "U+20731"), Optional.empty()); assertThat(idnTable.getName()).isEqualTo("lolcatattack"); assertThat(idnTable.isValidLabel("𠜎")).isTrue(); assertThat(idnTable.isValidLabel("𠜱")).isTrue(); @@ -99,7 +100,7 @@ public class IdnTableTest { "# URL: https://love.example/lolcatattack.txt", "# Policy: https://love.example/policy.html"); IdnTable idnTable = - IdnTable.createFrom("lolcatattack", of, Optional.absent()); + 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")); } @@ -109,7 +110,7 @@ public class IdnTableTest { ImmutableList of = ImmutableList.of( "# Policy: https://love.example/policy.html"); thrown.expect(NullPointerException.class, "sloth missing '# URL:"); - IdnTable.createFrom("sloth", of, Optional.absent()); + IdnTable.createFrom("sloth", of, Optional.empty()); } @Test @@ -117,6 +118,6 @@ public class IdnTableTest { ImmutableList of = ImmutableList.of( "# URL: https://love.example/sloth.txt"); thrown.expect(NullPointerException.class, "sloth missing '# Policy:"); - IdnTable.createFrom("sloth", of, Optional.absent()); + IdnTable.createFrom("sloth", of, Optional.empty()); } } diff --git a/javatests/google/registry/tmch/BUILD b/javatests/google/registry/tmch/BUILD index b5763d675..df90894f5 100644 --- a/javatests/google/registry/tmch/BUILD +++ b/javatests/google/registry/tmch/BUILD @@ -24,10 +24,11 @@ java_library( "//java/google/registry/util", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/tmch/LordnLogTest.java b/javatests/google/registry/tmch/LordnLogTest.java index ae48f4d98..950d4e1ac 100644 --- a/javatests/google/registry/tmch/LordnLogTest.java +++ b/javatests/google/registry/tmch/LordnLogTest.java @@ -15,6 +15,7 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableList; import google.registry.testing.ExceptionRule; diff --git a/javatests/google/registry/tmch/LordnTaskTest.java b/javatests/google/registry/tmch/LordnTaskTest.java index 0b5982622..9fae3b8a9 100644 --- a/javatests/google/registry/tmch/LordnTaskTest.java +++ b/javatests/google/registry/tmch/LordnTaskTest.java @@ -15,6 +15,7 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; diff --git a/javatests/google/registry/tmch/NordnUploadActionTest.java b/javatests/google/registry/tmch/NordnUploadActionTest.java index 73d0dfd34..c6ed2b3ba 100644 --- a/javatests/google/registry/tmch/NordnUploadActionTest.java +++ b/javatests/google/registry/tmch/NordnUploadActionTest.java @@ -19,6 +19,7 @@ import static com.google.common.net.HttpHeaders.CONTENT_TYPE; import static com.google.common.net.HttpHeaders.LOCATION; import static com.google.common.net.MediaType.FORM_DATA; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.newDomainResource; @@ -37,7 +38,6 @@ 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; -import com.google.common.base.Optional; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableList; import google.registry.model.domain.DomainResource; @@ -51,6 +51,7 @@ import google.registry.testing.InjectRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.util.UrlFetchException; import java.net.URL; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; @@ -155,10 +156,10 @@ public class NordnUploadActionTest { @Test public void testRun_noPassword_doesntSendAuthorizationHeader() throws Exception { - lordnRequestInitializer.marksdbLordnPassword = Optional.absent(); + lordnRequestInitializer.marksdbLordnPassword = Optional.empty(); persistClaimsModeDomain(); action.run(); - assertThat(getHeaderFirst(getCapturedHttpRequest(), AUTHORIZATION)).isAbsent(); + assertThat(getHeaderFirst(getCapturedHttpRequest(), AUTHORIZATION)).isEmpty(); } @Test diff --git a/javatests/google/registry/tmch/NordnVerifyActionTest.java b/javatests/google/registry/tmch/NordnVerifyActionTest.java index a0569a697..a80e251d5 100644 --- a/javatests/google/registry/tmch/NordnVerifyActionTest.java +++ b/javatests/google/registry/tmch/NordnVerifyActionTest.java @@ -16,6 +16,7 @@ package google.registry.tmch; import static com.google.common.net.HttpHeaders.AUTHORIZATION; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.util.UrlFetchUtils.getHeaderFirst; @@ -30,13 +31,13 @@ import static org.mockito.Mockito.when; import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.URLFetchService; -import com.google.common.base.Optional; import google.registry.model.registry.Registry; import google.registry.request.HttpException.ConflictException; import google.registry.testing.AppEngineRule; import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; import java.net.URL; +import java.util.Optional; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -138,9 +139,9 @@ public class NordnVerifyActionTest { @Test public void testSuccess_noLordnPassword_doesntSetAuthorizationHeader() throws Exception { - lordnRequestInitializer.marksdbLordnPassword = Optional.absent(); + lordnRequestInitializer.marksdbLordnPassword = Optional.empty(); action.run(); - assertThat(getHeaderFirst(getCapturedHttpRequest(), AUTHORIZATION)).isAbsent(); + assertThat(getHeaderFirst(getCapturedHttpRequest(), AUTHORIZATION)).isEmpty(); } @Test diff --git a/javatests/google/registry/tmch/SmdrlCsvParserTest.java b/javatests/google/registry/tmch/SmdrlCsvParserTest.java index 610887c2f..69b29d787 100644 --- a/javatests/google/registry/tmch/SmdrlCsvParserTest.java +++ b/javatests/google/registry/tmch/SmdrlCsvParserTest.java @@ -15,6 +15,7 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.US_ASCII; import static org.joda.time.Duration.millis; import static org.joda.time.Duration.standardDays; diff --git a/javatests/google/registry/tmch/TmchCrlActionTest.java b/javatests/google/registry/tmch/TmchCrlActionTest.java index 770b5dee8..26d8544ab 100644 --- a/javatests/google/registry/tmch/TmchCrlActionTest.java +++ b/javatests/google/registry/tmch/TmchCrlActionTest.java @@ -15,6 +15,7 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.ResourceUtils.readResourceBytes; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/javatests/google/registry/tmch/TmchDnlActionTest.java b/javatests/google/registry/tmch/TmchDnlActionTest.java index 24dd96241..6d787f855 100644 --- a/javatests/google/registry/tmch/TmchDnlActionTest.java +++ b/javatests/google/registry/tmch/TmchDnlActionTest.java @@ -15,12 +15,13 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import google.registry.model.tmch.ClaimsListShard; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Test; diff --git a/javatests/google/registry/tmch/TmchSmdrlActionTest.java b/javatests/google/registry/tmch/TmchSmdrlActionTest.java index b958068e9..2cfa3d521 100644 --- a/javatests/google/registry/tmch/TmchSmdrlActionTest.java +++ b/javatests/google/registry/tmch/TmchSmdrlActionTest.java @@ -15,13 +15,14 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.tmch.TmchTestData.loadBytes; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import google.registry.model.smd.SignedMarkRevocationList; +import java.util.Optional; import org.joda.time.DateTime; import org.junit.Test; @@ -33,7 +34,7 @@ public class TmchSmdrlActionTest extends TmchActionTestCase { private TmchSmdrlAction newTmchSmdrlAction() { TmchSmdrlAction action = new TmchSmdrlAction(); action.marksdb = marksdb; - action.marksdbSmdrlLogin = Optional.absent(); + action.marksdbSmdrlLogin = Optional.empty(); return action; } diff --git a/javatests/google/registry/tools/AllocateDomainCommandTest.java b/javatests/google/registry/tools/AllocateDomainCommandTest.java index 5b06af429..1f6470afc 100644 --- a/javatests/google/registry/tools/AllocateDomainCommandTest.java +++ b/javatests/google/registry/tools/AllocateDomainCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.flows.EppXmlTransformer.unmarshal; import static google.registry.flows.picker.FlowPicker.getFlowClass; import static google.registry.model.domain.DesignatedContact.Type.ADMIN; diff --git a/javatests/google/registry/tools/AuthModuleTest.java b/javatests/google/registry/tools/AuthModuleTest.java index 9d501c7e4..72675e130 100644 --- a/javatests/google/registry/tools/AuthModuleTest.java +++ b/javatests/google/registry/tools/AuthModuleTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/javatests/google/registry/tools/BUILD b/javatests/google/registry/tools/BUILD index 7b81bddd1..eac99cb52 100644 --- a/javatests/google/registry/tools/BUILD +++ b/javatests/google/registry/tools/BUILD @@ -37,7 +37,6 @@ java_library( "//javatests/google/registry/tools/server", "//javatests/google/registry/xml", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_beust_jcommander", "@com_google_api_client", "@com_google_apis_google_api_services_dns", @@ -50,6 +49,8 @@ java_library( "@com_google_http_client_jackson2", "@com_google_oauth_client", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_inject", "@joda_time", diff --git a/javatests/google/registry/tools/CommandTestCase.java b/javatests/google/registry/tools/CommandTestCase.java index 8858e8768..f1295857c 100644 --- a/javatests/google/registry/tools/CommandTestCase.java +++ b/javatests/google/registry/tools/CommandTestCase.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.toArray; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/tools/ComparableEntityTest.java b/javatests/google/registry/tools/ComparableEntityTest.java index d1f71093e..a9fec983e 100644 --- a/javatests/google/registry/tools/ComparableEntityTest.java +++ b/javatests/google/registry/tools/ComparableEntityTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.appengine.api.datastore.Entity; import com.google.appengine.api.datastore.EntityTranslator; diff --git a/javatests/google/registry/tools/CompareDbBackupsTest.java b/javatests/google/registry/tools/CompareDbBackupsTest.java index 37d9313e8..7e9b90fa8 100644 --- a/javatests/google/registry/tools/CompareDbBackupsTest.java +++ b/javatests/google/registry/tools/CompareDbBackupsTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import google.registry.testing.AppEngineRule; diff --git a/javatests/google/registry/tools/CreateCdnsTldTest.java b/javatests/google/registry/tools/CreateCdnsTldTest.java index 2c3ecab62..f7d6bfa32 100644 --- a/javatests/google/registry/tools/CreateCdnsTldTest.java +++ b/javatests/google/registry/tools/CreateCdnsTldTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/javatests/google/registry/tools/CreateCreditBalanceCommandTest.java b/javatests/google/registry/tools/CreateCreditBalanceCommandTest.java index 069ecab36..22f513e42 100644 --- a/javatests/google/registry/tools/CreateCreditBalanceCommandTest.java +++ b/javatests/google/registry/tools/CreateCreditBalanceCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; diff --git a/javatests/google/registry/tools/CreateCreditCommandTest.java b/javatests/google/registry/tools/CreateCreditCommandTest.java index 5d20d7b6d..d0e71ecbc 100644 --- a/javatests/google/registry/tools/CreateCreditCommandTest.java +++ b/javatests/google/registry/tools/CreateCreditCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; diff --git a/javatests/google/registry/tools/CreateLrpTokensCommandTest.java b/javatests/google/registry/tools/CreateLrpTokensCommandTest.java index a89f3f6ba..a45051b58 100644 --- a/javatests/google/registry/tools/CreateLrpTokensCommandTest.java +++ b/javatests/google/registry/tools/CreateLrpTokensCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/tools/CreateOrUpdatePremiumListCommandTestCase.java b/javatests/google/registry/tools/CreateOrUpdatePremiumListCommandTestCase.java index 99650729f..0a156c898 100644 --- a/javatests/google/registry/tools/CreateOrUpdatePremiumListCommandTestCase.java +++ b/javatests/google/registry/tools/CreateOrUpdatePremiumListCommandTestCase.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; diff --git a/javatests/google/registry/tools/CreateRegistrarCommandTest.java b/javatests/google/registry/tools/CreateRegistrarCommandTest.java index 229c3d8ae..6d699c3df 100644 --- a/javatests/google/registry/tools/CreateRegistrarCommandTest.java +++ b/javatests/google/registry/tools/CreateRegistrarCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; @@ -27,7 +28,6 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.beust.jcommander.ParameterException; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Range; import com.google.common.net.MediaType; @@ -35,6 +35,7 @@ import google.registry.model.registrar.Registrar; import google.registry.testing.CertificateSamples; import google.registry.tools.ServerSideCommand.Connection; import java.io.IOException; +import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.time.DateTime; import org.junit.Before; diff --git a/javatests/google/registry/tools/CreateReservedListCommandTest.java b/javatests/google/registry/tools/CreateReservedListCommandTest.java index d46507a2e..048bc430c 100644 --- a/javatests/google/registry/tools/CreateReservedListCommandTest.java +++ b/javatests/google/registry/tools/CreateReservedListCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.persistReservedList; @@ -174,7 +175,7 @@ public class CreateReservedListCommandTest extends runCommandForced("--name=" + name, "--input=" + reservedTermsPath); assertWithMessage("Expected IllegalArgumentException to be thrown").fail(); } catch (IllegalArgumentException e) { - assertThat(ReservedList.get(name)).isAbsent(); + assertThat(ReservedList.get(name)).isEmpty(); assertThat(e).hasMessageThat().isEqualTo(expectedErrorMsg); } } diff --git a/javatests/google/registry/tools/CreateTldCommandTest.java b/javatests/google/registry/tools/CreateTldCommandTest.java index 2294abd13..1df04498b 100644 --- a/javatests/google/registry/tools/CreateTldCommandTest.java +++ b/javatests/google/registry/tools/CreateTldCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistPremiumList; diff --git a/javatests/google/registry/tools/DefaultRequestFactoryModuleTest.java b/javatests/google/registry/tools/DefaultRequestFactoryModuleTest.java index 58dba7181..0627c4caa 100644 --- a/javatests/google/registry/tools/DefaultRequestFactoryModuleTest.java +++ b/javatests/google/registry/tools/DefaultRequestFactoryModuleTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.http.HttpRequest; diff --git a/javatests/google/registry/tools/DeleteCreditCommandTest.java b/javatests/google/registry/tools/DeleteCreditCommandTest.java index 73c95a420..00f0fec90 100644 --- a/javatests/google/registry/tools/DeleteCreditCommandTest.java +++ b/javatests/google/registry/tools/DeleteCreditCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; diff --git a/javatests/google/registry/tools/DeletePremiumListCommandTest.java b/javatests/google/registry/tools/DeletePremiumListCommandTest.java index 7b85586d8..503a98be6 100644 --- a/javatests/google/registry/tools/DeletePremiumListCommandTest.java +++ b/javatests/google/registry/tools/DeletePremiumListCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadPremiumListEntries; @@ -35,7 +36,7 @@ public class DeletePremiumListCommandTest extends CommandTestCase } else { runCommand(tldsParameter); } - verifySent(null, Optional.absent(), Optional.absent()); + verifySent(null, Optional.empty(), Optional.empty()); } @Test @@ -115,7 +115,7 @@ public abstract class ListObjectsCommandTestCase } else { runCommand("--fields=fieldName", tldsParameter); } - verifySent("fieldName", Optional.absent(), Optional.absent()); + verifySent("fieldName", Optional.empty(), Optional.empty()); } @Test @@ -125,7 +125,7 @@ public abstract class ListObjectsCommandTestCase } else { runCommand("--fields=*", tldsParameter); } - verifySent("*", Optional.absent(), Optional.absent()); + verifySent("*", Optional.empty(), Optional.empty()); } @Test @@ -135,7 +135,7 @@ public abstract class ListObjectsCommandTestCase } else { runCommand("--fields=fieldName", "--header=true", tldsParameter); } - verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.absent()); + verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.empty()); } @Test @@ -145,7 +145,7 @@ public abstract class ListObjectsCommandTestCase } else { runCommand("--fields=fieldName", "--header=false", tldsParameter); } - verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.absent()); + verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.empty()); } @Test @@ -155,7 +155,7 @@ public abstract class ListObjectsCommandTestCase } else { runCommand("--fields=fieldName", "--full_field_names", tldsParameter); } - verifySent("fieldName", Optional.absent(), Optional.of(Boolean.TRUE)); + verifySent("fieldName", Optional.empty(), Optional.of(Boolean.TRUE)); } @Test diff --git a/javatests/google/registry/tools/MutatingCommandTest.java b/javatests/google/registry/tools/MutatingCommandTest.java index a2f8ca994..4022a9d8a 100644 --- a/javatests/google/registry/tools/MutatingCommandTest.java +++ b/javatests/google/registry/tools/MutatingCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.deleteResource; diff --git a/javatests/google/registry/tools/RecordAccumulatorTest.java b/javatests/google/registry/tools/RecordAccumulatorTest.java index ea15e3742..879b0706b 100644 --- a/javatests/google/registry/tools/RecordAccumulatorTest.java +++ b/javatests/google/registry/tools/RecordAccumulatorTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableSet; import google.registry.testing.AppEngineRule; diff --git a/javatests/google/registry/tools/RegistrarContactCommandTest.java b/javatests/google/registry/tools/RegistrarContactCommandTest.java index d9352f882..1e4d993a1 100644 --- a/javatests/google/registry/tools/RegistrarContactCommandTest.java +++ b/javatests/google/registry/tools/RegistrarContactCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registrar.RegistrarContact.Type.ABUSE; import static google.registry.model.registrar.RegistrarContact.Type.ADMIN; import static google.registry.model.registrar.RegistrarContact.Type.TECH; diff --git a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java index 0dc8eeb84..e9815a31f 100644 --- a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java +++ b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.ExceptionRule; import org.junit.Rule; diff --git a/javatests/google/registry/tools/RegistryToolTest.java b/javatests/google/registry/tools/RegistryToolTest.java index 96b98b6fa..b49814bc6 100644 --- a/javatests/google/registry/tools/RegistryToolTest.java +++ b/javatests/google/registry/tools/RegistryToolTest.java @@ -18,6 +18,7 @@ import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.reflect.Reflection.getPackageName; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/tools/ResaveEntitiesCommandTest.java b/javatests/google/registry/tools/ResaveEntitiesCommandTest.java index dd5076a3f..c9fb6ddc8 100644 --- a/javatests/google/registry/tools/ResaveEntitiesCommandTest.java +++ b/javatests/google/registry/tools/ResaveEntitiesCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.persistActiveContact; diff --git a/javatests/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java b/javatests/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java index 7b754cd7e..785474b5f 100644 --- a/javatests/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java +++ b/javatests/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java @@ -17,6 +17,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.transform; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; diff --git a/javatests/google/registry/tools/ResaveEppResourcesCommandTest.java b/javatests/google/registry/tools/ResaveEppResourcesCommandTest.java index fd1f3f012..c38f74e8e 100644 --- a/javatests/google/registry/tools/ResaveEppResourcesCommandTest.java +++ b/javatests/google/registry/tools/ResaveEppResourcesCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.persistActiveContact; diff --git a/javatests/google/registry/tools/RestoreCommitLogsCommandTest.java b/javatests/google/registry/tools/RestoreCommitLogsCommandTest.java index dac5a8ffd..9584556c3 100644 --- a/javatests/google/registry/tools/RestoreCommitLogsCommandTest.java +++ b/javatests/google/registry/tools/RestoreCommitLogsCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; diff --git a/javatests/google/registry/tools/SetupOteCommandTest.java b/javatests/google/registry/tools/SetupOteCommandTest.java index 0b61bf857..cae9eb3f0 100644 --- a/javatests/google/registry/tools/SetupOteCommandTest.java +++ b/javatests/google/registry/tools/SetupOteCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registrar.Registrar.State.ACTIVE; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; diff --git a/javatests/google/registry/tools/UpdateApplicationStatusCommandTest.java b/javatests/google/registry/tools/UpdateApplicationStatusCommandTest.java index eef15bdc4..f37ff304c 100644 --- a/javatests/google/registry/tools/UpdateApplicationStatusCommandTest.java +++ b/javatests/google/registry/tools/UpdateApplicationStatusCommandTest.java @@ -16,6 +16,7 @@ package google.registry.tools; import static com.google.common.collect.Iterables.getLast; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.domain.launch.ApplicationStatus.ALLOCATED; import static google.registry.model.domain.launch.ApplicationStatus.PENDING_ALLOCATION; import static google.registry.model.domain.launch.ApplicationStatus.REJECTED; diff --git a/javatests/google/registry/tools/UpdateCursorsCommandTest.java b/javatests/google/registry/tools/UpdateCursorsCommandTest.java index 7e8aec0ec..ce20666a7 100644 --- a/javatests/google/registry/tools/UpdateCursorsCommandTest.java +++ b/javatests/google/registry/tools/UpdateCursorsCommandTest.java @@ -15,6 +15,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; @@ -57,7 +58,7 @@ public class UpdateCursorsCommandTest extends CommandTestCase field = FormField.named("lol").uppercased().build(); - assertThat(field.convert(null)).isAbsent(); + assertThat(field.convert(null)).isEmpty(); assertThat(field.convert("foo")).hasValue("FOO"); assertThat(field.convert("BAR")).hasValue("BAR"); } @@ -103,7 +104,7 @@ public class FormFieldTest { @Test public void testLowercased() { FormField field = FormField.named("lol").lowercased().build(); - assertThat(field.convert(null)).isAbsent(); + assertThat(field.convert(null)).isEmpty(); assertThat(field.convert("foo")).hasValue("foo"); assertThat(field.convert("BAR")).hasValue("bar"); } @@ -113,7 +114,7 @@ public class FormFieldTest { FormField field = FormField.named("lol") .in(ImmutableSet.of("foo", "bar")) .build(); - assertThat(field.convert(null)).isAbsent(); + assertThat(field.convert(null)).isEmpty(); } @Test @@ -136,7 +137,7 @@ public class FormFieldTest { @Test public void testRange_hasLowerBound_nullValue_passesThrough() { - assertThat(FormField.named("lol").range(atLeast(5)).build().convert(null)).isAbsent(); + assertThat(FormField.named("lol").range(atLeast(5)).build().convert(null)).isEmpty(); } @Test @@ -153,7 +154,7 @@ public class FormFieldTest { @Test public void testRange_noLowerBound_nullValue_passThrough() { - assertThat(FormField.named("lol").range(atMost(5)).build().convert(null)).isAbsent(); + assertThat(FormField.named("lol").range(atMost(5)).build().convert(null)).isEmpty(); } @Test @@ -235,7 +236,7 @@ public class FormFieldTest { @Test public void testAsList_null_notPresent() { - assertThat(FormField.named("lol").asList().build().convert(null)).isAbsent(); + assertThat(FormField.named("lol").asList().build().convert(null)).isEmpty(); } @Test @@ -262,7 +263,7 @@ public class FormFieldTest { .emptyToNull() .build() .convert(ImmutableList.of())) - .isAbsent(); + .isEmpty(); } @Test @@ -302,7 +303,7 @@ public class FormFieldTest { .containsExactly("oh", "my", "goth") .inOrder(); assertThat(field.convert("").get()).isEmpty(); - assertThat(field.convert(null)).isAbsent(); + assertThat(field.convert(null)).isEmpty(); } @Test @@ -315,7 +316,7 @@ public class FormFieldTest { .containsExactly("OH", "MY", "GOTH") .inOrder(); assertThat(field.convert("").get()).isEmpty(); - assertThat(field.convert(null)).isAbsent(); + assertThat(field.convert(null)).isEmpty(); } @Test diff --git a/javatests/google/registry/ui/forms/FormFieldsTest.java b/javatests/google/registry/ui/forms/FormFieldsTest.java index 7db80dd7e..7fee5b276 100644 --- a/javatests/google/registry/ui/forms/FormFieldsTest.java +++ b/javatests/google/registry/ui/forms/FormFieldsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.forms; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.hamcrest.Matchers.equalTo; import com.google.common.testing.NullPointerTester; diff --git a/javatests/google/registry/ui/server/BUILD b/javatests/google/registry/ui/server/BUILD index 85c7db004..b8b408db4 100644 --- a/javatests/google/registry/ui/server/BUILD +++ b/javatests/google/registry/ui/server/BUILD @@ -14,7 +14,8 @@ java_library( "//java/google/registry/ui/forms", "//java/google/registry/ui/server", "//javatests/google/registry/testing", - "//third_party/java/truth", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_hamcrest_library", ], diff --git a/javatests/google/registry/ui/server/RegistrarFormFieldsTest.java b/javatests/google/registry/ui/server/RegistrarFormFieldsTest.java index 00b49169a..0068017c7 100644 --- a/javatests/google/registry/ui/server/RegistrarFormFieldsTest.java +++ b/javatests/google/registry/ui/server/RegistrarFormFieldsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.hamcrest.Matchers.equalTo; import google.registry.testing.CertificateSamples; diff --git a/javatests/google/registry/ui/server/registrar/BUILD b/javatests/google/registry/ui/server/registrar/BUILD index 471860a52..9e08eaef3 100644 --- a/javatests/google/registry/ui/server/registrar/BUILD +++ b/javatests/google/registry/ui/server/registrar/BUILD @@ -25,11 +25,12 @@ java_library( "//javatests/google/registry/security", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_braintreepayments_gateway_braintree_java", "@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@com_googlecode_json_simple", "@javax_servlet_api", "@joda_time", diff --git a/javatests/google/registry/ui/server/registrar/ConsoleUiActionTest.java b/javatests/google/registry/ui/server/registrar/ConsoleUiActionTest.java index dd03bc36c..687ca6589 100644 --- a/javatests/google/registry/ui/server/registrar/ConsoleUiActionTest.java +++ b/javatests/google/registry/ui/server/registrar/ConsoleUiActionTest.java @@ -16,6 +16,7 @@ package google.registry.ui.server.registrar; import static com.google.common.net.HttpHeaders.LOCATION; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; diff --git a/javatests/google/registry/ui/server/registrar/ContactSettingsTest.java b/javatests/google/registry/ui/server/registrar/ContactSettingsTest.java index 4aae8d175..1ad659ed3 100644 --- a/javatests/google/registry/ui/server/registrar/ContactSettingsTest.java +++ b/javatests/google/registry/ui/server/registrar/ContactSettingsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResource; diff --git a/javatests/google/registry/ui/server/registrar/RegistrarPaymentActionTest.java b/javatests/google/registry/ui/server/registrar/RegistrarPaymentActionTest.java index 73558cf21..65b590618 100644 --- a/javatests/google/registry/ui/server/registrar/RegistrarPaymentActionTest.java +++ b/javatests/google/registry/ui/server/registrar/RegistrarPaymentActionTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.ReflectiveFieldExtractor.extractField; import static java.util.Arrays.asList; diff --git a/javatests/google/registry/ui/server/registrar/RegistrarPaymentSetupActionTest.java b/javatests/google/registry/ui/server/registrar/RegistrarPaymentSetupActionTest.java index eff3fdc52..8f1c0ec3d 100644 --- a/javatests/google/registry/ui/server/registrar/RegistrarPaymentSetupActionTest.java +++ b/javatests/google/registry/ui/server/registrar/RegistrarPaymentSetupActionTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static java.util.Arrays.asList; diff --git a/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTest.java b/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTest.java index aacca9280..6ff09ed27 100644 --- a/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTest.java +++ b/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; diff --git a/javatests/google/registry/ui/server/registrar/SecuritySettingsTest.java b/javatests/google/registry/ui/server/registrar/SecuritySettingsTest.java index 12c59ae70..1d8a2b1d7 100644 --- a/javatests/google/registry/ui/server/registrar/SecuritySettingsTest.java +++ b/javatests/google/registry/ui/server/registrar/SecuritySettingsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getDefaultRegistrarReferralUrl; import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; diff --git a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java index a1b7eddf1..541f8217e 100644 --- a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java +++ b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailAddress; import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailDisplayName; import static org.mockito.Matchers.any; diff --git a/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java b/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java index 17ce018ae..45703939f 100644 --- a/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java +++ b/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.AppEngineRule.THE_REGISTRAR_GAE_USER_ID; import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.loadRegistrar; diff --git a/javatests/google/registry/ui/server/registrar/WhoisSettingsTest.java b/javatests/google/registry/ui/server/registrar/WhoisSettingsTest.java index 092b3bbe7..bf525d189 100644 --- a/javatests/google/registry/ui/server/registrar/WhoisSettingsTest.java +++ b/javatests/google/registry/ui/server/registrar/WhoisSettingsTest.java @@ -16,6 +16,7 @@ package google.registry.ui.server.registrar; import static com.google.common.base.Strings.repeat; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static java.util.Arrays.asList; diff --git a/javatests/google/registry/util/BUILD b/javatests/google/registry/util/BUILD index e6b5ec41d..dc7d2f3c8 100644 --- a/javatests/google/registry/util/BUILD +++ b/javatests/google/registry/util/BUILD @@ -14,12 +14,13 @@ java_library( "//java/google/registry/config", "//java/google/registry/util", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk", "@com_google_code_findbugs_jsr305", "@com_google_guava", "@com_google_guava_testlib", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_mockito_all", diff --git a/javatests/google/registry/util/CollectionUtilsTest.java b/javatests/google/registry/util/CollectionUtilsTest.java index 944419ea1..0c59799f5 100644 --- a/javatests/google/registry/util/CollectionUtilsTest.java +++ b/javatests/google/registry/util/CollectionUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.partitionMap; diff --git a/javatests/google/registry/util/ComparingInvocationHandlerTest.java b/javatests/google/registry/util/ComparingInvocationHandlerTest.java index 423c86037..0e87f1a32 100644 --- a/javatests/google/registry/util/ComparingInvocationHandlerTest.java +++ b/javatests/google/registry/util/ComparingInvocationHandlerTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/javatests/google/registry/util/ConcurrentTest.java b/javatests/google/registry/util/ConcurrentTest.java index f2b2159bf..7868f047e 100644 --- a/javatests/google/registry/util/ConcurrentTest.java +++ b/javatests/google/registry/util/ConcurrentTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.fail; import com.google.common.base.Function; diff --git a/javatests/google/registry/util/DateTimeUtilsTest.java b/javatests/google/registry/util/DateTimeUtilsTest.java index 57b4de12e..4e84c4b3d 100644 --- a/javatests/google/registry/util/DateTimeUtilsTest.java +++ b/javatests/google/registry/util/DateTimeUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.earliestOf; diff --git a/javatests/google/registry/util/DiffUtilsTest.java b/javatests/google/registry/util/DiffUtilsTest.java index bd541ce56..fd8bf56bd 100644 --- a/javatests/google/registry/util/DiffUtilsTest.java +++ b/javatests/google/registry/util/DiffUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff; import static google.registry.util.DiffUtils.prettyPrintSetDiff; diff --git a/javatests/google/registry/util/DomainNameUtilsTest.java b/javatests/google/registry/util/DomainNameUtilsTest.java index fc0bd4b97..f043e7e60 100644 --- a/javatests/google/registry/util/DomainNameUtilsTest.java +++ b/javatests/google/registry/util/DomainNameUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.DomainNameUtils.canonicalizeDomainName; import google.registry.testing.ExceptionRule; diff --git a/javatests/google/registry/util/HexDumperTest.java b/javatests/google/registry/util/HexDumperTest.java index dbf6a0ff5..2c321958e 100644 --- a/javatests/google/registry/util/HexDumperTest.java +++ b/javatests/google/registry/util/HexDumperTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import google.registry.testing.ExceptionRule; diff --git a/javatests/google/registry/util/PosixTarHeaderSystemTest.java b/javatests/google/registry/util/PosixTarHeaderSystemTest.java index 3e9d92ecb..8430d392a 100644 --- a/javatests/google/registry/util/PosixTarHeaderSystemTest.java +++ b/javatests/google/registry/util/PosixTarHeaderSystemTest.java @@ -16,6 +16,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.SystemInfo.hasCommand; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assume.assumeTrue; diff --git a/javatests/google/registry/util/PosixTarHeaderTest.java b/javatests/google/registry/util/PosixTarHeaderTest.java index 4501b826f..3b4274ffd 100644 --- a/javatests/google/registry/util/PosixTarHeaderTest.java +++ b/javatests/google/registry/util/PosixTarHeaderTest.java @@ -17,6 +17,7 @@ package google.registry.util; import static com.google.common.io.BaseEncoding.base64; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.testing.EqualsTester; diff --git a/javatests/google/registry/util/RequestStatusCheckerImplTest.java b/javatests/google/registry/util/RequestStatusCheckerImplTest.java index 37ce49556..ccc6ca731 100644 --- a/javatests/google/registry/util/RequestStatusCheckerImplTest.java +++ b/javatests/google/registry/util/RequestStatusCheckerImplTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.LogsSubject.assertAboutLogs; import static org.mockito.Matchers.argThat; import static org.mockito.Mockito.mock; diff --git a/javatests/google/registry/util/RetrierTest.java b/javatests/google/registry/util/RetrierTest.java index 47eb7dff1..ef4d16df2 100644 --- a/javatests/google/registry/util/RetrierTest.java +++ b/javatests/google/registry/util/RetrierTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; diff --git a/javatests/google/registry/util/SerializeUtilsTest.java b/javatests/google/registry/util/SerializeUtilsTest.java index a3c6bf7e6..85b40cbf7 100644 --- a/javatests/google/registry/util/SerializeUtilsTest.java +++ b/javatests/google/registry/util/SerializeUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.SerializeUtils.deserialize; import static google.registry.util.SerializeUtils.serialize; diff --git a/javatests/google/registry/util/SqlTemplateTest.java b/javatests/google/registry/util/SqlTemplateTest.java index f72eb81c4..ec41b1dbc 100644 --- a/javatests/google/registry/util/SqlTemplateTest.java +++ b/javatests/google/registry/util/SqlTemplateTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.ExceptionRule; import org.junit.Rule; diff --git a/javatests/google/registry/util/TaskEnqueuerTest.java b/javatests/google/registry/util/TaskEnqueuerTest.java index 77a72f6bc..3db22e931 100644 --- a/javatests/google/registry/util/TaskEnqueuerTest.java +++ b/javatests/google/registry/util/TaskEnqueuerTest.java @@ -16,6 +16,7 @@ package google.registry.util; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/javatests/google/registry/util/TeeOutputStreamTest.java b/javatests/google/registry/util/TeeOutputStreamTest.java index dff8ea2ab..7b1b24e17 100644 --- a/javatests/google/registry/util/TeeOutputStreamTest.java +++ b/javatests/google/registry/util/TeeOutputStreamTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static java.util.Arrays.asList; import com.google.common.collect.ImmutableSet; diff --git a/javatests/google/registry/util/TypeUtilsTest.java b/javatests/google/registry/util/TypeUtilsTest.java index 073e73094..b9234cef0 100644 --- a/javatests/google/registry/util/TypeUtilsTest.java +++ b/javatests/google/registry/util/TypeUtilsTest.java @@ -15,6 +15,7 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.ExceptionRule; import java.io.Serializable; diff --git a/javatests/google/registry/util/UrlFetchUtilsTest.java b/javatests/google/registry/util/UrlFetchUtilsTest.java index b54133c96..cc684f4d8 100644 --- a/javatests/google/registry/util/UrlFetchUtilsTest.java +++ b/javatests/google/registry/util/UrlFetchUtilsTest.java @@ -18,6 +18,7 @@ import static com.google.common.net.HttpHeaders.CONTENT_LENGTH; import static com.google.common.net.HttpHeaders.CONTENT_TYPE; import static com.google.common.net.MediaType.CSV_UTF_8; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.UrlFetchUtils.setPayloadMultipart; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Matchers.any; diff --git a/javatests/google/registry/whois/BUILD b/javatests/google/registry/whois/BUILD index 77bc14f34..d7752213a 100644 --- a/javatests/google/registry/whois/BUILD +++ b/javatests/google/registry/whois/BUILD @@ -19,12 +19,13 @@ java_library( "//java/google/registry/whois", "//javatests/google/registry/testing", "//third_party/java/objectify:objectify-v4_1", - "//third_party/java/truth", "@com_google_appengine_api_1_0_sdk", "@com_google_appengine_testing", "@com_google_dagger", "@com_google_guava", "@com_google_guava_testlib", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@javax_servlet_api", "@joda_time", "@junit", diff --git a/javatests/google/registry/whois/DomainWhoisResponseTest.java b/javatests/google/registry/whois/DomainWhoisResponseTest.java index dfe0eb9c1..8a64a4943 100644 --- a/javatests/google/registry/whois/DomainWhoisResponseTest.java +++ b/javatests/google/registry/whois/DomainWhoisResponseTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; diff --git a/javatests/google/registry/whois/NameserverWhoisResponseTest.java b/javatests/google/registry/whois/NameserverWhoisResponseTest.java index f899fe8b5..1e7d5fe5d 100644 --- a/javatests/google/registry/whois/NameserverWhoisResponseTest.java +++ b/javatests/google/registry/whois/NameserverWhoisResponseTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.whois.WhoisHelper.loadWhoisTestFile; diff --git a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java index d5300f06a..322d77ba1 100644 --- a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java +++ b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; diff --git a/javatests/google/registry/whois/WhoisHttpServerTest.java b/javatests/google/registry/whois/WhoisHttpServerTest.java index 4010ccded..d139a2a82 100644 --- a/javatests/google/registry/whois/WhoisHttpServerTest.java +++ b/javatests/google/registry/whois/WhoisHttpServerTest.java @@ -17,6 +17,7 @@ package google.registry.whois; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; diff --git a/javatests/google/registry/whois/WhoisInjectionTest.java b/javatests/google/registry/whois/WhoisInjectionTest.java index ab5752237..054e30d64 100644 --- a/javatests/google/registry/whois/WhoisInjectionTest.java +++ b/javatests/google/registry/whois/WhoisInjectionTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; diff --git a/javatests/google/registry/whois/WhoisReaderTest.java b/javatests/google/registry/whois/WhoisReaderTest.java index 9d74bc965..a1dd11f57 100644 --- a/javatests/google/registry/whois/WhoisReaderTest.java +++ b/javatests/google/registry/whois/WhoisReaderTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.LogsSubject.assertAboutLogs; diff --git a/javatests/google/registry/whois/WhoisServerTest.java b/javatests/google/registry/whois/WhoisServerTest.java index 535fc39e9..2ca38d282 100644 --- a/javatests/google/registry/whois/WhoisServerTest.java +++ b/javatests/google/registry/whois/WhoisServerTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.registrar.Registrar.State.ACTIVE; import static google.registry.model.registrar.Registrar.Type.PDT; import static google.registry.model.registry.Registries.getTlds; diff --git a/javatests/google/registry/xjc/BUILD b/javatests/google/registry/xjc/BUILD index 10861f8ff..0b81ba775 100644 --- a/javatests/google/registry/xjc/BUILD +++ b/javatests/google/registry/xjc/BUILD @@ -15,9 +15,10 @@ java_library( "//java/google/registry/util", "//java/google/registry/xjc", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_code_findbugs_jsr305", "@com_google_re2j", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@junit", "@org_hamcrest_library", ], diff --git a/javatests/google/registry/xjc/JaxbFragmentTest.java b/javatests/google/registry/xjc/JaxbFragmentTest.java index f1c09bb60..aa3dc5f4b 100644 --- a/javatests/google/registry/xjc/JaxbFragmentTest.java +++ b/javatests/google/registry/xjc/JaxbFragmentTest.java @@ -15,6 +15,7 @@ package google.registry.xjc; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.ResourceUtils.readResourceUtf8; import google.registry.xjc.rdehost.XjcRdeHostElement; diff --git a/javatests/google/registry/xjc/XjcObjectTest.java b/javatests/google/registry/xjc/XjcObjectTest.java index f291c6e0e..775d26fbf 100644 --- a/javatests/google/registry/xjc/XjcObjectTest.java +++ b/javatests/google/registry/xjc/XjcObjectTest.java @@ -16,6 +16,7 @@ package google.registry.xjc; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.xjc.XjcXmlTransformer.unmarshal; import static java.nio.charset.StandardCharsets.UTF_16; diff --git a/javatests/google/registry/xjc/XmlTestdataTest.java b/javatests/google/registry/xjc/XmlTestdataTest.java index 8d3e12d6e..aab8d1357 100644 --- a/javatests/google/registry/xjc/XmlTestdataTest.java +++ b/javatests/google/registry/xjc/XmlTestdataTest.java @@ -15,6 +15,7 @@ package google.registry.xjc; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.xjc.XjcXmlTransformer.unmarshal; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/javatests/google/registry/xml/BUILD b/javatests/google/registry/xml/BUILD index 13f64c603..b15c42451 100644 --- a/javatests/google/registry/xml/BUILD +++ b/javatests/google/registry/xml/BUILD @@ -15,9 +15,10 @@ java_library( "//java/google/registry/util", "//java/google/registry/xml", "//javatests/google/registry/testing", - "//third_party/java/truth", "@com_google_code_findbugs_jsr305", "@com_google_guava", + "@com_google_truth", + "@com_google_truth_extensions_truth_java8_extension", "@joda_time", "@junit", "@org_json", diff --git a/javatests/google/registry/xml/DateAdapterTest.java b/javatests/google/registry/xml/DateAdapterTest.java index dbc82b9ef..8e4277e9e 100644 --- a/javatests/google/registry/xml/DateAdapterTest.java +++ b/javatests/google/registry/xml/DateAdapterTest.java @@ -15,6 +15,7 @@ package google.registry.xml; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import google.registry.testing.ExceptionRule; import org.joda.time.LocalDate; diff --git a/javatests/google/registry/xml/UtcDateTimeAdapterTest.java b/javatests/google/registry/xml/UtcDateTimeAdapterTest.java index 8913ba728..33062c46e 100644 --- a/javatests/google/registry/xml/UtcDateTimeAdapterTest.java +++ b/javatests/google/registry/xml/UtcDateTimeAdapterTest.java @@ -15,6 +15,7 @@ package google.registry.xml; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth8.assertThat; import static org.joda.time.DateTimeZone.UTC; import google.registry.testing.ExceptionRule;