@Test public void studentIsEqualToStudentWithSameUsername() { student.setUsername(USERNAME); final Student other = new Student(); other.setUsername(USERNAME); assertTrue(student.equals(other)); }
@Test public void studentIsNotEqualToStudentWithOtherUsername() { student.setUsername(USERNAME); final Student other = new Student(); other.setUsername("NotSame"); assertFalse(student.equals(other)); }
@Test public void hashCodeIsSameForTwoUsersWithSameUsernames() { final Student student1 = new Student(); student1.setUsername(USERNAME); final Student student2 = new Student(); student2.setUsername(USERNAME); assertEquals(student1.hashCode(), student2.hashCode()); }
@Test public void hashCodeIsNotSameForTwoUsersWithDifferentUsernames() { final Student student1 = new Student(); student1.setUsername(USERNAME); final Student student2 = new Student(); student2.setUsername("notSame"); assertThat(student1.hashCode(), is(not(student2.hashCode()))); }
@Test public void canSetUsername() { student.setUsername(USERNAME); assertEquals(USERNAME, student.getUsername()); }
@Test public void idIsSetBasedOnUsername() { final String expectedId = Base64.encodeBase64URLSafeString(USERNAME.getBytes()); student.setUsername(USERNAME); assertEquals(expectedId, student.getId()); }
@Test public void studentWithNullUsernameIsNotEqualToStudentWithNonNullUsername() { final Student other = new Student(); other.setUsername(USERNAME); assertFalse(student.equals(other)); }