LoginDelegator extends BaseDelegator implements ILoginDelegator { @Override public boolean isDontWriteTicket(final String cmd, final String[] cmdArgs) { if (isNotBlank(cmd)) { if (LOGIN.toString().equalsIgnoreCase(cmd)) { if (nonNull(cmdArgs)) { for (String arg : cmdArgs) { if (isNotBlank(arg) && "-p".equals(arg)) { return true; } } } } } return false; } LoginDelegator(final IOptionsServer server); @Override String getLoginStatus(); @Override void login(final String password); @Override void login(final String password, final boolean allHosts); @Override boolean isDontWriteTicket(final String cmd, final String[] cmdArgs); @Override void login(final String password, final LoginOptions opts); @Override void login(final String password, final StringBuffer ticket, final LoginOptions opts); @Override void login(@Nonnull final IUser user, final StringBuffer ticket, final LoginOptions opts);  }
@Test public void testIsDontWriteTicket() { assertTrue("-p option should resolve as true", loginDelegator.isDontWriteTicket(LOGIN.name(), new String[] { "-p" })); assertTrue("-p option with others should resolve as true", loginDelegator .isDontWriteTicket(LOGIN.name(), new String[] { "-q", "-p", "-o", "-i" })); assertFalse("blank option should resolve as false", loginDelegator.isDontWriteTicket(LOGIN.name(), new String[] { "" })); assertFalse("empty option should resolve as false", loginDelegator.isDontWriteTicket(LOGIN.name(), new String[] {})); assertFalse("null option should resolve as false", loginDelegator.isDontWriteTicket(LOGIN.name(), null)); assertFalse("other options should resolve as false", loginDelegator.isDontWriteTicket(LOGIN.name(), new String[] { "-q", "-o", "-i" })); }