fix: comparaison between two projects instead of their IDs
Some checks failed
Format / formatting (push) Successful in 6s
Build / build (push) Failing after 38s
CI / build (push) Successful in 14s

This commit is contained in:
Pierre Tellier 2025-04-06 20:14:43 +02:00
parent aaa6e46d0c
commit 9e1f568ea4
2 changed files with 10 additions and 1 deletions

View File

@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Objects;
@Service @Service
public class UtilsService { public class UtilsService {
@ -45,7 +47,9 @@ public class UtilsService {
User user = this.userService.getUserByEmail(mail); User user = this.userService.getUserByEmail(mail);
Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(user.getIdUser()); Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(user.getIdUser());
Project project = this.projectService.getProjectById(projectId); Project project = this.projectService.getProjectById(projectId);
return entrepreneur.getProjectParticipation().equals(project); // We compare the ID instead of the project themselves
return Objects.equals(
entrepreneur.getProjectParticipation().getIdProject(), project.getIdProject());
} }
// TODO: test // TODO: test
@ -56,6 +60,7 @@ public class UtilsService {
return true; return true;
} catch (ResponseStatusException e) { } catch (ResponseStatusException e) {
logger.info(e); logger.info(e);
return false; return false;
} }
} }

View File

@ -87,13 +87,17 @@ public class EntrepreneurApiServiceTest {
@Test @Test
void editValidSectionCell() { void editValidSectionCell() {
System.out.println("START\n\n\n");
entrepreneurApiService.editSectionCell( entrepreneurApiService.editSectionCell(
IterableToList(sectionCells).getFirst().getIdSectionCell(), IterableToList(sectionCells).getFirst().getIdSectionCell(),
"modified content", "modified content",
"entrepreneur@mail.fr"); "entrepreneur@mail.fr");
// We get the data from the database again.
sectionCells = sectionCellService.getSectionCellsByProject(project, 2L);
assertEquals( assertEquals(
"modified content", "modified content",
IterableToList(sectionCells).getFirst().getContentSectionCell()); IterableToList(sectionCells).getFirst().getContentSectionCell());
System.out.println("END\n\n\n");
} }
@Test @Test