Search in sources :

Example 11 with Copier

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;
}
Also used : Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier)

Example 12 with 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());
}
Also used : CommandLine(picocli.CommandLine) InOrder(org.mockito.InOrder) DumpCreator(org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 13 with Copier

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());
}
Also used : CommandLine(picocli.CommandLine) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 14 with Copier

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());
}
Also used : CommandLine(picocli.CommandLine) DumpCreator(org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 15 with Copier

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());
}
Also used : Path(java.nio.file.Path) CommandLine(picocli.CommandLine) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

Copier (org.neo4j.pushtocloud.PushToCloudCommand.Copier)18 Test (org.junit.jupiter.api.Test)17 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)17 CommandLine (picocli.CommandLine)17 Path (java.nio.file.Path)6 DumpCreator (org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator)5 InOrder (org.mockito.InOrder)1