@Test public void triesOnlyOnceIfUserPassExists() throws Exception { doThrow(authException).doThrow(new RuntimeException("second try")).when(shell).connect(connectionConfig, null); doReturn("bob").when(connectionConfig).username(); doReturn("secret").when(connectionConfig).password(); InputStream inputStream = new ByteArrayInputStream("".getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); Main main = new Main(inputStream, ps); try { main.connectMaybeInteractively(shell, connectionConfig, true, true, true); fail("Expected an exception"); } catch (Neo4jException e) { assertEquals(authException.code(), e.code()); verify(shell, times(1)).connect(connectionConfig, null); } }
void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); static void main(String[] args); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); static void main(String[] args); static final int EXIT_FAILURE; static final int EXIT_SUCCESS; }