コード例 #1
0
  private Aluno createAluno() {
    Aluno aluno = new Aluno();
    aluno.setName("Aluno 0");
    aluno.setEmail("*****@*****.**");
    aluno.setCreatedAt(new Date());

    return aluno;
  }
コード例 #2
0
  private List<Aluno> updateListAluno(List<Aluno> alunos) {
    List<Aluno> updatedAlunos = new ArrayList<Aluno>(3);
    for (int i = 4; i <= 6; i++) {
      Aluno aluno = new Aluno();
      aluno.setName("Aluno " + i);
      aluno.setEmail(alunos.get(i - 4).getEmail());
      aluno.setCreatedAt(alunos.get(i - 4).getCreatedAt());

      updatedAlunos.add(aluno);
    }

    return updatedAlunos;
  }
コード例 #3
0
  @Test
  public void testPersistAndGetByEmail() {
    Aluno aluno = createAluno();
    alunoRepository.persist(aluno);

    Aluno alunoExpected = alunoRepository.getByEmail(aluno.getEmail());
    Assert.assertEquals(alunoExpected.getName(), aluno.getName());
    Assert.assertEquals(alunoExpected.getEmail(), aluno.getEmail());
    Assert.assertEquals(alunoExpected.getCreatedAt(), aluno.getCreatedAt());
  }
コード例 #4
0
  private List<Aluno> createListAluno() {
    List<Aluno> alunos = new ArrayList<Aluno>(3);

    for (int i = 1; i <= 3; i++) {
      Aluno aluno = new Aluno();
      aluno.setName("Aluno " + i);
      aluno.setEmail("aluno" + i + "@google.com");
      aluno.setCreatedAt(new Date());

      alunos.add(aluno);
    }

    return alunos;
  }
コード例 #5
0
  @Test
  public void testBulkPersistAndGetByEmail() {
    List<Aluno> alunos = createListAluno();
    for (Aluno aluno : alunos) {
      alunoRepository.persist(aluno);
    }

    for (Aluno aluno : alunos) {
      Aluno alunoExpected = alunoRepository.getByEmail(aluno.getEmail());
      Assert.assertEquals(alunoExpected.getName(), aluno.getName());
      Assert.assertEquals(alunoExpected.getEmail(), aluno.getEmail());
      Assert.assertEquals(alunoExpected.getCreatedAt(), aluno.getCreatedAt());
    }
  }
コード例 #6
0
  @Test
  public void testPersistAndGetAll() {
    Aluno aluno = createAluno();
    alunoRepository.persist(aluno);

    List<Aluno> alunosExpected = alunoRepository.getAll();
    for (Aluno alunoExpected : alunosExpected) {
      Assert.assertEquals(alunoExpected.getName(), aluno.getName());
      Assert.assertEquals(alunoExpected.getEmail(), aluno.getEmail());
      Assert.assertEquals(alunoExpected.getCreatedAt(), aluno.getCreatedAt());
    }
  }
コード例 #7
0
  @Test
  public void testBulkPersistAndDelete() {
    List<Aluno> alunos = createListAluno();
    for (Aluno aluno : alunos) {
      alunoRepository.persist(aluno);
    }

    for (Aluno aluno : alunos) {
      Aluno alunoExpected = alunoRepository.getByEmail(aluno.getEmail());
      Assert.assertEquals(alunoExpected.getName(), aluno.getName());
      Assert.assertEquals(alunoExpected.getEmail(), aluno.getEmail());
      Assert.assertEquals(alunoExpected.getCreatedAt(), aluno.getCreatedAt());
    }

    for (Aluno aluno : alunos) {
      alunoRepository.delete(aluno);
    }

    // Test 1
    Assert.assertEquals(0, alunoRepository.getAll().size());

    // Test 2
    for (Aluno aluno : alunos) {
      Aluno alunoExpected = alunoRepository.getByEmail(aluno.getEmail());
      Assert.assertNull(alunoExpected);
    }
  }