mirror of
https://github.com/google/nomulus.git
synced 2025-05-21 19:59:34 +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
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue