Bael 2810 data jpa delete (#6759)
* BAEL-2810: Finished the examples and unit tests. * BAEL-2810: Changed assertions to isEqualTo * BAEL-2810: Changed the test of the derived query to reflect the number of the deleted records
This commit is contained in:
parent
fd5afd015a
commit
93dfb77f1f
|
@ -43,22 +43,22 @@ public class DeleteFromRepositoryUnitTest {
|
|||
public void whenDeleteByIdFromRepository_thenDeletingShouldBeSuccessful() {
|
||||
repository.deleteById(book1.getId());
|
||||
|
||||
assertThat(repository.count() == 1).isTrue();
|
||||
assertThat(repository.count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeleteAllFromRepository_thenRepositoryShouldBeEmpty() {
|
||||
repository.deleteAll();
|
||||
|
||||
assertThat(repository.count() == 0).isTrue();
|
||||
assertThat(repository.count()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void whenDeleteFromDerivedQuery_thenDeletingShouldBeSuccessful() {
|
||||
repository.deleteByTitle("The Hobbit");
|
||||
long deletedRecords = repository.deleteByTitle("The Hobbit");
|
||||
|
||||
assertThat(repository.count() == 1).isTrue();
|
||||
assertThat(deletedRecords).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -66,7 +66,7 @@ public class DeleteFromRepositoryUnitTest {
|
|||
public void whenDeleteFromCustomQuery_thenDeletingShouldBeSuccessful() {
|
||||
repository.deleteBooks("The Hobbit");
|
||||
|
||||
assertThat(repository.count() == 1).isTrue();
|
||||
assertThat(repository.count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
}
|
|
@ -46,15 +46,15 @@ public class DeleteInRelationshipsUnitTest {
|
|||
public void whenDeletingCategories_thenBooksShouldAlsoBeDeleted() {
|
||||
categoryRepository.deleteAll();
|
||||
|
||||
assertThat(bookRepository.count() == 0).isTrue();
|
||||
assertThat(categoryRepository.count() == 0).isTrue();
|
||||
assertThat(bookRepository.count()).isEqualTo(0);
|
||||
assertThat(categoryRepository.count()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDeletingBooks_thenCategoriesShouldAlsoBeDeleted() {
|
||||
bookRepository.deleteAll();
|
||||
|
||||
assertThat(bookRepository.count() == 0).isTrue();
|
||||
assertThat(categoryRepository.count() == 2).isTrue();
|
||||
assertThat(bookRepository.count()).isEqualTo(0);
|
||||
assertThat(categoryRepository.count()).isEqualTo(2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue