fix: more tests working, still need fixes
Some checks failed
Format / formatting (push) Failing after 4s
Build / build (push) Failing after 5m8s
CI / build (push) Successful in 10s

This commit is contained in:
Théo Le Lez
2025-04-16 10:36:59 +02:00
parent 55112c8508
commit 6029457735
6 changed files with 168 additions and 18 deletions

View File

@ -65,15 +65,9 @@ public class EntrepreneurApiServiceTest {
project =
projectService.addNewProject(
new Project("Project", null, LocalDate.now(), ACTIVE, null, entrepreneur));
// projectService.updateProjectEntrepreneurParticipation(project.getIdProject(),
// entrepreneur); proxy error because why not
entrepreneurService.updateEntrepreneurProjectProposed(entrepreneur.getIdUser(), project);
entrepreneurService.updateEntrepreneurProjectParticipation(
entrepreneur.getIdUser(), project);
System.out.println(("real"));
System.out.println(entrepreneur);
// System.out.println(entrepreneur.getProjectProposed());
// System.out.println(entrepreneur.getProjectParticipation());
SectionCell s1 =
sectionCellService.addNewSectionCell(
new SectionCell(
@ -88,7 +82,7 @@ public class EntrepreneurApiServiceTest {
new SectionCell(
null,
3L,
"contenu très intéressant",
"contenu très intéressant2",
LocalDateTime.now(),
project));
sectionCells2 = sectionCellService.getSectionCellsByProject(project, 2L);
@ -104,13 +98,15 @@ public class EntrepreneurApiServiceTest {
@Test
void editValidSectionCell() {
entrepreneurApiService.editSectionCell(
IterableToList(sectionCells2).getFirst().getIdSectionCell(),
IterableToList(sectionCells2).getLast().getIdSectionCell(),
"modified content",
"entrepreneur@mail.fr");
// We get the data from the database again.
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getFirst();
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getLast();
assertEquals("modified content", s.getContentSectionCell());
assertEquals(
2, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
}
@Test
@ -120,6 +116,11 @@ public class EntrepreneurApiServiceTest {
() ->
entrepreneurApiService.editSectionCell(
-1L, "should not be modified", "entrepreneur@mail.fr"));
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getLast();
assertEquals("contenu très intéressant", s.getContentSectionCell());
assertEquals(
1, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
}
@Test
@ -132,7 +133,7 @@ public class EntrepreneurApiServiceTest {
"should not be modified",
"testentrepreneur@mail.fr"));
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 3L)).getFirst();
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getFirst();
assertEquals("contenu très intéressant", s.getContentSectionCell());
}
@ -148,7 +149,10 @@ public class EntrepreneurApiServiceTest {
entrepreneurApiService.removeSectionCell(
tmpCell.getIdSectionCell(), "entrepreneur@mail.fr");
assertEquals(
1, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
tmpCell.getIdReference(),
IterableToList(sectionCellService.getSectionCellsByProject(project, -1L))
.getLast()
.getIdReference());
}
@Test
@ -156,5 +160,52 @@ public class EntrepreneurApiServiceTest {
assertThrows(
ResponseStatusException.class,
() -> entrepreneurApiService.removeSectionCell(-1L, "entrepreneur@mail.fr"));
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getFirst();
assertEquals("contenu très intéressant", s.getContentSectionCell());
}
@Test
void addValidSectionCell() {
SectionCell added =
sectionCellService.addNewSectionCell(
new SectionCell(null, 2L, "contenu ajouté", LocalDateTime.now(), project));
entrepreneurApiService.addSectionCell(added, "entrepreneur@mail.fr");
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getLast();
assertEquals("contenu ajouté", s.getContentSectionCell());
assertEquals(
2, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
}
@Test
void addSectionCellInvalidAccess() {
System.out.println(
"content : "
+ IterableToList(sectionCellService.getSectionCellsByProject(project, 2L))
.getLast()
.getContentSectionCell());
SectionCell added =
sectionCellService.addNewSectionCell(
new SectionCell(null, 2L, "contenu ajouté", LocalDateTime.now(), project));
assertThrows(
ResponseStatusException.class,
() -> entrepreneurApiService.addSectionCell(added, "fauxentrepreneur@mail.fr"));
SectionCell s =
IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).getLast();
assertEquals(
1, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
assertEquals("contenu très intéressant", s.getContentSectionCell());
}
@Test
void addInvalidSectionCell() {
SectionCell added =
sectionCellService.addNewSectionCell(
new SectionCell(null, -1L, "contenu ajouté", LocalDateTime.now(), project));
assertThrows(
ResponseStatusException.class,
() -> entrepreneurApiService.addSectionCell(added, "entrepreneur@mail.fr"));
}
}