-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f666f28
commit f9046c5
Showing
1 changed file
with
8 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ void tearDown() { | |
TenantContext.setCurrentTenant(null); | ||
} | ||
|
||
@DisplayName("findById() should return single entity if entity with id exists") | ||
@Test | ||
void findByIdShouldReturnSingleEntityIfEntityWithIdExists() { | ||
User foundUser = persistenceBase.findById(ID_USER_PACO); | ||
|
@@ -64,15 +65,17 @@ void findByIdShouldReturnSingleEntityIfEntityWithIdExists() { | |
assertUser("Paco", "Eggimann", "[email protected]", foundUser); | ||
} | ||
|
||
@DisplayName("findById() should throw exception if entity with id does not exists") | ||
@Test | ||
void findByIdShouldThrowExceptionIfEntityWithIdDoesNotExist() { | ||
void findByIdShouldThrowExceptionIfEntityWithIdDoesNotExists() { | ||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, | ||
() -> persistenceBase.findById(321L)); | ||
|
||
assertEquals(NOT_FOUND, exception.getStatusCode()); | ||
assertErrorKey("MODEL_WITH_ID_NOT_FOUND", exception); | ||
} | ||
|
||
@DisplayName("findById() should throw exception if id is null") | ||
@Test | ||
void findByIdShouldThrowExceptionIfIdIsNull() { | ||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, | ||
|
@@ -82,13 +85,15 @@ void findByIdShouldThrowExceptionIfIdIsNull() { | |
assertErrorKey("ATTRIBUTE_NULL", exception); | ||
} | ||
|
||
@DisplayName("findAll() should return all entities as list") | ||
@Test | ||
void findAllShouldReturnAllEntitiesAsList() throws ResponseStatusException { | ||
List<User> userList = persistenceBase.findAll(); | ||
|
||
assertThat(userList.size()).isGreaterThanOrEqualTo(7); | ||
} | ||
|
||
@DisplayName("save() should add new entity") | ||
@Test | ||
void saveShouldAddNewEntity() throws ResponseStatusException { | ||
createdUser = persistenceBase.save(USER_WITHOUT_CONSTRAINTS); | ||
|
@@ -97,6 +102,7 @@ void saveShouldAddNewEntity() throws ResponseStatusException { | |
assertUser("Hans", "Muster", "[email protected]", createdUser); | ||
} | ||
|
||
@DisplayName("save() existing entity with different data should update existing entity") | ||
@Test | ||
void saveExistingEntityWithDifferentDataShouldUpdateExistingEntity() throws ResponseStatusException { | ||
// arrange | ||
|
@@ -114,6 +120,7 @@ void saveExistingEntityWithDifferentDataShouldUpdateExistingEntity() throws Resp | |
assertEquals("Pekka", foundUser.getFirstname()); | ||
} | ||
|
||
@DisplayName("deleteById() should delete entity") | ||
@Test | ||
void deleteByIdShouldDeleteEntity() throws ResponseStatusException { | ||
// arrange | ||
|