From a7908c46aa05cb93e281834b8e8eaa97cd086b51 Mon Sep 17 00:00:00 2001 From: clean-coder Date: Tue, 1 Oct 2024 14:43:46 +0200 Subject: [PATCH] #1012: remove findX test (already covered by PersistenceBase tests) --- .../UserTeamPersistenceService.java | 2 + .../persistence/UserPersistenceServiceIT.java | 51 +++---------------- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java index 326feabe4d..d74eba2fa6 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java @@ -14,10 +14,12 @@ protected UserTeamPersistenceService(UserTeamRepository repository) { super(repository); } + // TODO implement Test public void delete(UserTeam userTeam) { getRepository().delete(userTeam); } + // TODO implement Test public void deleteAll(List userTeamList) { getRepository().deleteAll(userTeamList); } diff --git a/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java b/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java index ca1dc10624..7cd956eef0 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java +++ b/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java @@ -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 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("peggimann@puzzle.ch", 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("lastname@puzzle.ch").build(); + User newUser = User.Builder.builder() // + .withId(null) // + .withFirstname("firstname") // + .withLastname("lastname") // + .withEmail("lastname@puzzle.ch") // + .build(); createdUser = userPersistenceService.getOrCreateUser(newUser);