use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptUsernameViaArgAndPromptForPassword.
@Test
public void shouldAcceptUsernameViaArgAndPromptForPassword() throws IOException, CommandFailedException {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
String password = "abc";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, password)).build();
Path dump = this.dump;
// when
String[] args = { "--dump", dump.toString(), "--username", "user", "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
assertTrue(Files.exists(dump));
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("user"), eq("abc".toCharArray()), anyBoolean());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldRecognizeBothEnvironmentAndDatabaseIdFromBoltURI.
// TODO: 2019-08-07 shouldFailOnDumpPointingToInvalidDumpFile
@Test
public void shouldRecognizeBothEnvironmentAndDatabaseIdFromBoltURI() throws IOException, CommandFailedException {
// given
Copier copier = mock(Copier.class);
PushToCloudCommand command = command().copier(copier).build();
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", "bolt+routing://mydbid-testenvironment.databases.neo4j.io" };
new CommandLine(command).execute(args);
// then
verify(copier).copy(anyBoolean(), eq("https://console-testenvironment.neo4j.io/v1/databases/mydbid"), eq("bolt+routing://mydbid-testenvironment.databases.neo4j.io"), any(), eq(false), any());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldFailOnDatabaseNameAsSourceUsingExistingDumpTarget.
@Test
public void shouldFailOnDatabaseNameAsSourceUsingExistingDumpTarget() throws IOException, CommandFailedException {
// given
Copier targetCommunicator = mockedTargetCommunicator();
DumpCreator dumpCreator = mockedDumpCreator();
PushToCloudCommand command = command().copier(targetCommunicator).dumpCreator(dumpCreator).build();
// when
String databaseName = DBNAME;
Path dumpFile = directory.file("some-dump-file-that-exists");
Files.write(dumpFile, "some data".getBytes());
String[] args = { "--database", databaseName, "--dump-to", dumpFile.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 shouldAcceptUsernameViaEnvAndPromptForPassword.
@Test
public void shouldAcceptUsernameViaEnvAndPromptForPassword() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
String password = "abc";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, password)).build();
Path dump = this.dump;
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
var environment = Map.of("NEO4J_USERNAME", "user", "NEO4J_PASSWORD", "");
new CommandLine(command).setResourceBundle(new MapResourceBundle(environment)).execute(args);
assertTrue(Files.exists(dump));
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("user"), eq("abc".toCharArray()), anyBoolean());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldRecognizeDatabaseIdFromBoltURI.
@Test
public void shouldRecognizeDatabaseIdFromBoltURI() throws IOException, CommandFailedException {
// given
Copier copier = mock(Copier.class);
PushToCloudCommand command = command().copier(copier).build();
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", "bolt+routing://mydbid.databases.neo4j.io" };
new CommandLine(command).execute(args);
// then
verify(copier).copy(anyBoolean(), eq("https://console.neo4j.io/v1/databases/mydbid"), eq("bolt+routing://mydbid.databases.neo4j.io"), any(), eq(false), any());
}
Aggregations