UsernamePassword { public UsernamePassword(String username, String password) { this.username = username; this.password = password; } UsernamePassword(String username, String password); String getUsername(); String getPassword(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testUsernamePassword(){ UsernamePassword up = new UsernamePassword("foo", "bar"); assertEquals("foo", up.getUsername()); assertEquals("bar", up.getPassword()); UsernamePassword up2 = new UsernamePassword("foo", "bar"); UsernamePassword up3 = new UsernamePassword("foo", "bar2"); assertTrue(up.equals( up2 ) ); assertFalse(up.equals( up3 ) ); UsernamePassword up4 = new UsernamePassword("foo", "bar"); assertFalse(up4.equals(new String())); assertNotNull(up.hashCode()); }