use of org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptDatabaseNameAsSourceUsingGivenDumpTarget.
@Test
public void shouldAcceptDatabaseNameAsSourceUsingGivenDumpTarget() throws Exception {
// 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");
String[] args = { "--database", databaseName, "--dump-to", dumpFile.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
// then
verify(dumpCreator).dumpDatabase(databaseName, dumpFile);
verify(targetCommunicator).copy(anyBoolean(), any(), any(), any(), eq(true), any());
}
use of org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldChooseToDumpDefaultDatabaseIfNeitherDumpNorDatabaseIsGiven.
@Test
public void shouldChooseToDumpDefaultDatabaseIfNeitherDumpNorDatabaseIsGiven() throws IOException, CommandFailedException {
// given
DumpCreator dumpCreator = mockedDumpCreator();
Copier copier = mock(Copier.class);
PushToCloudCommand command = command().dumpCreator(dumpCreator).copier(copier).build();
// when
String[] args = { "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
// then
verify(dumpCreator).dumpDatabase(eq(DEFAULT_DATABASE_NAME), any());
verify(copier).copy(anyBoolean(), any(), any(), any(), eq(true), any());
}
use of org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator 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 org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator in project neo4j by neo4j.
the class PushToCloudCommandTest method mockedDumpCreator.
private DumpCreator mockedDumpCreator() throws CommandFailedException {
DumpCreator dumpCreator = mock(DumpCreator.class);
when(dumpCreator.dumpDatabase(anyString(), any())).thenReturn(dump);
return dumpCreator;
}
use of org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator 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());
}
Aggregations