@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); } }
@Test public void testBulkPersistAndUpdate() { 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()); } List<Aluno> updatedAlunos = updateListAluno(alunos); for (Aluno updatedAluno : updatedAlunos) { alunoRepository.update(updatedAluno); } for (Aluno updatedAluno : updatedAlunos) { Aluno alunoExpected = alunoRepository.getByEmail(updatedAluno.getEmail()); Assert.assertEquals(alunoExpected.getName(), updatedAluno.getName()); Assert.assertEquals(alunoExpected.getEmail(), updatedAluno.getEmail()); Assert.assertEquals(alunoExpected.getCreatedAt(), updatedAluno.getCreatedAt()); } }
@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()); }
@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()); } }