Merge branch 'master' into master
This commit is contained in:
@@ -15,3 +15,4 @@
|
||||
- [Spring Data JPA and Named Entity Graphs](https://www.baeldung.com/spring-data-jpa-named-entity-graphs)
|
||||
- [Tagging and Filtering JUnit Tests](https://www.baeldung.com/junits-filtering-tests)
|
||||
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
||||
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
|
||||
|
||||
+5
-5
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user