-
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.
#1012: remove findX test (already covered by PersistenceBase tests)
- Loading branch information
1 parent
1c9e98f
commit a7908c4
Showing
2 changed files
with
10 additions
and
43 deletions.
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
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 |
---|---|---|
|
@@ -3,17 +3,13 @@ | |
import ch.puzzle.okr.models.User; | ||
import ch.puzzle.okr.multitenancy.TenantContext; | ||
import ch.puzzle.okr.test.SpringIntegrationTest; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@SpringIntegrationTest | ||
class UserPersistenceServiceIT { | ||
|
@@ -39,41 +35,6 @@ void tearDown() { | |
TenantContext.setCurrentTenant(null); | ||
} | ||
|
||
@Test | ||
void shouldReturnAllUsersCorrect() throws ResponseStatusException { | ||
List<User> userList = userPersistenceService.findAll(); | ||
|
||
Assertions.assertThat(userList.size()).isGreaterThanOrEqualTo(7); | ||
} | ||
|
||
@Test | ||
void shouldReturnSingleUserWhenFindingOwnerByValidId() { | ||
User returnedUser = userPersistenceService.findById(1L); | ||
|
||
assertEquals(1L, returnedUser.getId()); | ||
assertEquals("Paco", returnedUser.getFirstname()); | ||
assertEquals("Eggimann", returnedUser.getLastname()); | ||
assertEquals("[email protected]", returnedUser.getEmail()); | ||
} | ||
|
||
@Test | ||
void shouldThrowExceptionWhenFindingOwnerNotFound() { | ||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, | ||
() -> userPersistenceService.findById(321L)); | ||
|
||
assertEquals(HttpStatus.NOT_FOUND, exception.getStatusCode()); | ||
assertEquals("MODEL_WITH_ID_NOT_FOUND", exception.getReason()); | ||
} | ||
|
||
@Test | ||
void shouldThrowExceptionWhenFindingOwnerWithNullId() { | ||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, | ||
() -> userPersistenceService.findById(null)); | ||
|
||
assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); | ||
assertEquals("ATTRIBUTE_NULL", exception.getReason()); | ||
} | ||
|
||
@Test | ||
void getOrCreateUserShouldReturnSingleUserWhenUserFound() { | ||
User existingUser = User.Builder.builder().withEmail(EMAIL_ALICE).build(); | ||
|
@@ -88,8 +49,12 @@ void getOrCreateUserShouldReturnSingleUserWhenUserFound() { | |
|
||
@Test | ||
void getOrCreateUserShouldReturnSavedUserWhenUserNotFound() { | ||
User newUser = User.Builder.builder().withId(null).withFirstname("firstname").withLastname("lastname") | ||
.withEmail("[email protected]").build(); | ||
User newUser = User.Builder.builder() // | ||
.withId(null) // | ||
.withFirstname("firstname") // | ||
.withLastname("lastname") // | ||
.withEmail("[email protected]") // | ||
.build(); | ||
|
||
createdUser = userPersistenceService.getOrCreateUser(newUser); | ||
|
||
|