mirror of
https://github.com/google/nomulus.git
synced 2025-08-12 20:49:37 +02:00
Remove usage of the AppEngine remote API (#1858)
This is only used for contacting Datastore. With the removal of: 1. All standard usages of Datastore 2. Usage of Datastore for allocation of object IDs 3. Usage of Datastore for GAE user IDs we can remove the remote API without affecting functionality. This also allows us to just use SQL for every command since it's lazily supplied. This simplifies the SQL setup and means that we remove a possible situation where we forget the SQL setup.
This commit is contained in:
parent
7b0b104616
commit
1e2b17fff7
55 changed files with 99 additions and 440 deletions
|
@ -145,40 +145,29 @@ class ShellCommandTest {
|
|||
shellCommand.run();
|
||||
}
|
||||
|
||||
static class MockCli implements CommandRunner {
|
||||
public ArrayList<ImmutableList<String>> calls = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void run(String[] args) {
|
||||
calls.add(ImmutableList.copyOf(args));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleCommandInvocations() throws Exception {
|
||||
try (RegistryCli cli =
|
||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyExtension);
|
||||
cli.setEnvironment(RegistryToolEnvironment.UNITTEST);
|
||||
cli.run(new String[] {"test_command", "-x", "xval", "arg1", "arg2"});
|
||||
cli.run(new String[] {"test_command", "-x", "otherxval", "arg3"});
|
||||
cli.run(new String[] {"test_command"});
|
||||
assertThat(TestCommand.commandInvocations)
|
||||
.containsExactly(
|
||||
ImmutableList.of("xval", "arg1", "arg2"),
|
||||
ImmutableList.of("otherxval", "arg3"),
|
||||
ImmutableList.of("default value"));
|
||||
}
|
||||
RegistryCli cli =
|
||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class));
|
||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyExtension);
|
||||
cli.setEnvironment(RegistryToolEnvironment.UNITTEST);
|
||||
cli.run(new String[] {"test_command", "-x", "xval", "arg1", "arg2"});
|
||||
cli.run(new String[] {"test_command", "-x", "otherxval", "arg3"});
|
||||
cli.run(new String[] {"test_command"});
|
||||
assertThat(TestCommand.commandInvocations)
|
||||
.containsExactly(
|
||||
ImmutableList.of("xval", "arg1", "arg2"),
|
||||
ImmutableList.of("otherxval", "arg3"),
|
||||
ImmutableList.of("default value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonExistentCommand() {
|
||||
try (RegistryCli cli =
|
||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
||||
RegistryCli cli =
|
||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class));
|
||||
|
||||
cli.setEnvironment(RegistryToolEnvironment.UNITTEST);
|
||||
assertThrows(MissingCommandException.class, () -> cli.run(new String[] {"bad_command"}));
|
||||
}
|
||||
cli.setEnvironment(RegistryToolEnvironment.UNITTEST);
|
||||
assertThrows(MissingCommandException.class, () -> cli.run(new String[] {"bad_command"}));
|
||||
}
|
||||
|
||||
private void performJCommanderCompletorTest(
|
||||
|
@ -341,12 +330,22 @@ class ShellCommandTest {
|
|||
System.setIn(new ByteArrayInputStream("command1\n".getBytes(UTF_8)));
|
||||
}
|
||||
|
||||
static class MockCli implements CommandRunner {
|
||||
public ArrayList<ImmutableList<String>> calls = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void run(String[] args) {
|
||||
calls.add(ImmutableList.copyOf(args));
|
||||
}
|
||||
}
|
||||
|
||||
@Parameters(commandDescription = "Test command")
|
||||
static class TestCommand implements Command {
|
||||
enum OrgType {
|
||||
PRIVATE,
|
||||
PUBLIC
|
||||
}
|
||||
// List for recording command invocations by run().
|
||||
//
|
||||
// This has to be static because it gets populated by multiple TestCommand instances, which are
|
||||
// created in RegistryCli by using reflection to call the constructor.
|
||||
static final List<List<String>> commandInvocations = new ArrayList<>();
|
||||
|
||||
@Parameter(
|
||||
names = {"-x", "--xparam"},
|
||||
|
@ -357,13 +356,6 @@ class ShellCommandTest {
|
|||
names = {"--xorg"},
|
||||
description = "test organization")
|
||||
OrgType orgType = OrgType.PRIVATE;
|
||||
|
||||
// List for recording command invocations by run().
|
||||
//
|
||||
// This has to be static because it gets populated by multiple TestCommand instances, which are
|
||||
// created in RegistryCli by using reflection to call the constructor.
|
||||
static final List<List<String>> commandInvocations = new ArrayList<>();
|
||||
|
||||
@Parameter(description = "normal argument")
|
||||
List<String> args;
|
||||
|
||||
|
@ -378,6 +370,11 @@ class ShellCommandTest {
|
|||
}
|
||||
commandInvocations.add(callRecord.build());
|
||||
}
|
||||
|
||||
enum OrgType {
|
||||
PRIVATE,
|
||||
PUBLIC
|
||||
}
|
||||
}
|
||||
|
||||
@Parameters(commandDescription = "Another test command")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue