Пример #1
0
  @Test
  public void studentIsEqualToStudentWithSameUsername() {

    student.setUsername(USERNAME);

    final Student other = new Student();
    other.setUsername(USERNAME);

    assertTrue(student.equals(other));
  }
Пример #2
0
  @Test
  public void studentIsNotEqualToStudentWithOtherUsername() {

    student.setUsername(USERNAME);

    final Student other = new Student();
    other.setUsername("NotSame");

    assertFalse(student.equals(other));
  }
Пример #3
0
  @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());
  }
Пример #4
0
  @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())));
  }
Пример #5
0
  @Test
  public void canSetUsername() {

    student.setUsername(USERNAME);

    assertEquals(USERNAME, student.getUsername());
  }
Пример #6
0
  @Test
  public void idIsSetBasedOnUsername() {

    final String expectedId = Base64.encodeBase64URLSafeString(USERNAME.getBytes());
    student.setUsername(USERNAME);

    assertEquals(expectedId, student.getId());
  }
Пример #7
0
  @Test
  public void studentWithNullUsernameIsNotEqualToStudentWithNonNullUsername() {

    final Student other = new Student();
    other.setUsername(USERNAME);

    assertFalse(student.equals(other));
  }