use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldReadUsernameAndPasswordFromUserInput.
@Test
public void shouldReadUsernameAndPasswordFromUserInput() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
String password = "abc";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, password)).build();
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
// then
verify(targetCommunicator).authenticate(anyBoolean(), any(), eq(username), eq(password.toCharArray()), anyBoolean());
verify(targetCommunicator).copy(anyBoolean(), any(), any(), any(), eq(false), any());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptDatabaseNameAsSource.
@Test
public void shouldAcceptDatabaseNameAsSource() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
DumpCreator dumpCreator = mockedDumpCreator();
PushToCloudCommand command = command().copier(targetCommunicator).dumpCreator(dumpCreator).build();
// when
String databaseName = DBNAME;
String[] args = { "--database", databaseName, "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
// then
verify(dumpCreator).dumpDatabase(eq(databaseName), any());
verify(targetCommunicator).checkSize(anyBoolean(), any(), anyLong(), any());
verify(targetCommunicator).copy(anyBoolean(), any(), any(), any(), eq(true), any());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldFailOnDumpPointingToMissingFile.
@Test
public void shouldFailOnDumpPointingToMissingFile() throws IOException, CommandFailedException {
// given
PushToCloudCommand command = command().copier(mockedTargetCommunicator()).build();
// when
Path dumpFile = directory.file("some-dump-file");
String[] args = { "--dump", dumpFile.toAbsolutePath().toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
int returnValue = new CommandLine(command).execute(args);
assertNotEquals(0, returnValue, "Expected command to fail");
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptPasswordViaArgAndPromptForUsername.
@Test
public void shouldAcceptPasswordViaArgAndPromptForUsername() throws IOException, CommandFailedException {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, "tomte")).build();
Path dump = this.dump;
// when
String[] args = { "--dump", dump.toString(), "--password", "pass", "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("neo4j"), eq("pass".toCharArray()), anyBoolean());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptPasswordViaEnvAndPromptForUsername.
@Test
public void shouldAcceptPasswordViaEnvAndPromptForUsername() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, "tomte")).build();
Path dump = this.dump;
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
var environment = Map.of("NEO4J_USERNAME", "", "NEO4J_PASSWORD", "pass");
new CommandLine(command).setResourceBundle(new MapResourceBundle(environment)).execute(args);
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("neo4j"), eq("pass".toCharArray()), anyBoolean());
}
Aggregations