mirror of
https://github.com/google/nomulus.git
synced 2025-08-06 01:35:17 +02:00
Clean up some code quality issues
This removes some qualifiers that aren't necessary (e.g. public/abstract on interfaces, private on enum constructors, final on private methods, static on nested interfaces/enums), uses Java 8 lambdas and features where that's an improvement ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177182945
This commit is contained in:
parent
0935ba6450
commit
e2db3f914e
109 changed files with 286 additions and 379 deletions
|
@ -110,7 +110,7 @@ public class MapreduceEntityCleanupActionTest
|
|||
.setInput(input)
|
||||
.setMapper(new TestMapper())
|
||||
.setReducer(new TestReducer())
|
||||
.setOutput(new InMemoryOutput<String>())
|
||||
.setOutput(new InMemoryOutput<>())
|
||||
.setNumReducers(2)
|
||||
.build(),
|
||||
new MapReduceSettings.Builder().setWorkerQueueName(QUEUE_NAME).build());
|
||||
|
|
|
@ -46,6 +46,7 @@ import google.registry.testing.ExceptionRule;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectRule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
|
@ -429,9 +430,7 @@ public class DnsUpdateWriterTest {
|
|||
private void assertThatUpdateAdds(
|
||||
Update update, String resourceName, int recordType, String... resourceData) {
|
||||
ArrayList<String> expectedData = new ArrayList<>();
|
||||
for (String resourceDatum : resourceData) {
|
||||
expectedData.add(resourceDatum);
|
||||
}
|
||||
Collections.addAll(expectedData, resourceData);
|
||||
|
||||
ArrayList<String> actualData = new ArrayList<>();
|
||||
for (Record record : findUpdateRecords(update, resourceName, recordType)) {
|
||||
|
|
|
@ -40,7 +40,6 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeSleeper;
|
||||
import google.registry.testing.Lazies;
|
||||
import google.registry.testing.TaskQueueHelper;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import google.registry.util.CapturingLogHandler;
|
||||
|
@ -94,7 +93,7 @@ public class BigqueryPollJobActionTest {
|
|||
action.enqueuer = ENQUEUER;
|
||||
action.projectId = PROJECT_ID;
|
||||
action.jobId = JOB_ID;
|
||||
action.chainedQueueName = Lazies.of(CHAINED_QUEUE_NAME);
|
||||
action.chainedQueueName = () -> CHAINED_QUEUE_NAME;
|
||||
Logger.getLogger(BigqueryPollJobAction.class.getName()).addHandler(logHandler);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ interface EppTestComponent {
|
|||
|
||||
/** Module for injecting fakes and mocks. */
|
||||
@Module
|
||||
static class FakesAndMocksModule {
|
||||
class FakesAndMocksModule {
|
||||
|
||||
private BigQueryMetricsEnqueuer metricsEnqueuer;
|
||||
private DnsQueue dnsQueue;
|
||||
|
@ -143,7 +143,7 @@ interface EppTestComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public static class FakeServerTridProvider implements ServerTridProvider {
|
||||
class FakeServerTridProvider implements ServerTridProvider {
|
||||
|
||||
@Override
|
||||
public String createServerTrid() {
|
||||
|
|
|
@ -36,7 +36,6 @@ import google.registry.monitoring.whitebox.EppMetric;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.testing.Providers;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -74,7 +73,7 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
flowRunner.clientId = "TheRegistrar";
|
||||
flowRunner.credentials = new PasswordOnlyTransportCredentials();
|
||||
flowRunner.eppRequestSource = EppRequestSource.UNIT_TEST;
|
||||
flowRunner.flowProvider = Providers.<Flow>of(new TestCommandFlow());
|
||||
flowRunner.flowProvider = TestCommandFlow::new;
|
||||
flowRunner.flowClass = TestCommandFlow.class;
|
||||
flowRunner.inputXmlBytes = "<xml/>".getBytes(UTF_8);
|
||||
flowRunner.isDryRun = false;
|
||||
|
|
|
@ -124,7 +124,6 @@ import google.registry.model.smd.SignedMarkRevocationList;
|
|||
import google.registry.tmch.TmchCertificateAuthority;
|
||||
import google.registry.tmch.TmchXmlSignature;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
|
@ -205,7 +204,7 @@ public class DomainApplicationCreateFlowTest
|
|||
// Check that the domain application was created and persisted with a history entry.
|
||||
// We want the one with the newest creation time, but lacking an index we need this code.
|
||||
List<DomainApplication> applications = ofy().load().type(DomainApplication.class).list();
|
||||
Collections.sort(applications, comparing(DomainApplication::getCreationTime));
|
||||
applications.sort(comparing(DomainApplication::getCreationTime));
|
||||
assertAboutApplications().that(getLast(applications))
|
||||
.hasFullyQualifiedDomainName(getUniqueIdFromCommand()).and()
|
||||
.hasNumEncodedSignedMarks(sunriseApplication ? 1 : 0).and()
|
||||
|
|
|
@ -393,12 +393,13 @@ public class OfyTest {
|
|||
// Normal loading should come from the session cache and shouldn't reflect the mutation.
|
||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(someObject);
|
||||
// Loading inside doWithFreshSessionCache() should reflect the mutation.
|
||||
boolean ran = ofy().doWithFreshSessionCache(new Work<Boolean>() {
|
||||
@Override
|
||||
public Boolean run() {
|
||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(modifiedObject);
|
||||
return true;
|
||||
}});
|
||||
boolean ran =
|
||||
ofy()
|
||||
.doWithFreshSessionCache(
|
||||
() -> {
|
||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(modifiedObject);
|
||||
return true;
|
||||
});
|
||||
assertThat(ran).isTrue();
|
||||
// Test the normal loading again to verify that we've restored the original session unchanged.
|
||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(someObject);
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.ObjectifyService;
|
||||
import com.googlecode.objectify.Work;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.model.ofy.CommitLogManifest;
|
||||
|
@ -155,11 +154,7 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
|||
save(new TestObject());
|
||||
clock.advanceBy(standardDays(1));
|
||||
com.google.appengine.api.datastore.Entity entity =
|
||||
ofy().transactNewReadOnly(new Work<com.google.appengine.api.datastore.Entity>() {
|
||||
@Override
|
||||
public com.google.appengine.api.datastore.Entity run() {
|
||||
return ofy().save().toEntity(reload());
|
||||
}});
|
||||
ofy().transactNewReadOnly(() -> ofy().save().toEntity(reload()));
|
||||
assertThat(entity.getProperties().keySet()).containsExactly("revisions.key", "revisions.value");
|
||||
assertThat(entity.getProperties()).containsEntry(
|
||||
"revisions.key", ImmutableList.of(START_TIME.toDate(), START_TIME.plusDays(1).toDate()));
|
||||
|
@ -176,11 +171,7 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
|||
@Test
|
||||
public void testLoad_missingRevisionRawProperties_createsEmptyObject() throws Exception {
|
||||
com.google.appengine.api.datastore.Entity entity =
|
||||
ofy().transactNewReadOnly(new Work<com.google.appengine.api.datastore.Entity>() {
|
||||
@Override
|
||||
public com.google.appengine.api.datastore.Entity run() {
|
||||
return ofy().save().toEntity(new TestObject());
|
||||
}});
|
||||
ofy().transactNewReadOnly(() -> ofy().save().toEntity(new TestObject()));
|
||||
entity.removeProperty("revisions.key");
|
||||
entity.removeProperty("revisions.value");
|
||||
TestObject object = ofy().load().fromEntity(entity);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class StatusValueAdapterTest {
|
|||
.build()),
|
||||
ValidationMode.LENIENT),
|
||||
UTF_8);
|
||||
assertThat(marshalled.toString()).contains("<host:status s=\"clientUpdateProhibited\"/>");
|
||||
assertThat(marshalled).contains("<host:status s=\"clientUpdateProhibited\"/>");
|
||||
}
|
||||
|
||||
private StatusValue unmarshal(String statusValueXml) throws Exception {
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.util.logging.Logger;
|
|||
/** A sample application which uses the Metrics API to count sheep while sleeping. */
|
||||
public final class SheepCounterExample {
|
||||
|
||||
/**
|
||||
/*
|
||||
* The code below for using a custom {@link LogManager} is only necessary to enable logging at JVM
|
||||
* shutdown to show the shutdown logs of {@link MetricReporter} in this small standalone
|
||||
* application.
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
|
@ -172,14 +171,7 @@ public class StackdriverWriterTest {
|
|||
|
||||
@Test
|
||||
public void testWrite_invalidMetricType_throwsException() throws Exception {
|
||||
when(metric.getValueClass())
|
||||
.thenAnswer(
|
||||
new Answer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> answer(InvocationOnMock invocation) throws Throwable {
|
||||
return Object.class;
|
||||
}
|
||||
});
|
||||
when(metric.getValueClass()).thenAnswer((Answer<Class<?>>) invocation -> Object.class);
|
||||
StackdriverWriter writer =
|
||||
new StackdriverWriter(client, PROJECT, MONITORED_RESOURCE, MAX_QPS, MAX_POINTS_PER_REQUEST);
|
||||
|
||||
|
|
|
@ -75,15 +75,9 @@ public class RdapSearchActionTestCase {
|
|||
.setRequestMethod(requestMethod)
|
||||
.setStatusCode(metricStatusCode)
|
||||
.setIncompletenessWarningType(incompletenessWarningType);
|
||||
if (numDomainsRetrieved.isPresent()) {
|
||||
builder.setNumDomainsRetrieved(numDomainsRetrieved.get());
|
||||
}
|
||||
if (numHostsRetrieved.isPresent()) {
|
||||
builder.setNumHostsRetrieved(numHostsRetrieved.get());
|
||||
}
|
||||
if (numContactsRetrieved.isPresent()) {
|
||||
builder.setNumContactsRetrieved(numContactsRetrieved.get());
|
||||
}
|
||||
numDomainsRetrieved.ifPresent(builder::setNumDomainsRetrieved);
|
||||
numHostsRetrieved.ifPresent(builder::setNumHostsRetrieved);
|
||||
numContactsRetrieved.ifPresent(builder::setNumContactsRetrieved);
|
||||
verify(rdapMetrics).updateMetrics(builder.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import google.registry.testing.BouncyCastleProviderRule;
|
|||
import google.registry.testing.FakeKeyringModule;
|
||||
import google.registry.testing.GcsTestingUtils;
|
||||
import google.registry.testing.GpgSystemCommandRule;
|
||||
import google.registry.testing.Providers;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -104,9 +103,9 @@ public class BrdaCopyActionTest extends ShardableTestCase {
|
|||
public void before() throws Exception {
|
||||
action.gcsUtils = gcsUtils;
|
||||
action.ghostryde = new Ghostryde(23);
|
||||
action.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(() -> 1024);
|
||||
action.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(() -> 1024);
|
||||
action.pgpFileFactory = new RydePgpFileOutputStreamFactory(() -> 1024);
|
||||
action.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
|
||||
action.tarFactory = new RydeTarOutputStreamFactory();
|
||||
action.tld = "lol";
|
||||
|
|
|
@ -69,7 +69,6 @@ import google.registry.testing.FakeSleeper;
|
|||
import google.registry.testing.GpgSystemCommandRule;
|
||||
import google.registry.testing.IoSpyRule;
|
||||
import google.registry.testing.Lazies;
|
||||
import google.registry.testing.Providers;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import google.registry.testing.sftp.SftpServerRule;
|
||||
import google.registry.util.Retrier;
|
||||
|
@ -156,21 +155,21 @@ public class RdeUploadActionTest {
|
|||
}};
|
||||
|
||||
private final RydePgpFileOutputStreamFactory literalFactory =
|
||||
new RydePgpFileOutputStreamFactory(Providers.of(BUFFER_SIZE)) {
|
||||
new RydePgpFileOutputStreamFactory(() -> BUFFER_SIZE) {
|
||||
@Override
|
||||
public RydePgpFileOutputStream create(OutputStream os, DateTime modified, String filename) {
|
||||
return ioSpy.register(super.create(os, modified, filename));
|
||||
}};
|
||||
|
||||
private final RydePgpEncryptionOutputStreamFactory encryptFactory =
|
||||
new RydePgpEncryptionOutputStreamFactory(Providers.of(BUFFER_SIZE)) {
|
||||
new RydePgpEncryptionOutputStreamFactory(() -> BUFFER_SIZE) {
|
||||
@Override
|
||||
public RydePgpEncryptionOutputStream create(OutputStream os, PGPPublicKey publicKey) {
|
||||
return ioSpy.register(super.create(os, publicKey));
|
||||
}};
|
||||
|
||||
private final RydePgpCompressionOutputStreamFactory compressFactory =
|
||||
new RydePgpCompressionOutputStreamFactory(Providers.of(BUFFER_SIZE)) {
|
||||
new RydePgpCompressionOutputStreamFactory(() -> BUFFER_SIZE) {
|
||||
@Override
|
||||
public RydePgpCompressionOutputStream create(OutputStream os) {
|
||||
return ioSpy.register(super.create(os));
|
||||
|
@ -190,10 +189,11 @@ public class RdeUploadActionTest {
|
|||
action.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
|
||||
action.ghostryde = new Ghostryde(BUFFER_SIZE);
|
||||
action.lazyJsch =
|
||||
Lazies.of(
|
||||
() ->
|
||||
JSchModule.provideJSch(
|
||||
"user@ignored",
|
||||
keyring.getRdeSshClientPrivateKey(), keyring.getRdeSshClientPublicKey()));
|
||||
keyring.getRdeSshClientPrivateKey(),
|
||||
keyring.getRdeSshClientPublicKey());
|
||||
action.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3));
|
||||
action.response = response;
|
||||
action.pgpCompressionFactory = compressFactory;
|
||||
|
|
|
@ -26,7 +26,6 @@ import google.registry.keyring.api.Keyring;
|
|||
import google.registry.testing.BouncyCastleProviderRule;
|
||||
import google.registry.testing.FakeKeyringModule;
|
||||
import google.registry.testing.GpgSystemCommandRule;
|
||||
import google.registry.testing.Providers;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.io.File;
|
||||
|
@ -97,11 +96,11 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
RydeTarOutputStreamFactory tarFactory =
|
||||
new RydeTarOutputStreamFactory();
|
||||
RydePgpFileOutputStreamFactory pgpFileFactory =
|
||||
new RydePgpFileOutputStreamFactory(Providers.of(bufSize.get()));
|
||||
new RydePgpFileOutputStreamFactory(bufSize::get);
|
||||
RydePgpEncryptionOutputStreamFactory pgpEncryptionFactory =
|
||||
new RydePgpEncryptionOutputStreamFactory(Providers.of(bufSize.get()));
|
||||
new RydePgpEncryptionOutputStreamFactory(bufSize::get);
|
||||
RydePgpCompressionOutputStreamFactory pgpCompressionFactory =
|
||||
new RydePgpCompressionOutputStreamFactory(Providers.of(bufSize.get()));
|
||||
new RydePgpCompressionOutputStreamFactory(bufSize::get);
|
||||
RydePgpSigningOutputStreamFactory pgpSigningFactory =
|
||||
new RydePgpSigningOutputStreamFactory();
|
||||
|
||||
|
|
|
@ -194,8 +194,7 @@ public class RdeContactReaderTest {
|
|||
oout.writeObject(reader);
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
|
||||
ObjectInputStream oin = new ObjectInputStream(bin);
|
||||
RdeContactReader result = (RdeContactReader) oin.readObject();
|
||||
return result;
|
||||
return (RdeContactReader) oin.readObject();
|
||||
}
|
||||
|
||||
/** Verifies that contact id and ROID match expected values */
|
||||
|
|
|
@ -190,8 +190,7 @@ public class RdeHostReaderTest {
|
|||
oout.writeObject(reader);
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
|
||||
ObjectInputStream oin = new ObjectInputStream(bin);
|
||||
RdeHostReader result = (RdeHostReader) oin.readObject();
|
||||
return result;
|
||||
return (RdeHostReader) oin.readObject();
|
||||
}
|
||||
|
||||
/** Verifies that domain name and ROID match expected values */
|
||||
|
|
|
@ -121,7 +121,7 @@ public final class TestServer {
|
|||
* main event loop, for post-request processing.
|
||||
*/
|
||||
public void ping() {
|
||||
requestQueue.add(new FutureTask<Void>(doNothing(), null));
|
||||
requestQueue.add(new FutureTask<>(doNothing(), null));
|
||||
}
|
||||
|
||||
/** Stops the HTTP server. */
|
||||
|
|
|
@ -298,12 +298,7 @@ public final class AppEngineRule extends ExternalResource {
|
|||
}
|
||||
|
||||
if (clock != null) {
|
||||
helper.setClock(new com.google.appengine.tools.development.Clock() {
|
||||
@Override
|
||||
public long getCurrentTime() {
|
||||
return clock.nowUtc().getMillis();
|
||||
}
|
||||
});
|
||||
helper.setClock(() -> clock.nowUtc().getMillis());
|
||||
}
|
||||
|
||||
if (withLocalModules) {
|
||||
|
|
|
@ -56,7 +56,6 @@ import com.google.common.collect.Streams;
|
|||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import com.googlecode.objectify.Work;
|
||||
import com.googlecode.objectify.cmd.Saver;
|
||||
import google.registry.dns.writer.VoidDnsWriter;
|
||||
import google.registry.model.Buildable;
|
||||
|
@ -1030,11 +1029,7 @@ public class DatastoreHelper {
|
|||
|
||||
/** Force the create and update timestamps to get written into the resource. **/
|
||||
public static <R> R cloneAndSetAutoTimestamps(final R resource) {
|
||||
return ofy().transact(new Work<R>() {
|
||||
@Override
|
||||
public R run() {
|
||||
return ofy().load().fromEntity(ofy().save().toEntity(resource));
|
||||
}});
|
||||
return ofy().transact(() -> ofy().load().fromEntity(ofy().save().toEntity(resource)));
|
||||
}
|
||||
|
||||
/** Returns the entire map of {@link PremiumListEntry}s for the given {@link PremiumList}. */
|
||||
|
|
|
@ -60,16 +60,16 @@ public class DeterministicStringGenerator extends StringGenerator {
|
|||
@Override
|
||||
public String createString(int length) {
|
||||
checkArgument(length > 0, "String length must be positive.");
|
||||
String password = "";
|
||||
StringBuilder password = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
password += iterator.next();
|
||||
password.append(iterator.next());
|
||||
}
|
||||
switch (rule) {
|
||||
case PREPEND_COUNTER:
|
||||
return String.format("%04d_%s", counter++, password);
|
||||
return String.format("%04d_%s", counter++, password.toString());
|
||||
case DEFAULT:
|
||||
default:
|
||||
return password;
|
||||
return password.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,6 @@ public final class FakeKeyringModule {
|
|||
PgpHelper.lookupKeyPair(publics, privates, SIGNING_KEY_EMAIL, SIGN);
|
||||
final PGPPublicKey rdeReceiverKey =
|
||||
PgpHelper.lookupPublicKey(publics, RECEIVER_KEY_EMAIL, ENCRYPT);
|
||||
final PGPKeyPair brdaSigningKey = rdeSigningKey;
|
||||
final PGPPublicKey brdaReceiverKey = rdeReceiverKey;
|
||||
final String sshPublic =
|
||||
readResourceUtf8(FakeKeyringModule.class, "testdata/registry-unittest.id_rsa.pub");
|
||||
final String sshPrivate =
|
||||
|
@ -141,12 +139,12 @@ public final class FakeKeyringModule {
|
|||
|
||||
@Override
|
||||
public PGPKeyPair getBrdaSigningKey() {
|
||||
return brdaSigningKey;
|
||||
return rdeSigningKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PGPPublicKey getBrdaReceiverKey() {
|
||||
return brdaReceiverKey;
|
||||
return rdeReceiverKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class FullFieldsTestEntityHelper {
|
|||
|
||||
public static Registrar makeRegistrar(
|
||||
String clientId, String registrarName, Registrar.State state, Long ianaIdentifier) {
|
||||
Registrar registrar = new Registrar.Builder()
|
||||
return new Registrar.Builder()
|
||||
.setClientId(clientId)
|
||||
.setRegistrarName(registrarName)
|
||||
.setType(Registrar.Type.REAL)
|
||||
|
@ -82,7 +82,6 @@ public final class FullFieldsTestEntityHelper {
|
|||
.setWhoisServer("whois.example.com")
|
||||
.setReferralUrl("http://www.example.com")
|
||||
.build();
|
||||
return registrar;
|
||||
}
|
||||
|
||||
public static ImmutableList<RegistrarContact> makeRegistrarContacts(Registrar registrar) {
|
||||
|
|
|
@ -23,10 +23,6 @@ public final class Lazies {
|
|||
* Returns a {@link Lazy} that supplies a constant value.
|
||||
*/
|
||||
public static <T> Lazy<T> of(final T instance) {
|
||||
return new Lazy<T>() {
|
||||
@Override
|
||||
public T get() {
|
||||
return instance;
|
||||
}};
|
||||
return () -> instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,6 @@ public final class Providers {
|
|||
*
|
||||
*/
|
||||
public static <T> Provider<T> of(final T instance) {
|
||||
return new Provider<T>() {
|
||||
@Override
|
||||
public T get() {
|
||||
return instance;
|
||||
}};
|
||||
return () -> instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,7 @@ import com.google.api.client.http.HttpRequest;
|
|||
import com.google.api.client.http.HttpRequestFactory;
|
||||
import com.google.api.client.http.HttpRequestInitializer;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import google.registry.testing.Providers;
|
||||
import java.io.IOException;
|
||||
import javax.inject.Provider;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -43,8 +41,6 @@ public class DefaultRequestFactoryModuleTest {
|
|||
}
|
||||
});
|
||||
|
||||
Provider<Credential> credentialProvider = Providers.of(FAKE_CREDENTIAL);
|
||||
|
||||
DefaultRequestFactoryModule module = new DefaultRequestFactoryModule();
|
||||
|
||||
@Before
|
||||
|
@ -56,9 +52,9 @@ public class DefaultRequestFactoryModuleTest {
|
|||
public void test_provideHttpRequestFactory_localhost() throws Exception {
|
||||
// Make sure that localhost creates a request factory with an initializer.
|
||||
HttpRequestFactory factory =
|
||||
module.provideHttpRequestFactory(new AppEngineConnectionFlags(
|
||||
HostAndPort.fromParts("localhost", 1000)),
|
||||
credentialProvider);
|
||||
module.provideHttpRequestFactory(
|
||||
new AppEngineConnectionFlags(HostAndPort.fromParts("localhost", 1000)),
|
||||
() -> FAKE_CREDENTIAL);
|
||||
HttpRequestInitializer initializer = factory.getInitializer();
|
||||
assertThat(initializer).isNotNull();
|
||||
assertThat(initializer).isNotSameAs(FAKE_CREDENTIAL);
|
||||
|
@ -69,9 +65,9 @@ public class DefaultRequestFactoryModuleTest {
|
|||
// Make sure that example.com creates a request factory with the UNITTEST client id but no
|
||||
// initializer.
|
||||
HttpRequestFactory factory =
|
||||
module.provideHttpRequestFactory(new AppEngineConnectionFlags(
|
||||
HostAndPort.fromParts("example.com", 1000)),
|
||||
credentialProvider);
|
||||
module.provideHttpRequestFactory(
|
||||
new AppEngineConnectionFlags(HostAndPort.fromParts("example.com", 1000)),
|
||||
() -> FAKE_CREDENTIAL);
|
||||
assertThat(factory.getInitializer()).isSameAs(FAKE_CREDENTIAL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import google.registry.rde.RydePgpSigningOutputStreamFactory;
|
|||
import google.registry.rde.RydeTarOutputStreamFactory;
|
||||
import google.registry.testing.BouncyCastleProviderRule;
|
||||
import google.registry.testing.FakeKeyringModule;
|
||||
import google.registry.testing.Providers;
|
||||
import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -45,13 +44,13 @@ public class EncryptEscrowDepositCommandTest
|
|||
|
||||
static EscrowDepositEncryptor createEncryptor() {
|
||||
EscrowDepositEncryptor res = new EscrowDepositEncryptor();
|
||||
res.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
|
||||
res.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
|
||||
res.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
|
||||
res.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(() -> 1024);
|
||||
res.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(() -> 1024);
|
||||
res.pgpFileFactory = new RydePgpFileOutputStreamFactory(() -> 1024);
|
||||
res.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
|
||||
res.tarFactory = new RydeTarOutputStreamFactory();
|
||||
res.rdeReceiverKey = Providers.of(new FakeKeyringModule().get().getRdeReceiverKey());
|
||||
res.rdeSigningKey = Providers.of(new FakeKeyringModule().get().getRdeSigningKey());
|
||||
res.rdeReceiverKey = () -> new FakeKeyringModule().get().getRdeReceiverKey();
|
||||
res.rdeSigningKey = () -> new FakeKeyringModule().get().getRdeSigningKey();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import google.registry.rde.Ghostryde.DecodeResult;
|
|||
import google.registry.testing.BouncyCastleProviderRule;
|
||||
import google.registry.testing.FakeKeyringModule;
|
||||
import google.registry.testing.InjectRule;
|
||||
import google.registry.testing.Providers;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -68,8 +67,8 @@ public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
|||
public void before() throws Exception {
|
||||
keyring = new FakeKeyringModule().get();
|
||||
command.ghostryde = new Ghostryde(1024);
|
||||
command.rdeStagingDecryptionKey = Providers.of(keyring.getRdeStagingDecryptionKey());
|
||||
command.rdeStagingEncryptionKey = Providers.of(keyring.getRdeStagingEncryptionKey());
|
||||
command.rdeStagingDecryptionKey = keyring::getRdeStagingDecryptionKey;
|
||||
command.rdeStagingEncryptionKey = keyring::getRdeStagingEncryptionKey;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -81,9 +81,7 @@ class LevelDbUtil {
|
|||
pos = addRecordHeader(bytes, pos, type, data.length);
|
||||
|
||||
// Write the contents of "data".
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
bytes[pos + i] = data[i];
|
||||
}
|
||||
System.arraycopy(data, 0, bytes, pos, data.length);
|
||||
|
||||
return pos + data.length;
|
||||
}
|
||||
|
|
|
@ -82,12 +82,8 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
|||
if (fields != null) {
|
||||
params.put(FIELDS_PARAM, fields);
|
||||
}
|
||||
if (printHeaderRow.isPresent()) {
|
||||
params.put(PRINT_HEADER_ROW_PARAM, printHeaderRow.get());
|
||||
}
|
||||
if (fullFieldNames.isPresent()) {
|
||||
params.put(FULL_FIELD_NAMES_PARAM, fullFieldNames.get());
|
||||
}
|
||||
printHeaderRow.ifPresent(aBoolean -> params.put(PRINT_HEADER_ROW_PARAM, aBoolean));
|
||||
fullFieldNames.ifPresent(aBoolean -> params.put(FULL_FIELD_NAMES_PARAM, aBoolean));
|
||||
if (!getTlds().isEmpty()) {
|
||||
params.put("tlds", Joiner.on(',').join(getTlds()));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ComparingInvocationHandlerTest {
|
|||
|
||||
static class Dummy {}
|
||||
|
||||
static interface MyInterface {
|
||||
interface MyInterface {
|
||||
String func(int a, String b);
|
||||
|
||||
Dummy func();
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class RequestStatusCheckerImplTest {
|
|||
* Because LogQuery doesn't have a .equals function, we have to create an actual matcher to make
|
||||
* sure we have the right argument in our mocks.
|
||||
*/
|
||||
private static final LogQuery expectedLogQuery(final String requestLogId) {
|
||||
private static LogQuery expectedLogQuery(final String requestLogId) {
|
||||
return argThat(
|
||||
new ArgumentMatcher<LogQuery>() {
|
||||
@Override
|
||||
|
|
|
@ -47,7 +47,7 @@ public class WhoisReaderTest {
|
|||
WhoisReader.logger.addHandler(testLogHandler);
|
||||
}
|
||||
|
||||
@SuppressWarnings("TypeParameterUnusedInFormals") // XXX: Generic abuse ftw.
|
||||
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
|
||||
<T> T readCommand(String commandStr) throws Exception {
|
||||
return (T)
|
||||
new WhoisReader(new WhoisCommandFactory())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue