Esempio n. 1
0
  @Test
  public void studentIsEqualToStudentWithSameUsername() {

    student.setUsername(USERNAME);

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

    assertTrue(student.equals(other));
  }
Esempio n. 2
0
  @Test
  public void studentIsNotEqualToStudentWithOtherUsername() {

    student.setUsername(USERNAME);

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

    assertFalse(student.equals(other));
  }
Esempio n. 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());
  }
Esempio n. 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())));
  }
Esempio n. 5
0
  @Test
  public void canSetUsername() {

    student.setUsername(USERNAME);

    assertEquals(USERNAME, student.getUsername());
  }
Esempio n. 6
0
  @Test
  public void idIsSetBasedOnUsername() {

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

    assertEquals(expectedId, student.getId());
  }
Esempio n. 7
0
  @Test
  public void studentWithNullUsernameIsNotEqualToStudentWithNonNullUsername() {

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

    assertFalse(student.equals(other));
  }