Credentials implements Serializable { public Credentials(final String userName, final String password) { this.userName = encodeBase64(userName); this.password = encodeBase64(password); } Credentials(final String userName, final String password); String getUserName(); String getPassword(); boolean isEmpty(); @Override String toString(); static final Credentials EMPTY; }
@Test public void testCredentials() throws Exception { Credentials credentials = new Credentials("userid", null); assertEquals("userid", credentials.getUserName()); assertEquals(null, credentials.getPassword()); credentials = new Credentials(null, "password"); assertEquals(null, credentials.getUserName()); assertEquals("password", credentials.getPassword()); credentials = new Credentials(null, null); assertEquals(null, credentials.getUserName()); assertEquals(null, credentials.getPassword()); }