use of org.neo4j.pushtocloud.PushToCloudCommand.Copier in project neo4j by neo4j.
the class PushToCloudCommandTest method mockedTargetCommunicator.
private Copier mockedTargetCommunicator() throws CommandFailedException {
Copier copier = mock(Copier.class);
when(copier.authenticate(anyBoolean(), any(), any(), any(), anyBoolean())).thenReturn("abc");
return copier;
}
use of org.neo4j.pushtocloud.PushToCloudCommand.Copier in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAuthenticateBeforeDumping.
@Test
public void shouldAuthenticateBeforeDumping() throws CommandFailedException, IOException {
// given
Copier copier = mockedTargetCommunicator();
DumpCreator dumper = mockedDumpCreator();
PushToCloudCommand command = command().copier(copier).dumpCreator(dumper).build();
// when
String[] args = { "--bolt-uri", "bolt+routing://mydbid.databases.neo4j.io" };
new CommandLine(command).execute(args);
// then
InOrder inOrder = inOrder(copier, dumper);
inOrder.verify(copier).authenticate(anyBoolean(), anyString(), anyString(), any(), eq(false));
inOrder.verify(dumper).dumpDatabase(anyString(), any());
inOrder.verify(copier).copy(anyBoolean(), anyString(), eq("bolt+routing://mydbid.databases.neo4j.io"), any(), eq(true), anyString());
}
use of org.neo4j.pushtocloud.PushToCloudCommand.Copier 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 org.neo4j.pushtocloud.PushToCloudCommand.Copier 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 org.neo4j.pushtocloud.PushToCloudCommand.Copier 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());
}
Aggregations