diff --git a/core/src/main/java/google/registry/persistence/converter/VKeyConverter.java b/core/src/main/java/google/registry/persistence/converter/VKeyConverter.java index ad2b96938..c72145c62 100644 --- a/core/src/main/java/google/registry/persistence/converter/VKeyConverter.java +++ b/core/src/main/java/google/registry/persistence/converter/VKeyConverter.java @@ -18,9 +18,7 @@ import google.registry.persistence.VKey; import javax.annotation.Nullable; import javax.persistence.AttributeConverter; -/** - * Converts VKey to a string column. - */ +/** Converts VKey to a string column. */ public abstract class VKeyConverter implements AttributeConverter, String> { @Override @Nullable @@ -34,8 +32,6 @@ public abstract class VKeyConverter implements AttributeConverter, St return dbData == null ? null : VKey.createSql(getAttributeClass(), dbData); } - /** - * Returns the class of the attribute. - */ + /** Returns the class of the attribute. */ protected abstract Class getAttributeClass(); } diff --git a/core/src/main/java/google/registry/tools/DomainLockUtils.java b/core/src/main/java/google/registry/tools/DomainLockUtils.java index ee0bf4c4f..abb8ca794 100644 --- a/core/src/main/java/google/registry/tools/DomainLockUtils.java +++ b/core/src/main/java/google/registry/tools/DomainLockUtils.java @@ -153,8 +153,8 @@ public final class DomainLockUtils { /** * Creates and applies a lock in one step. * - *

This should only be used for admin actions, e.g. Nomulus tool commands or relocks. - * Note: in the case of relocks, isAdmin is determined by the previous lock. + *

This should only be used for admin actions, e.g. Nomulus tool commands or relocks. Note: in + * the case of relocks, isAdmin is determined by the previous lock. */ public RegistryLock administrativelyApplyLock( String domainName, String registrarId, @Nullable String registrarPocId, boolean isAdmin) { @@ -175,7 +175,7 @@ public final class DomainLockUtils { /** * Creates and applies an unlock in one step. - * + * *

This should only be used for admin actions, e.g. Nomulus tool commands. */ public RegistryLock administrativelyApplyUnlock( diff --git a/core/src/main/java/google/registry/tools/RegistryCli.java b/core/src/main/java/google/registry/tools/RegistryCli.java index afb33e522..2f8ee9bce 100644 --- a/core/src/main/java/google/registry/tools/RegistryCli.java +++ b/core/src/main/java/google/registry/tools/RegistryCli.java @@ -132,10 +132,8 @@ final class RegistryCli implements AutoCloseable, CommandRunner { jcommander.parse(args); } catch (ParameterException e) { // If we failed to fully parse the command but at least found a valid command name, show only - // the usage for that command. Otherwise, show full usage. Either way, rethrow the error. - if (jcommander.getParsedCommand() == null) { - jcommander.usage(); - } else { + // the usage for that command. + if (jcommander.getParsedCommand() != null) { jcommander.usage(jcommander.getParsedCommand()); } // Don't rethrow if we said: nomulus command --help @@ -144,8 +142,13 @@ final class RegistryCli implements AutoCloseable, CommandRunner { } throw e; } - - if (showAllCommands) { + String parsedCommand = jcommander.getParsedCommand(); + // Show the list of all commands either if requested or if no subcommand name was specified + // (which does not throw a ParameterException parse error above). + if (showAllCommands || parsedCommand == null) { + if (parsedCommand == null) { + System.out.println("The list of available subcommands is:"); + } commands.keySet().forEach(System.out::println); return; } @@ -161,8 +164,7 @@ final class RegistryCli implements AutoCloseable, CommandRunner { // retrieving the first (and, by virtue of our usage, only) object from it. Command command = (Command) - Iterables.getOnlyElement( - jcommander.getCommands().get(jcommander.getParsedCommand()).getObjects()); + Iterables.getOnlyElement(jcommander.getCommands().get(parsedCommand).getObjects()); loggingParams.configureLogging(); // Must be called after parameters are parsed. try { diff --git a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java index 46c95d411..145f94a60 100644 --- a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java +++ b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java @@ -186,9 +186,7 @@ public final class RegistrarFormFields { .build(); public static final FormField REGISTRY_LOCK_EMAIL_ADDRESS_FIELD = - FormFields.EMAIL - .asBuilderNamed("registryLockEmailAddress") - .build(); + FormFields.EMAIL.asBuilderNamed("registryLockEmailAddress").build(); public static final FormField CONTACT_VISIBLE_IN_WHOIS_AS_ADMIN_FIELD = FormField.named("visibleInWhoisAsAdmin", Boolean.class) diff --git a/core/src/nonprod/java/google/registry/tools/DumpGoldenSchemaCommand.java b/core/src/nonprod/java/google/registry/tools/DumpGoldenSchemaCommand.java index 34586247a..d9aa1ddb9 100644 --- a/core/src/nonprod/java/google/registry/tools/DumpGoldenSchemaCommand.java +++ b/core/src/nonprod/java/google/registry/tools/DumpGoldenSchemaCommand.java @@ -64,8 +64,8 @@ public class DumpGoldenSchemaCommand extends PostgresqlCommand { if (result.getExitCode() != 0) { throw new RuntimeException(result.toString()); } - result = postgresContainer.execInContainer( - "cp", CONTAINER_MOUNT_POINT_TMP, CONTAINER_MOUNT_POINT); + result = + postgresContainer.execInContainer("cp", CONTAINER_MOUNT_POINT_TMP, CONTAINER_MOUNT_POINT); if (result.getExitCode() != 0) { throw new RuntimeException(result.toString()); } diff --git a/core/src/test/java/google/registry/persistence/converter/VKeyConverterTest.java b/core/src/test/java/google/registry/persistence/converter/VKeyConverterTest.java index 0f81309c5..7d22c0c79 100644 --- a/core/src/test/java/google/registry/persistence/converter/VKeyConverterTest.java +++ b/core/src/test/java/google/registry/persistence/converter/VKeyConverterTest.java @@ -45,8 +45,8 @@ public class VKeyConverterTest { jpaTm().transact(() -> jpaTm().getEntityManager().persist(original)); TestEntity retrieved = - jpaTm().transact( - () -> jpaTm().getEntityManager().find(TestEntity.class, "TheRealSpartacus")); + jpaTm() + .transact(() -> jpaTm().getEntityManager().find(TestEntity.class, "TheRealSpartacus")); assertThat(retrieved.other.getSqlKey()).isEqualTo("ImSpartacus!"); } @@ -60,8 +60,7 @@ public class VKeyConverterTest { @Entity(name = "TestEntity") static class TestEntity { - @Id - String id; + @Id String id; // Specifying "@Converter(autoApply = true) on TestEntityVKeyConverter this doesn't seem to // work. diff --git a/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java b/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java index 45919fbf6..33e4fc6ac 100644 --- a/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java +++ b/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java @@ -98,19 +98,20 @@ public class RegistrarContactCommandTest extends CommandTestCase RegistryTool.main(new String[] {})); + assertThat(thrown).hasMessageThat().contains("Please specify the environment flag"); + } + + private String getStdout() { + return new String(stdout.toByteArray(), UTF_8); + } +}