fix: added null check in sharedService and updated test
Some checks failed
Format / formatting (push) Failing after 5s
Build / build (push) Failing after 39s
CI / build (push) Successful in 11s

This commit is contained in:
2025-04-23 11:47:41 +02:00
parent 6861d07dfc
commit 8ee06b93a6
2 changed files with 169 additions and 112 deletions

View File

@ -2,7 +2,8 @@ package enseirb.myinpulse.service;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
import enseirb.myinpulse.controller.AdminApi;
import enseirb.myinpulse.controller.EntrepreneurApi;
import enseirb.myinpulse.model.*;
import enseirb.myinpulse.service.database.*;
@ -30,6 +31,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
@Service
public class SharedApiService {
private final AdminApi adminApi;
private final EntrepreneurApi entrepreneurApi;
protected static final Logger logger = LogManager.getLogger();
private final ProjectService projectService;
@ -45,12 +50,14 @@ public class SharedApiService {
EntrepreneurService entrepreneurService,
SectionCellService sectionCellService,
AppointmentService appointmentService,
UtilsService utilsService) {
UtilsService utilsService, EntrepreneurApi entrepreneurApi, AdminApi adminApi) {
this.projectService = projectService;
this.entrepreneurService = entrepreneurService;
this.sectionCellService = sectionCellService;
this.appointmentService = appointmentService;
this.utilsService = utilsService;
this.entrepreneurApi = entrepreneurApi;
this.adminApi = adminApi;
}
// TODO filter this with date
@ -287,6 +294,13 @@ public class SharedApiService {
sectionCell -> {
sectionCell.updateAppointmentSectionCell(newAppointment);
});
newAppointment.getAppointmentReport().setAppointmentReport(newAppointment);
/*
* On initial insertion, the resport value is null unless that report does already exist in the db somewhere
* If a non null value is passed and it does not exist in db it will throw an exception
*/
if (newAppointment.getAppointmentReport() != null) {
newAppointment.getAppointmentReport().setAppointmentReport(newAppointment);
}
}
}