mirror of
https://github.com/google/nomulus.git
synced 2025-08-02 07:52:11 +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
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.<DateTime, Map<DateTime, Money>>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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String, PremiumListEntry> entries =
|
||||
loadPremiumListEntries(PremiumList.get("tld2").get());
|
||||
assertThat(entries.keySet()).containsExactly("lol");
|
||||
|
@ -333,7 +334,7 @@ public class PremiumListUtilsTest {
|
|||
assertThat(PremiumList.get("gtld1")).isPresent();
|
||||
Key<PremiumListRevision> 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. */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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> 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<Lock> 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue