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:
mcilwain 2017-10-11 13:09:26 -07:00 committed by jianglai
parent 184b2b56ac
commit c0f8da0c6e
581 changed files with 1325 additions and 932 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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",

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<DeletePremiumL
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
assertThat(loadPremiumListEntries(premiumList)).hasSize(1);
runCommand("--force", "--name=xn--q9jyb4c");
assertThat(PremiumList.get("xn--q9jyb4c")).isAbsent();
assertThat(PremiumList.get("xn--q9jyb4c")).isEmpty();
// Ensure that the Datastore premium list entry entities were deleted correctly.
assertThat(ofy().load()

View file

@ -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.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
@ -39,7 +40,7 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
public void testSuccess() throws Exception {
assertThat(reservedList.getReservedListEntries()).hasSize(1);
runCommandForced("--name=common");
assertThat(ReservedList.get("common")).isAbsent();
assertThat(ReservedList.get("common")).isEmpty();
}
@Test

View file

@ -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.util.ResourceUtils.readResourceBytes;
import com.google.common.io.ByteSource;

View file

@ -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.xml.XmlTestUtils.assertXmlEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Matchers.eq;

View file

@ -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.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newContactResourceWithRoid;
import static google.registry.testing.DatastoreHelper.newDomainApplication;

View file

@ -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.testing.DatastoreHelper.createTlds;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.newHostResource;

View file

@ -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 java.nio.file.Files.readAllLines;
import static org.joda.time.DateTimeZone.UTC;

View file

@ -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.re2j.Matcher;
import com.google.re2j.Pattern;

View file

@ -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.keyring.api.Keyring;

View file

@ -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;

View file

@ -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.testing.DatastoreHelper.createTlds;
import static google.registry.testing.DatastoreHelper.persistResource;

View file

@ -25,12 +25,12 @@ import static org.mockito.Mockito.verify;
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.ImmutableMap;
import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
@ -105,7 +105,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand(tldsParameter);
}
verifySent(null, Optional.<Boolean>absent(), Optional.<Boolean>absent());
verifySent(null, Optional.<Boolean>empty(), Optional.<Boolean>empty());
}
@Test
@ -115,7 +115,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", tldsParameter);
}
verifySent("fieldName", Optional.<Boolean>absent(), Optional.<Boolean>absent());
verifySent("fieldName", Optional.<Boolean>empty(), Optional.<Boolean>empty());
}
@Test
@ -125,7 +125,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=*", tldsParameter);
}
verifySent("*", Optional.<Boolean>absent(), Optional.<Boolean>absent());
verifySent("*", Optional.<Boolean>empty(), Optional.<Boolean>empty());
}
@Test
@ -135,7 +135,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--header=true", tldsParameter);
}
verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.<Boolean>absent());
verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.<Boolean>empty());
}
@Test
@ -145,7 +145,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--header=false", tldsParameter);
}
verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.<Boolean>absent());
verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.<Boolean>empty());
}
@Test
@ -155,7 +155,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
} else {
runCommand("--fields=fieldName", "--full_field_names", tldsParameter);
}
verifySent("fieldName", Optional.<Boolean>absent(), Optional.of(Boolean.TRUE));
verifySent("fieldName", Optional.<Boolean>empty(), Optional.of(Boolean.TRUE));
}
@Test

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<UpdateCursorsComma
}
@Test
public void testSuccess_oldValueIsAbsent() throws Exception {
public void testSuccess_oldValueisEmpty() throws Exception {
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
doUpdateTest();
}
@ -76,7 +77,7 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
}
@Test
public void testSuccess_global_oldValueIsAbsent() throws Exception {
public void testSuccess_global_oldValueisEmpty() throws Exception {
assertThat(ofy().load().key(Cursor.createGlobalKey(CursorType.RECURRING_BILLING)).now())
.isNull();
doGlobalUpdateTest();
@ -96,7 +97,7 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
}
@Test
public void testSuccess_multipleTlds_oldValueIsAbsent() throws Exception {
public void testSuccess_multipleTlds_oldValueisEmpty() throws Exception {
createTld("bar");
Registry registry2 = Registry.get("bar");
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();

View file

@ -16,6 +16,7 @@ package google.registry.tools;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.CertificateSamples.SAMPLE_CERT;
import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
import static google.registry.testing.DatastoreHelper.createTlds;

View file

@ -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.registry.label.ReservationType.FULLY_BLOCKED;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@ -84,7 +85,7 @@ public class UpdateReservedListCommandTest extends
assertThat(reservedList.getReservedListEntries()).hasSize(2);
assertThat(reservedList.getReservationInList("baddies")).hasValue(FULLY_BLOCKED);
assertThat(reservedList.getReservationInList("ford")).hasValue(FULLY_BLOCKED);
assertThat(reservedList.getReservationInList("helicopter")).isAbsent();
assertThat(reservedList.getReservationInList("helicopter")).isEmpty();
}
@Test

View file

@ -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;

View file

@ -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.model.tmch.ClaimsListShard;
import java.io.FileNotFoundException;

View file

@ -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.rde.RdeTestData;
import google.registry.xml.XmlException;

View file

@ -12,9 +12,10 @@ java_library(
"//java/google/registry/model",
"//java/google/registry/tools/params",
"//javatests/google/registry/testing",
"//third_party/java/truth",
"@com_beust_jcommander",
"@com_google_guava",
"@com_google_truth",
"@com_google_truth_extensions_truth_java8_extension",
"@joda_time",
"@junit",
"@org_hamcrest_library",

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
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.DateTime;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
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.beust.jcommander.ParameterException;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.beust.jcommander.ParameterException;
import google.registry.testing.ExceptionRule;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import google.registry.model.registry.Registry.TldState;
import google.registry.testing.ExceptionRule;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
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;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.beust.jcommander.ParameterException;
import google.registry.testing.ExceptionRule;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.google.common.collect.ImmutableMap;
import google.registry.testing.ExceptionRule;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.beust.jcommander.ParameterException;
import google.registry.testing.ExceptionRule;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
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;
@ -44,11 +45,11 @@ public class PhoneNumberParameterTest {
@Test
public void testConvert_empty_returnsAbsent() throws Exception {
assertThat(instance.convert("")).isAbsent();
assertThat(instance.convert("")).isEmpty();
}
@Test
public void testConvert_nullString_returnsAbsent() throws Exception {
assertThat(instance.convert("null")).isAbsent();
assertThat(instance.convert("null")).isEmpty();
}
}

View file

@ -15,6 +15,7 @@
package google.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.beust.jcommander.ParameterException;
import google.registry.testing.ExceptionRule;

View file

@ -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",

View file

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

View file

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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

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

View file

@ -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;