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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<RdeStagingAction> {
action.pendingDepositChecker.rdeInterval = Duration.standardDays(1);
action.response = response;
action.transactionCooldown = Duration.ZERO;
action.directory = Optional.<String>absent();
action.directory = Optional.<String>empty();
action.modeStrings = ImmutableSet.<String>of();
action.tlds = ImmutableSet.<String>of();
action.watermarks = ImmutableSet.<DateTime>of();
action.revision = Optional.<Integer>absent();
action.revision = Optional.<Integer>empty();
}
@Test

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with zero contacts results in expected reader configuration */
@Test
public void testZeroContactsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_0_CONTACT);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with one contact results in expected reader configuration */
@Test
public void testOneContactDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_1_CONTACT);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with 199 contacts results in expected reader configuration */
@Test
public void test199ContactsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_199_CONTACT);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 199);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 2);
assertNumberOfReaders(Optional.<Integer>empty(), 2);
}
/** Escrow file with 200 contacts results in expected reader configurations */
@Test
public void test200ContactsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_200_CONTACT);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>absent(), 1, 100, 100);
assertReaderConfigurations(Optional.<Integer>empty(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 10);
assertNumberOfReaders(Optional.<Integer>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.<Integer>absent(), i, i * 100, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 50);
assertNumberOfReaders(Optional.<Integer>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.<Integer>absent(), i, i * 200, 200);
assertReaderConfigurations(Optional.<Integer>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<Integer> 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<Integer> mapShards) {
return new RdeContactInput(mapShards, IMPORT_BUCKET_NAME, IMPORT_FILE_NAME);

View file

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

View file

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

View file

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

View file

@ -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<RdeHostImportActi
private MapreduceRunner mrRunner;
private Response response;
private final Optional<Integer> mapShards = Optional.absent();
private final Optional<Integer> mapShards = Optional.empty();
@Before
public void before() throws Exception {
response = new FakeResponse();
mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
mrRunner = new MapreduceRunner(Optional.<Integer>empty(), Optional.<Integer>empty());
action = new RdeHostImportAction(
mrRunner,
response,

View file

@ -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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with zero hosts results in expected reader configuration */
@Test
public void testZeroHostsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_0_HOST);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with one host results in expected reader configuration */
@Test
public void testOneHostDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_1_HOST);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 1);
assertNumberOfReaders(Optional.<Integer>empty(), 1);
}
/** Escrow file with 199 hosts results in expected reader configuration */
@Test
public void test199HostsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_199_HOST);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 199);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 2);
assertNumberOfReaders(Optional.<Integer>empty(), 2);
}
/** Escrow file with 200 hosts results in expected reader configurations */
@Test
public void test200HostsDefaultShardsReaderConfigurations() throws Exception {
pushToGcs(DEPOSIT_200_HOST);
assertReaderConfigurations(Optional.<Integer>absent(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>absent(), 1, 100, 100);
assertReaderConfigurations(Optional.<Integer>empty(), 0, 0, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 10);
assertNumberOfReaders(Optional.<Integer>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.<Integer>absent(), i, i * 100, 100);
assertReaderConfigurations(Optional.<Integer>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.<Integer>absent(), 50);
assertNumberOfReaders(Optional.<Integer>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.<Integer>absent(), i, i * 200, 200);
assertReaderConfigurations(Optional.<Integer>empty(), i, i * 200, 200);
}
}

View file

@ -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<RdeHostLinkAction>
private Response response;
private final Optional<Integer> mapShards = Optional.absent();
private final Optional<Integer> mapShards = Optional.empty();
private final FakeClock clock = new FakeClock();
@ -84,7 +85,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase<RdeHostLinkAction>
inject.setStaticField(Ofy.class, "clock", clock);
createTld("test");
response = new FakeResponse();
mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
mrRunner = new MapreduceRunner(Optional.<Integer>empty(), Optional.<Integer>empty());
action =
new RdeHostLinkAction(mrRunner, response, IMPORT_BUCKET_NAME, IMPORT_FILE_NAME, mapShards);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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