mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 12:08:36 +02:00
Switch from Guava Optionals to Java 8 Optionals
This was a surprisingly involved change. Some of the difficulties included java.util.Optional purposely not being Serializable (so I had to move a few Optionals in mapreduce classes to @Nullable) and having to add the Truth Java8 extension library for assertion support. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171863777
This commit is contained in:
parent
184b2b56ac
commit
c0f8da0c6e
581 changed files with 1325 additions and 932 deletions
|
@ -23,13 +23,14 @@ 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_appengine_tools_appengine_mapreduce",
|
||||
"@com_google_appengine_tools_appengine_pipeline",
|
||||
"@com_google_guava",
|
||||
"@com_google_re2j",
|
||||
"@com_google_truth",
|
||||
"@com_google_truth_extensions_truth_java8_extension",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
"@junit",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
|
@ -22,7 +23,6 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.groups.DirectoryGroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
|
@ -31,6 +31,7 @@ import google.registry.request.Response;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.InjectRule;
|
||||
import java.util.Optional;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -61,7 +62,7 @@ public class CreateGroupsActionTest {
|
|||
action.response = response;
|
||||
action.groupsConnection = connection;
|
||||
action.gSuiteDomainName = "domain-registry.example";
|
||||
action.clientId = Optional.fromNullable(clientId);
|
||||
action.clientId = Optional.ofNullable(clientId);
|
||||
action.run();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.registry.label.PremiumListUtils.deletePremiumList;
|
||||
import static google.registry.model.registry.label.PremiumListUtils.getPremiumPrice;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
|
@ -91,6 +92,6 @@ public class CreatePremiumListActionTest {
|
|||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(loadPremiumListEntries(PremiumList.get("foo").get())).hasSize(2);
|
||||
assertThat(getPremiumPrice("rich", Registry.get("foo"))).hasValue(Money.parse("USD 25"));
|
||||
assertThat(getPremiumPrice("diamond", Registry.get("foo"))).isAbsent();
|
||||
assertThat(getPremiumPrice("diamond", Registry.get("foo"))).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.tools.server;
|
|||
|
||||
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.googlecode.objectify.Key.create;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.tools.server;
|
|||
|
||||
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
|
||||
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;
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Predicates.not;
|
|||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static 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.newContactResource;
|
||||
|
|
|
@ -21,6 +21,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
|||
import static com.google.common.collect.Multimaps.filterKeys;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.FakeJsonResponse;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.Rule;
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -17,8 +17,8 @@ package google.registry.tools.server;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.tools.server;
|
|||
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
|
@ -18,8 +18,8 @@ import static google.registry.testing.DatastoreHelper.createTlds;
|
|||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Optional;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
|
@ -18,9 +18,9 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import java.util.Optional;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
|
@ -16,8 +16,8 @@ package google.registry.tools.server;
|
|||
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.tools.server;
|
|||
|
||||
import static com.google.appengine.tools.pipeline.PipelineServiceFactory.newPipelineService;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Counters;
|
||||
import com.google.appengine.tools.mapreduce.MapReduceResult;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.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.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.registry.label.PremiumListUtils.getPremiumPrice;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.loadPremiumListEntries;
|
||||
|
@ -87,6 +88,6 @@ public class UpdatePremiumListActionTest {
|
|||
assertThat(getPremiumPrice("rich", registry)).hasValue(Money.parse("USD 75"));
|
||||
assertThat(getPremiumPrice("richer", registry)).hasValue(Money.parse("USD 5000"));
|
||||
assertThat(getPremiumPrice("poor", registry)).hasValue(Money.parse("USD 0.99"));
|
||||
assertThat(getPremiumPrice("diamond", registry)).isAbsent();
|
||||
assertThat(getPremiumPrice("diamond", registry)).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue