feat: started test for EntrepreneurServiceApi
Some checks failed
Format / formatting (push) Successful in 5s
Build / build (push) Failing after 37s
CI / build (push) Successful in 11s

This commit is contained in:
Théo Le Lez
2025-04-02 10:25:50 +02:00
parent 137bc84c21
commit 5b6b647697
7 changed files with 183 additions and 24 deletions

View File

@ -33,9 +33,9 @@ public class EntrepreneurApiService {
this.utilsService = utilsService;
}
public void editSectionCell(Long sectionCellId, SectionCell sectionCell, String mail) {
SectionCell editSectionCell = sectionCellService.getSectionCellById(sectionCellId);
if (editSectionCell == null) {
public void editSectionCell(Long sectionCellId, String content, String mail) {
SectionCell sectionCell = sectionCellService.getSectionCellById(sectionCellId);
if (sectionCell == null) {
System.err.println("Trying to edit unknown section cell");
throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
@ -55,11 +55,7 @@ public class EntrepreneurApiService {
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
sectionCellService.updateSectionCell(
sectionCellId,
sectionCell.getSectionId(),
sectionCell.getContentSectionCell(),
sectionCell.getModificationDate());
sectionCellService.updateSectionCell(sectionCellId, content);
}
public void removeSectionCell(Long sectionCellId, String mail) {

View File

@ -50,22 +50,16 @@ public class SectionCellService {
this.sectionCellRepository.deleteById(id);
}
public SectionCell updateSectionCell(
Long id, Long sectionId, String contentSectionCell, LocalDateTime modificationDate) {
public SectionCell updateSectionCell(Long id, String contentSectionCell) {
Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id);
if (sectionCell.isEmpty()) {
logger.error("updateSectionCell : No sectionCell found with id {}", id);
throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
}
if (sectionId != null) {
sectionCell.get().setSectionId(sectionId);
}
if (contentSectionCell != null) {
sectionCell.get().setContentSectionCell(contentSectionCell);
}
if (modificationDate != null) {
sectionCell.get().setModificationDate(modificationDate);
sectionCell.get().setModificationDate(LocalDateTime.now());
}
return this.sectionCellRepository.save(sectionCell.get());
}