mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Fix @VisibleForTesting given the newly deployed enforcement
Generated code is now also covered by @VisibleForTesting, including Dagger @Inject This CL is a cleanup of auto-generated code by ghm@ from the Error Prone team ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228748874
This commit is contained in:
parent
8bde7285bf
commit
c74ffd7559
15 changed files with 11 additions and 24 deletions
|
@ -21,7 +21,6 @@ import com.google.appengine.api.taskqueue.Queue;
|
||||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||||
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
||||||
import com.google.appengine.api.taskqueue.TransientFailureException;
|
import com.google.appengine.api.taskqueue.TransientFailureException;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
|
@ -68,7 +67,6 @@ public final class AsyncTaskEnqueuer {
|
||||||
private final AppEngineServiceUtils appEngineServiceUtils;
|
private final AppEngineServiceUtils appEngineServiceUtils;
|
||||||
private final Retrier retrier;
|
private final Retrier retrier;
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
@Inject
|
@Inject
|
||||||
public AsyncTaskEnqueuer(
|
public AsyncTaskEnqueuer(
|
||||||
@Named(QUEUE_ASYNC_ACTIONS) Queue asyncActionsPushQueue,
|
@Named(QUEUE_ASYNC_ACTIONS) Queue asyncActionsPushQueue,
|
||||||
|
|
|
@ -60,7 +60,6 @@ public class TlsCredentials implements TransportCredentials {
|
||||||
private final InetAddress clientInetAddr;
|
private final InetAddress clientInetAddr;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
|
||||||
public TlsCredentials(
|
public TlsCredentials(
|
||||||
@Config("requireSslCertificates") boolean requireSslCertificates,
|
@Config("requireSslCertificates") boolean requireSslCertificates,
|
||||||
@Header("X-SSL-Certificate") String clientCertificateHash,
|
@Header("X-SSL-Certificate") String clientCertificateHash,
|
||||||
|
|
|
@ -32,7 +32,6 @@ import com.google.appengine.tools.mapreduce.Reducer;
|
||||||
import com.google.appengine.tools.mapreduce.outputs.NoOutput;
|
import com.google.appengine.tools.mapreduce.outputs.NoOutput;
|
||||||
import com.google.appengine.tools.pipeline.Job0;
|
import com.google.appengine.tools.pipeline.Job0;
|
||||||
import com.google.appengine.tools.pipeline.JobSetting;
|
import com.google.appengine.tools.pipeline.JobSetting;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.mapreduce.inputs.ConcatenatingInput;
|
import google.registry.mapreduce.inputs.ConcatenatingInput;
|
||||||
import google.registry.request.Parameter;
|
import google.registry.request.Parameter;
|
||||||
|
@ -86,7 +85,6 @@ public class MapreduceRunner {
|
||||||
* @param reduceShards number of reduce shards; if omitted, uses {@link #defaultReduceShards}
|
* @param reduceShards number of reduce shards; if omitted, uses {@link #defaultReduceShards}
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
|
||||||
public MapreduceRunner(
|
public MapreduceRunner(
|
||||||
@Parameter(PARAM_MAP_SHARDS) Optional<Integer> mapShards,
|
@Parameter(PARAM_MAP_SHARDS) Optional<Integer> mapShards,
|
||||||
@Parameter(PARAM_REDUCE_SHARDS) Optional<Integer> reduceShards) {
|
@Parameter(PARAM_REDUCE_SHARDS) Optional<Integer> reduceShards) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.model.contact;
|
||||||
|
|
||||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
|
@ -84,7 +83,6 @@ public class Disclose extends ImmutableObject {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public static PostalInfoChoice create(PostalInfo.Type type) {
|
public static PostalInfoChoice create(PostalInfo.Type type) {
|
||||||
PostalInfoChoice instance = new PostalInfoChoice();
|
PostalInfoChoice instance = new PostalInfoChoice();
|
||||||
instance.type = type;
|
instance.type = type;
|
||||||
|
@ -93,7 +91,6 @@ public class Disclose extends ImmutableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A builder for {@link Disclose} since it is immutable. */
|
/** A builder for {@link Disclose} since it is immutable. */
|
||||||
@VisibleForTesting
|
|
||||||
public static class Builder extends Buildable.Builder<Disclose> {
|
public static class Builder extends Buildable.Builder<Disclose> {
|
||||||
public Builder setNames(ImmutableList<PostalInfoChoice> names) {
|
public Builder setNames(ImmutableList<PostalInfoChoice> names) {
|
||||||
getInstance().name = names;
|
getInstance().name = names;
|
||||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.model.domain;
|
||||||
|
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
|
@ -57,7 +56,6 @@ public class DesignatedContact extends ImmutableObject {
|
||||||
REGISTRANT;
|
REGISTRANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
||||||
DesignatedContact instance = new DesignatedContact();
|
DesignatedContact instance = new DesignatedContact();
|
||||||
instance.type = type;
|
instance.type = type;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package google.registry.model.domain.secdns;
|
package google.registry.model.domain.secdns;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
@ -76,7 +75,6 @@ public class DelegationSignerData
|
||||||
return digest;
|
return digest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public static DelegationSignerData create(
|
public static DelegationSignerData create(
|
||||||
int keyTag, int algorithm, int digestType, byte[] digest) {
|
int keyTag, int algorithm, int digestType, byte[] digest) {
|
||||||
DelegationSignerData instance = new DelegationSignerData();
|
DelegationSignerData instance = new DelegationSignerData();
|
||||||
|
|
|
@ -100,7 +100,6 @@ public class Address extends ImmutableObject implements Jsonifiable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A builder for constructing {@link Address}. */
|
/** A builder for constructing {@link Address}. */
|
||||||
@VisibleForTesting
|
|
||||||
public static class Builder<T extends Address> extends Buildable.Builder<T> {
|
public static class Builder<T extends Address> extends Buildable.Builder<T> {
|
||||||
|
|
||||||
public Builder() {}
|
public Builder() {}
|
||||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.model.eppcommon;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
@ -66,7 +65,6 @@ public class PhoneNumber extends ImmutableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A builder for constructing {@link PhoneNumber}. */
|
/** A builder for constructing {@link PhoneNumber}. */
|
||||||
@VisibleForTesting
|
|
||||||
public static class Builder<T extends PhoneNumber> extends Buildable.Builder<T> {
|
public static class Builder<T extends PhoneNumber> extends Buildable.Builder<T> {
|
||||||
@Override
|
@Override
|
||||||
public T build() {
|
public T build() {
|
||||||
|
|
|
@ -129,6 +129,14 @@ public abstract class PollMessage extends ImmutableObject
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually set the ID for testing or in special circumstances.
|
||||||
|
*
|
||||||
|
* <p>In general the ID is auto-created, and there should be no need to set it manually.
|
||||||
|
*
|
||||||
|
* <p>This is only here for testing and for one special situation in which we're making a new
|
||||||
|
* poll message to replace an existing one, so it has to have the same ID.
|
||||||
|
*/
|
||||||
public B setId(Long id) {
|
public B setId(Long id) {
|
||||||
getInstance().id = id;
|
getInstance().id = id;
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
|
|
|
@ -562,7 +562,6 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
* domain renewal, and all derived costs (i.e. autorenews, transfers, and the per-domain part of a
|
* domain renewal, and all derived costs (i.e. autorenews, transfers, and the per-domain part of a
|
||||||
* restore cost).
|
* restore cost).
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
public Money getStandardRenewCost(DateTime now) {
|
public Money getStandardRenewCost(DateTime now) {
|
||||||
return renewBillingCostTransitions.getValueAtTime(now);
|
return renewBillingCostTransitions.getValueAtTime(now);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.security.XsrfTokenManager.P_CSRF_TOKEN;
|
||||||
import static google.registry.security.XsrfTokenManager.X_CSRF_TOKEN;
|
import static google.registry.security.XsrfTokenManager.X_CSRF_TOKEN;
|
||||||
|
|
||||||
import com.google.appengine.api.users.UserService;
|
import com.google.appengine.api.users.UserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import google.registry.security.XsrfTokenManager;
|
import google.registry.security.XsrfTokenManager;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -41,7 +40,6 @@ public class LegacyAuthenticationMechanism implements AuthenticationMechanism {
|
||||||
/** HTTP methods which are considered safe, and do not require XSRF protection. */
|
/** HTTP methods which are considered safe, and do not require XSRF protection. */
|
||||||
private static final ImmutableSet<String> SAFE_METHODS = ImmutableSet.of("GET", "HEAD");
|
private static final ImmutableSet<String> SAFE_METHODS = ImmutableSet.of("GET", "HEAD");
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
@Inject
|
@Inject
|
||||||
public LegacyAuthenticationMechanism(UserService userService, XsrfTokenManager xsrfTokenManager) {
|
public LegacyAuthenticationMechanism(UserService userService, XsrfTokenManager xsrfTokenManager) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.google.appengine.api.oauth.OAuthRequestException;
|
||||||
import com.google.appengine.api.oauth.OAuthService;
|
import com.google.appengine.api.oauth.OAuthService;
|
||||||
import com.google.appengine.api.oauth.OAuthServiceFailureException;
|
import com.google.appengine.api.oauth.OAuthServiceFailureException;
|
||||||
import com.google.appengine.api.users.User;
|
import com.google.appengine.api.users.User;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.config.RegistryConfig.Config;
|
import google.registry.config.RegistryConfig.Config;
|
||||||
|
@ -50,7 +49,6 @@ public class OAuthAuthenticationMechanism implements AuthenticationMechanism {
|
||||||
|
|
||||||
private final ImmutableSet<String> allowedOauthClientIds;
|
private final ImmutableSet<String> allowedOauthClientIds;
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
@Inject
|
@Inject
|
||||||
public OAuthAuthenticationMechanism(
|
public OAuthAuthenticationMechanism(
|
||||||
OAuthService oauthService,
|
OAuthService oauthService,
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.request.auth;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
|
@ -35,7 +34,6 @@ public class RequestAuthenticator {
|
||||||
|
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
@Inject
|
@Inject
|
||||||
public RequestAuthenticator(
|
public RequestAuthenticator(
|
||||||
AppEngineInternalAuthenticationMechanism appEngineInternalAuthenticationMechanism,
|
AppEngineInternalAuthenticationMechanism appEngineInternalAuthenticationMechanism,
|
||||||
|
|
|
@ -297,7 +297,6 @@ public class ShellCommand implements Command {
|
||||||
return resultBuilder.build().toArray(new String[0]);
|
return resultBuilder.build().toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static class JCommanderCompletor implements Completor {
|
static class JCommanderCompletor implements Completor {
|
||||||
|
|
||||||
private static final ParamDoc DEFAULT_PARAM_DOC =
|
private static final ParamDoc DEFAULT_PARAM_DOC =
|
||||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.annotations.VisibleForTesting.Visibility;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -47,6 +48,7 @@ import javax.annotation.concurrent.NotThreadSafe;
|
||||||
* oftentimes will not know the name of the field they're validating.
|
* oftentimes will not know the name of the field they're validating.
|
||||||
*/
|
*/
|
||||||
@NotThreadSafe
|
@NotThreadSafe
|
||||||
|
@SuppressWarnings("OverrideThrowableToString")
|
||||||
public final class FormFieldException extends FormException {
|
public final class FormFieldException extends FormException {
|
||||||
|
|
||||||
private final List<Object> names = new ArrayList<>();
|
private final List<Object> names = new ArrayList<>();
|
||||||
|
@ -131,7 +133,7 @@ public final class FormFieldException extends FormException {
|
||||||
|
|
||||||
/** Returns self with {@code name} prepended, for propagating exceptions up the stack. */
|
/** Returns self with {@code name} prepended, for propagating exceptions up the stack. */
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
@VisibleForTesting
|
@VisibleForTesting(productionVisibility = Visibility.PACKAGE_PRIVATE)
|
||||||
public FormFieldException propagate(String name) {
|
public FormFieldException propagate(String name) {
|
||||||
return propagateImpl(name);
|
return propagateImpl(name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue