mirror of
https://github.com/google/nomulus
synced 2026-09-28 10:45:36 +00:00
Convert a bunch more @AutoValues to records (#2412)
This commit is contained in:
+2
-1
@@ -200,7 +200,8 @@ public class FakeSecretManagerClient implements SecretManagerClient {
|
||||
Iterable<SecretVersionState> listVersions() {
|
||||
ImmutableList.Builder<SecretVersionState> builder = new ImmutableList.Builder<>();
|
||||
for (int i = 0; i < versions.size(); i++) {
|
||||
builder.add(SecretVersionState.of(secretId, String.valueOf(i), versions.get(i).getState()));
|
||||
builder.add(
|
||||
SecretVersionState.create(secretId, String.valueOf(i), versions.get(i).getState()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2024 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.privileges.secretmanager;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link SqlCredential}. */
|
||||
public class SqlCredentialTest {
|
||||
|
||||
@Test
|
||||
void secrets_arentWrittenOutByToString() {
|
||||
SqlCredential cred = SqlCredential.create("joshua", "rosebud");
|
||||
String credStr = cred.toString();
|
||||
assertThat(credStr).doesNotContain("joshua");
|
||||
assertThat(credStr).doesNotContain("rosebud");
|
||||
}
|
||||
}
|
||||
@@ -14,20 +14,13 @@
|
||||
|
||||
package google.registry.server;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
|
||||
/** Pair of servlet path and servlet instance object. */
|
||||
@AutoValue
|
||||
public abstract class Route {
|
||||
|
||||
abstract String path();
|
||||
abstract Class<? extends HttpServlet> servletClass();
|
||||
public record Route(String path, Class<? extends HttpServlet> servletClass) {
|
||||
|
||||
/** Creates a new route mapping between a path (may have wildcards) and a servlet. */
|
||||
public static Route route(String path, Class<? extends HttpServlet> servletClass) {
|
||||
return new AutoValue_Route(path, servletClass);
|
||||
return new Route(path, servletClass);
|
||||
}
|
||||
|
||||
Route() {}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.ResourceUtils.readResourceBytes;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.MoreFiles;
|
||||
@@ -40,14 +39,9 @@ import javax.annotation.Nullable;
|
||||
/** Contains helper methods for dealing with test data. */
|
||||
public final class TestDataHelper {
|
||||
|
||||
@AutoValue
|
||||
abstract static class FileKey {
|
||||
abstract Class<?> context();
|
||||
|
||||
abstract String filename();
|
||||
|
||||
record FileKey(Class<?> context, String filename) {
|
||||
static FileKey create(Class<?> context, String filename) {
|
||||
return new AutoValue_TestDataHelper_FileKey(context, filename);
|
||||
return new FileKey(context, filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,35 +14,25 @@
|
||||
|
||||
package google.registry.testing;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
/**
|
||||
* Container for values passed to {@link UserServiceExtension} to set the logged-in user for tests.
|
||||
*/
|
||||
@AutoValue
|
||||
public abstract class UserInfo {
|
||||
|
||||
abstract String email();
|
||||
abstract String authDomain();
|
||||
abstract boolean isAdmin();
|
||||
abstract boolean isLoggedIn();
|
||||
public record UserInfo(String email, String authDomain, boolean isAdmin, boolean isLoggedIn) {
|
||||
|
||||
/** Creates a new logged-in non-admin user instance. */
|
||||
public static UserInfo create(String email) {
|
||||
String authDomain = email.substring(email.indexOf('@') + 1);
|
||||
return new AutoValue_UserInfo(email, authDomain, false, true);
|
||||
return new UserInfo(email, authDomain, false, true);
|
||||
}
|
||||
|
||||
/** Creates a new logged-in admin user instance. */
|
||||
public static UserInfo createAdmin(String email) {
|
||||
String authDomain = email.substring(email.indexOf('@') + 1);
|
||||
return new AutoValue_UserInfo(email, authDomain, true, true);
|
||||
return new UserInfo(email, authDomain, true, true);
|
||||
}
|
||||
|
||||
/** Returns a logged-out user instance. */
|
||||
public static UserInfo loggedOut() {
|
||||
return new AutoValue_UserInfo("", "", false, false);
|
||||
return new UserInfo("", "", false, false);
|
||||
}
|
||||
|
||||
UserInfo() {}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static java.lang.Math.abs;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.auto.value.AutoBuilder;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.awt.Color;
|
||||
@@ -59,35 +59,30 @@ class WebDriverScreenDiffer implements ScreenDiffer {
|
||||
this.actualScreenshots = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
abstract static class ComparisonResult {
|
||||
abstract ActualScreenshot actualScreenshot();
|
||||
|
||||
abstract boolean isConsideredSimilar();
|
||||
|
||||
abstract boolean isMissingGoldenImage();
|
||||
|
||||
abstract boolean isSizeDifferent();
|
||||
|
||||
abstract int numDiffPixels();
|
||||
record ComparisonResult(
|
||||
ActualScreenshot actualScreenshot,
|
||||
boolean isConsideredSimilar,
|
||||
boolean isMissingGoldenImage,
|
||||
boolean isSizeDifferent,
|
||||
int numDiffPixels) {
|
||||
|
||||
static Builder builder() {
|
||||
return new AutoValue_WebDriverScreenDiffer_ComparisonResult.Builder();
|
||||
return new AutoBuilder_WebDriverScreenDiffer_ComparisonResult_Builder();
|
||||
}
|
||||
|
||||
@AutoValue.Builder
|
||||
abstract static class Builder {
|
||||
abstract Builder setActualScreenshot(ActualScreenshot actualScreenshot);
|
||||
@AutoBuilder
|
||||
interface Builder {
|
||||
Builder setActualScreenshot(ActualScreenshot actualScreenshot);
|
||||
|
||||
abstract Builder setIsConsideredSimilar(boolean isConsideredSimilar);
|
||||
Builder setIsConsideredSimilar(boolean isConsideredSimilar);
|
||||
|
||||
abstract Builder setIsMissingGoldenImage(boolean isMissingGoldenImage);
|
||||
Builder setIsMissingGoldenImage(boolean isMissingGoldenImage);
|
||||
|
||||
abstract Builder setIsSizeDifferent(boolean isSizeDifferent);
|
||||
Builder setIsSizeDifferent(boolean isSizeDifferent);
|
||||
|
||||
abstract Builder setNumDiffPixels(int numDiffPixels);
|
||||
Builder setNumDiffPixels(int numDiffPixels);
|
||||
|
||||
abstract ComparisonResult build();
|
||||
ComparisonResult build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user