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

@ -17,6 +17,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDateTime;
@Service
public class EntrepreneurApiService {
@ -64,7 +66,28 @@ public class EntrepreneurApiService {
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
sectionCellService.updateSectionCell(sectionCellId, content, null, null, null);
SectionCell newSectionCell =
new SectionCell(
null,
sectionCell.getSectionId(),
content,
LocalDateTime.now(),
sectionCell.getProjectSectionCell());
newSectionCell.setIdReference(sectionCell.getIdReference());
sectionCell
.getAppointmentSectionCell()
.forEach(
appointment -> {
newSectionCell.updateAppointmentSectionCell(appointment);
});
sectionCell
.getListAnnotation()
.forEach(
annotation -> {
newSectionCell.updateListAnnotation(annotation);
});
this.addSectionCell(newSectionCell, mail);
// sectionCellService.updateSectionCell(sectionCellId, content, null, null, null);
}
public void removeSectionCell(Long sectionCellId, String mail) {
@ -89,7 +112,12 @@ public class EntrepreneurApiService {
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
sectionCellService.removeSectionCellById(sectionCellId);
SectionCell removedSectionCell = new SectionCell(null, -1L, "", LocalDateTime.now(), null);
removedSectionCell.setIdReference(editSectionCell.getIdReference());
sectionCellService.addNewSectionCell(removedSectionCell);
projectService.updateProjectListSectionCell(
sectionCellService.getProjectId(sectionCellId), removedSectionCell);
// sectionCellService.removeSectionCellById(sectionCellId);
}
public void addSectionCell(SectionCell sectionCell, String mail) {
@ -98,6 +126,11 @@ public class EntrepreneurApiService {
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "La cellule de section fournie est vide");
}
if (sectionCell.getSectionId() == -1) {
System.err.println("Trying to create an illegal section cell");
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "La cellule de section fournie n'est pas valide");
}
if (!utilsService.isAllowedToCheckProject(
mail, this.sectionCellService.getProjectId(sectionCell.getIdSectionCell()))) {
logger.warn(
@ -112,7 +145,9 @@ public class EntrepreneurApiService {
mail,
sectionCell.getIdSectionCell(),
this.sectionCellService.getProjectId(sectionCell.getIdSectionCell()));
SectionCell newSectionCell = sectionCellService.addNewSectionCell(sectionCell);
SectionCell newSectionCell =
sectionCellService.addNewSectionCell(
sectionCell); // if here, logger fails cause id is null (not added yet)
newSectionCell.getProjectSectionCell().updateListSectionCell(newSectionCell);
newSectionCell
.getAppointmentSectionCell()
@ -135,7 +170,14 @@ public class EntrepreneurApiService {
}
logger.info("User {} created a new project with id {}", mail, project.getIdProject());
project.setProjectStatus(PENDING);
project.setEntrepreneurProposed((Entrepreneur) this.userService.getUserByEmail(mail));
projectService.addNewProject(project);
project.getProjectAdministrator().updateListProject(project);
project.getEntrepreneurProposed().setProjectProposed(project);
project.getListEntrepreneurParticipation()
.forEach(entrepreneur -> entrepreneur.setProjectParticipation(project));
project.getListSectionCell()
.forEach(sectionCell -> sectionCell.setProjectSectionCell(project));
}
public void createAccount(Entrepreneur e) {