@Test public void dropUserWithoutForcePrompts() throws Exception { AccumuloClient client = EasyMock.createMock(AccumuloClient.class); CommandLine cli = EasyMock.createMock(CommandLine.class); Shell shellState = EasyMock.createMock(Shell.class); ConsoleReader reader = EasyMock.createMock(ConsoleReader.class); SecurityOperations secOps = EasyMock.createMock(SecurityOperations.class); EasyMock.expect(shellState.getAccumuloClient()).andReturn(client); EasyMock.expect(cli.getArgs()).andReturn(new String[] {"user"}); EasyMock.expect(client.whoami()).andReturn("root"); EasyMock.expect(cli.hasOption("f")).andReturn(false); EasyMock.expect(shellState.getReader()).andReturn(reader); reader.flush(); EasyMock.expectLastCall().once(); EasyMock.expect(shellState.getReader()).andReturn(reader); EasyMock.expect(reader.readLine(EasyMock.anyObject(String.class))).andReturn("yes"); EasyMock.expect(shellState.getAccumuloClient()).andReturn(client); EasyMock.expect(client.securityOperations()).andReturn(secOps); secOps.dropLocalUser("user"); EasyMock.expectLastCall(); EasyMock.replay(client, cli, shellState, reader, secOps); cmd.execute("dropuser foo -f", cli, shellState); EasyMock.verify(client, cli, shellState, reader, secOps); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getAccumuloClient().whoami().equals(user)) { throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user)); } doDropUser(shellState, user, cl.hasOption(forceOpt.getOpt())); return 0; }
DropUserCommand extends Command { @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getAccumuloClient().whoami().equals(user)) { throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user)); } doDropUser(shellState, user, cl.hasOption(forceOpt.getOpt())); return 0; } }
DropUserCommand extends Command { @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getAccumuloClient().whoami().equals(user)) { throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user)); } doDropUser(shellState, user, cl.hasOption(forceOpt.getOpt())); return 0; }  }
DropUserCommand extends Command { @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getAccumuloClient().whoami().equals(user)) { throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user)); } doDropUser(shellState, user, cl.hasOption(forceOpt.getOpt())); return 0; }  @Override int execute(final String fullCommand, final CommandLine cl, final Shell shellState); @Override String description(); @Override String usage(); @Override void registerCompletion(final Token root,
      final Map<Command.CompletionSet,Set<String>> completionSet); @Override int numArgs(); @Override Options getOptions(); }
DropUserCommand extends Command { @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException { final String user = cl.getArgs()[0]; if (shellState.getAccumuloClient().whoami().equals(user)) { throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user)); } doDropUser(shellState, user, cl.hasOption(forceOpt.getOpt())); return 0; }  @Override int execute(final String fullCommand, final CommandLine cl, final Shell shellState); @Override String description(); @Override String usage(); @Override void registerCompletion(final Token root,
      final Map<Command.CompletionSet,Set<String>> completionSet); @Override int numArgs(); @Override Options getOptions();  }