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

    student.setUsername(USERNAME);

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

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

    student.setUsername(USERNAME);

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

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

    student.setUsername(USERNAME);

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

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

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

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

    assertFalse(student.equals(other));
  }