fix: fixed formatting to be compatible with workflow
Some checks failed
Format / formatting (push) Failing after 6s
Build / build (push) Successful in 41s
CI / build (push) Successful in 11s

This commit is contained in:
MAILLAL Anas 2025-04-22 09:46:07 +02:00
parent 5615b0fb11
commit 5edcf9ffc8

View File

@ -43,7 +43,6 @@ class TestUtils {
} }
} }
@SpringBootTest @SpringBootTest
@Transactional // Each @Test method runs in a transaction that is rolled back @Transactional // Each @Test method runs in a transaction that is rolled back
public class SharedApiServiceTest { public class SharedApiServiceTest {
@ -68,7 +67,6 @@ public class SharedApiServiceTest {
private static Project staticUnauthorizedProject; private static Project staticUnauthorizedProject;
private static String staticUnauthorizedMail; private static String staticUnauthorizedMail;
// --- Static Setup (Runs once before all tests) --- // --- Static Setup (Runs once before all tests) ---
// Use @BeforeAll static method with injected services // Use @BeforeAll static method with injected services
@BeforeAll @BeforeAll
@ -78,54 +76,90 @@ public class SharedApiServiceTest {
@Autowired EntrepreneurService entrepreneurService) { @Autowired EntrepreneurService entrepreneurService) {
// Create and Save core test data here using injected services // Create and Save core test data here using injected services
staticAuthorizedAdmin = administratorService.addAdministrator(getTestAdmin("static_authorized_admin")); staticAuthorizedAdmin =
administratorService.addAdministrator(getTestAdmin("static_authorized_admin"));
staticAuthorizedMail = staticAuthorizedAdmin.getPrimaryMail(); staticAuthorizedMail = staticAuthorizedAdmin.getPrimaryMail();
staticUnauthorizedProject = projectService.addNewProject(getTestProject("static_unauthorized_project", administratorService.addAdministrator(getTestAdmin("static_unauthorized_admin")))); staticUnauthorizedProject =
staticUnauthorizedMail = administratorService.addAdministrator(getTestAdmin("static_unauthorized_user")).getPrimaryMail(); // User who is NOT admin of the unauthorized project projectService.addNewProject(
getTestProject(
"static_unauthorized_project",
administratorService.addAdministrator(
getTestAdmin("static_unauthorized_admin"))));
staticUnauthorizedMail =
administratorService
.addAdministrator(getTestAdmin("static_unauthorized_user"))
.getPrimaryMail(); // User who is NOT admin of the unauthorized project
staticAuthorizedProject = projectService.addNewProject(getTestProject("static_authorized_project", staticAuthorizedAdmin)); staticAuthorizedProject =
projectService.addNewProject(
getTestProject("static_authorized_project", staticAuthorizedAdmin));
// Link a static entrepreneur to the authorized project if needed for some tests // Link a static entrepreneur to the authorized project if needed for some tests
// Entrepreneur staticLinkedEntrepreneur = entrepreneurService.addEntrepreneur(getTestEntrepreneur("static_linked_entrepreneur")); // Entrepreneur staticLinkedEntrepreneur =
// entrepreneurService.addEntrepreneur(getTestEntrepreneur("static_linked_entrepreneur"));
// staticAuthorizedProject.updateListEntrepreneurParticipation(staticLinkedEntrepreneur); // staticAuthorizedProject.updateListEntrepreneurParticipation(staticLinkedEntrepreneur);
// projectService.addNewProject(staticAuthorizedProject); // Re-save the project after updating lists // projectService.addNewProject(staticAuthorizedProject); // Re-save the project after
// updating lists
} }
// --- Per-Test Setup (Runs before each test method) --- // --- Per-Test Setup (Runs before each test method) ---
@BeforeEach @BeforeEach
void setupForEach() { void setupForEach() {
// Reset mock expectations before each test // Reset mock expectations before each test
MockitoAnnotations.openMocks(this); // Needed for mocks if not using @ExtendWith(MockitoExtension.class) MockitoAnnotations.openMocks(
this); // Needed for mocks if not using @ExtendWith(MockitoExtension.class)
// --- Configure the mock UtilsService based on the actual authorization rules --- // --- Configure the mock UtilsService based on the actual authorization rules ---
// Rule: Any admin can check any project. // Rule: Any admin can check any project.
// Assuming staticAuthorizedMail is an admin: // Assuming staticAuthorizedMail is an admin:
when(mockUtilsService.isAllowedToCheckProject(eq(staticAuthorizedMail), anyLong())).thenReturn(true); // Admin allowed for ANY project ID when(mockUtilsService.isAllowedToCheckProject(eq(staticAuthorizedMail), anyLong()))
.thenReturn(true); // Admin allowed for ANY project ID
// Rule: An entrepreneur can only check their own stuff. // Rule: An entrepreneur can only check their own stuff.
// Assuming staticUnauthorizedMail is an entrepreneur NOT linked to staticAuthorizedProject or staticUnauthorizedProject: // Assuming staticUnauthorizedMail is an entrepreneur NOT linked to staticAuthorizedProject
when(mockUtilsService.isAllowedToCheckProject(eq(staticUnauthorizedMail), anyLong())).thenReturn(false); // Unauthorized entrepreneur NOT allowed for ANY project ID by default // or staticUnauthorizedProject:
when(mockUtilsService.isAllowedToCheckProject(eq(staticUnauthorizedMail), anyLong()))
.thenReturn(
false); // Unauthorized entrepreneur NOT allowed for ANY project ID by
// default
// Add more specific mock setups here if needed for entrepreneur tests // Add more specific mock setups here if needed for entrepreneur tests
// E.g., If you have a test specifically for an entrepreneur accessing THEIR project: // E.g., If you have a test specifically for an entrepreneur accessing THEIR project:
// Entrepreneur testEntrepreneur = entrepreneurService.addEntrepreneur(getTestEntrepreneur("specific_linked_entrepreneur")); // Entrepreneur testEntrepreneur =
// Project linkedProject = projectService.addNewProject(getTestProject("specific_linked_project", staticAuthorizedAdmin)); // entrepreneurService.addEntrepreneur(getTestEntrepreneur("specific_linked_entrepreneur"));
// Project linkedProject =
// projectService.addNewProject(getTestProject("specific_linked_project",
// staticAuthorizedAdmin));
// // Link testEntrepreneur to linkedProject in the database setup... // // Link testEntrepreneur to linkedProject in the database setup...
// when(mockUtilsService.isAllowedToCheckProject(eq(testEntrepreneur.getPrimaryMail()), eq(linkedProject.getIdProject()))).thenReturn(true); // when(mockUtilsService.isAllowedToCheckProject(eq(testEntrepreneur.getPrimaryMail()),
// when(mockUtilsService.isAllowedToCheckProject(eq(testEntrepreneur.getPrimaryMail()), anyLong())).thenReturn(false); // Deny for other projects // eq(linkedProject.getIdProject()))).thenReturn(true);
// when(mockUtilsService.isAllowedToCheckProject(eq(testEntrepreneur.getPrimaryMail()),
// anyLong())).thenReturn(false); // Deny for other projects
} }
// --- Helper Methods (Can remain non-static or static as needed) --- // --- Helper Methods (Can remain non-static or static as needed) ---
private static Administrator getTestAdmin(String name) { private static Administrator getTestAdmin(String name) {
return new Administrator(name + "_surname", name, name + "@example.com", "secondary_" + name + "@example.com", "0123456789"); return new Administrator(
name + "_surname",
name,
name + "@example.com",
"secondary_" + name + "@example.com",
"0123456789");
} }
private static Entrepreneur getTestEntrepreneur(String name) { private static Entrepreneur getTestEntrepreneur(String name) {
return new Entrepreneur(name + "_surname", name, name + "@example.com", "secondary_" + name + "@example.com", "0123456789", "Test School", "Test Course", false); return new Entrepreneur(
name + "_surname",
name,
name + "@example.com",
"secondary_" + name + "@example.com",
"0123456789",
"Test School",
"Test Course",
false);
} }
private static Project getTestProject(String name, Administrator admin) { private static Project getTestProject(String name, Administrator admin) {
@ -133,7 +167,8 @@ public class SharedApiServiceTest {
return project; return project;
} }
private static SectionCell getTestSectionCell(Project project, Long sectionId, String content, LocalDateTime date) { private static SectionCell getTestSectionCell(
Project project, Long sectionId, String content, LocalDateTime date) {
SectionCell sectionCell = new SectionCell(); SectionCell sectionCell = new SectionCell();
sectionCell.setProjectSectionCell(project); sectionCell.setProjectSectionCell(project);
sectionCell.setSectionId(sectionId); sectionCell.setSectionId(sectionId);
@ -142,7 +177,14 @@ public class SharedApiServiceTest {
return sectionCell; return sectionCell;
} }
private static Appointment getTestAppointment(LocalDate date, LocalTime time, LocalTime duration, String place, String subject, List<SectionCell> sectionCells, Report report) { private static Appointment getTestAppointment(
LocalDate date,
LocalTime time,
LocalTime duration,
String place,
String subject,
List<SectionCell> sectionCells,
Report report) {
Appointment appointment = new Appointment(); Appointment appointment = new Appointment();
appointment.setAppointmentDate(date); appointment.setAppointmentDate(date);
appointment.setAppointmentTime(time); appointment.setAppointmentTime(time);
@ -150,11 +192,11 @@ public class SharedApiServiceTest {
appointment.setAppointmentPlace(place); appointment.setAppointmentPlace(place);
appointment.setAppointmentSubject(subject); appointment.setAppointmentSubject(subject);
if(sectionCells != null) { if (sectionCells != null) {
sectionCells.forEach(appointment::updateListSectionCell); sectionCells.forEach(appointment::updateListSectionCell);
} }
if(report != null) { if (report != null) {
appointment.setAppointmentReport(report); appointment.setAppointmentReport(report);
report.setAppointmentReport(appointment); report.setAppointmentReport(appointment);
} }
@ -168,8 +210,6 @@ public class SharedApiServiceTest {
return report; return report;
} }
/* /*
* Tests retrieving section cells for a specific project and section ID before a given date * Tests retrieving section cells for a specific project and section ID before a given date
* when the user is authorized but no matching cells exist. * when the user is authorized but no matching cells exist.
@ -182,7 +222,8 @@ public class SharedApiServiceTest {
LocalDateTime dateFilter = LocalDateTime.now().plusDays(1); LocalDateTime dateFilter = LocalDateTime.now().plusDays(1);
// Act // Act
Iterable<SectionCell> result = sharedApiService.getSectionCells( Iterable<SectionCell> result =
sharedApiService.getSectionCells(
staticAuthorizedProject.getIdProject(), staticAuthorizedProject.getIdProject(),
targetSectionId, targetSectionId,
dateFilter.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), dateFilter.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")),
@ -202,19 +243,25 @@ public class SharedApiServiceTest {
void testGetSectionCells_Unauthorized() { void testGetSectionCells_Unauthorized() {
// Arrange: mockUtilsService configured in BeforeEach // Arrange: mockUtilsService configured in BeforeEach
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getSectionCells( sharedApiService.getSectionCells(
staticAuthorizedProject.getIdProject(), // Project static user is not authorized for staticAuthorizedProject
.getIdProject(), // Project static user is not
// authorized for
1L, 1L,
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), LocalDateTime.now()
.format(
DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm")),
staticUnauthorizedMail); // Static unauthorized user mail staticUnauthorizedMail); // Static unauthorized user mail
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
} }
/* /*
* Tests retrieving all section cells for a project when the user is authorized * Tests retrieving all section cells for a project when the user is authorized
* but the project has no section cells. * but the project has no section cells.
@ -224,9 +271,9 @@ public class SharedApiServiceTest {
void testGetAllSectionCells_Authorized_NoCells() { void testGetAllSectionCells_Authorized_NoCells() {
// Arrange: staticAuthorizedProject has no section cells initially in BeforeAll // Arrange: staticAuthorizedProject has no section cells initially in BeforeAll
// Act // Act
Iterable<SectionCell> result = sharedApiService.getAllSectionCells( Iterable<SectionCell> result =
staticAuthorizedProject.getIdProject(), sharedApiService.getAllSectionCells(
staticAuthorizedMail); staticAuthorizedProject.getIdProject(), staticAuthorizedMail);
List<SectionCell> resultList = TestUtils.toList(result); List<SectionCell> resultList = TestUtils.toList(result);
@ -242,18 +289,17 @@ public class SharedApiServiceTest {
void testGetAllSectionCells_Unauthorized() { void testGetAllSectionCells_Unauthorized() {
// Arrange: mockUtilsService configured in BeforeEach // Arrange: mockUtilsService configured in BeforeEach
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getAllSectionCells( sharedApiService.getAllSectionCells(
staticAuthorizedProject.getIdProject(), staticAuthorizedProject.getIdProject(), staticUnauthorizedMail);
staticUnauthorizedMail);
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
} }
/* /*
* Tests retrieving entrepreneurs linked to a project when the user is authorized * Tests retrieving entrepreneurs linked to a project when the user is authorized
* but no entrepreneurs are linked. * but no entrepreneurs are linked.
@ -263,9 +309,9 @@ public class SharedApiServiceTest {
void testGetEntrepreneursByProjectId_Authorized_NotFound() { void testGetEntrepreneursByProjectId_Authorized_NotFound() {
// Arrange: staticAuthorizedProject has no entrepreneurs linked initially in BeforeAll // Arrange: staticAuthorizedProject has no entrepreneurs linked initially in BeforeAll
// Act // Act
Iterable<Entrepreneur> result = sharedApiService.getEntrepreneursByProjectId( Iterable<Entrepreneur> result =
staticAuthorizedProject.getIdProject(), sharedApiService.getEntrepreneursByProjectId(
staticAuthorizedMail); staticAuthorizedProject.getIdProject(), staticAuthorizedMail);
List<Entrepreneur> resultList = TestUtils.toList(result); List<Entrepreneur> resultList = TestUtils.toList(result);
@ -281,10 +327,12 @@ public class SharedApiServiceTest {
void testGetEntrepreneursByProjectId_Unauthorized() { void testGetEntrepreneursByProjectId_Unauthorized() {
// Arrange: mockUtilsService configured in BeforeEach // Arrange: mockUtilsService configured in BeforeEach
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getEntrepreneursByProjectId( sharedApiService.getEntrepreneursByProjectId(
staticAuthorizedProject.getIdProject(), staticAuthorizedProject.getIdProject(), staticUnauthorizedMail);
staticUnauthorizedMail);
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
@ -300,9 +348,9 @@ public class SharedApiServiceTest {
void testGetAdminByProjectId_Authorized_Found() { void testGetAdminByProjectId_Authorized_Found() {
// Arrange: staticAuthorizedProject is created with staticAuthorizedAdmin in BeforeAll // Arrange: staticAuthorizedProject is created with staticAuthorizedAdmin in BeforeAll
// Act // Act
Administrator result = sharedApiService.getAdminByProjectId( Administrator result =
staticAuthorizedProject.getIdProject(), sharedApiService.getAdminByProjectId(
staticAuthorizedMail); staticAuthorizedProject.getIdProject(), staticAuthorizedMail);
// Assert // Assert
assertNotNull(result); assertNotNull(result);
@ -317,18 +365,17 @@ public class SharedApiServiceTest {
void testGetAdminByProjectId_Unauthorized() { void testGetAdminByProjectId_Unauthorized() {
// Arrange: mockUtilsService configured in BeforeEach // Arrange: mockUtilsService configured in BeforeEach
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getAdminByProjectId( sharedApiService.getAdminByProjectId(
staticAuthorizedProject.getIdProject(), staticAuthorizedProject.getIdProject(), staticUnauthorizedMail);
staticUnauthorizedMail);
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
} }
/* /*
* Tests retrieving appointments linked to a project's section cells when the user is authorized * Tests retrieving appointments linked to a project's section cells when the user is authorized
* but no such appointments exist. * but no such appointments exist.
@ -338,9 +385,9 @@ public class SharedApiServiceTest {
void testGetAppointmentsByProjectId_Authorized_NotFound() { void testGetAppointmentsByProjectId_Authorized_NotFound() {
// Arrange: staticAuthorizedProject has no linked section cells or appointments initially // Arrange: staticAuthorizedProject has no linked section cells or appointments initially
// Act // Act
Iterable<Appointment> result = sharedApiService.getAppointmentsByProjectId( Iterable<Appointment> result =
staticAuthorizedProject.getIdProject(), sharedApiService.getAppointmentsByProjectId(
staticAuthorizedMail); staticAuthorizedProject.getIdProject(), staticAuthorizedMail);
List<Appointment> resultList = TestUtils.toList(result); List<Appointment> resultList = TestUtils.toList(result);
@ -356,10 +403,12 @@ public class SharedApiServiceTest {
void testGetAppointmentsByProjectId_Unauthorized() { void testGetAppointmentsByProjectId_Unauthorized() {
// Arrange: mockUtilsService configured in BeforeEach // Arrange: mockUtilsService configured in BeforeEach
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getAppointmentsByProjectId( sharedApiService.getAppointmentsByProjectId(
staticAuthorizedProject.getIdProject(), staticAuthorizedProject.getIdProject(), staticUnauthorizedMail);
staticUnauthorizedMail);
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
@ -372,7 +421,8 @@ public class SharedApiServiceTest {
*/ */
@Test @Test
void testCreateAppointmentRequest_Unauthorized() { void testCreateAppointmentRequest_Unauthorized() {
// Arrange: Create transient appointment linked to a cell in the static *unauthorized* project // Arrange: Create transient appointment linked to a cell in the static *unauthorized*
// project
LocalDate date = LocalDate.parse("2026-01-01"); LocalDate date = LocalDate.parse("2026-01-01");
LocalTime time = LocalTime.parse("10:00:00"); LocalTime time = LocalTime.parse("10:00:00");
LocalTime duration = LocalTime.parse("00:30:00"); LocalTime duration = LocalTime.parse("00:30:00");
@ -380,23 +430,35 @@ public class SharedApiServiceTest {
String subject = "Discuss Project"; String subject = "Discuss Project";
String reportContent = "Initial Report"; String reportContent = "Initial Report";
SectionCell linkedCell = sectionCellService.addNewSectionCell(getTestSectionCell(staticUnauthorizedProject, 1L, "Related Section Content", LocalDateTime.now())); SectionCell linkedCell =
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticUnauthorizedProject,
1L,
"Related Section Content",
LocalDateTime.now()));
Report newReport = getTestReport(reportContent); Report newReport = getTestReport(reportContent);
Appointment newAppointment = getTestAppointment(date, time, duration, place, subject, List.of(linkedCell), newReport); Appointment newAppointment =
getTestAppointment(
date, time, duration, place, subject, List.of(linkedCell), newReport);
// mockUtilsService is configured in BeforeEach to deny staticUnauthorizedMail for staticUnauthorizedProject // mockUtilsService is configured in BeforeEach to deny staticUnauthorizedMail for
// staticUnauthorizedProject
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
sharedApiService.createAppointmentRequest(newAppointment, staticUnauthorizedMail); // Unauthorized user mail assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.createAppointmentRequest(
newAppointment,
staticUnauthorizedMail); // Unauthorized user mail
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
} }
/* /*
_____ _ _ _ _____ _ _ _
@ -412,7 +474,6 @@ public class SharedApiServiceTest {
*/ */
/* these tests fail because of the use of mockito's eq(), /* these tests fail because of the use of mockito's eq(),
* and since thee instances are technically not the same as * and since thee instances are technically not the same as
* as the classes used to turn them into persistant data * as the classes used to turn them into persistant data
@ -427,21 +488,41 @@ public class SharedApiServiceTest {
* Verifies that no authorization exception is thrown. (Note: File I/O is mocked). * Verifies that no authorization exception is thrown. (Note: File I/O is mocked).
*/ */
// Tests getPDFReport (Focus on authorization and data retrieval flow) // Tests getPDFReport (Focus on authorization and data retrieval flow)
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetPDFReport_Authorized() throws DocumentException, URISyntaxException, IOException { void testGetPDFReport_Authorized() throws DocumentException, URISyntaxException, IOException {
// Arrange: Create a specific appointment linked to the static authorized project // Arrange: Create a specific appointment linked to the static authorized project
SectionCell cell = sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, 1L, "Cell for PDF Test", LocalDateTime.now())); SectionCell cell =
Report report = new Report(null, "PDF Report Content // Point 2 PDF Content"); // ID set by DB sectionCellService.addNewSectionCell(
Appointment appointment = getTestAppointment(LocalDate.now().plusDays(20), LocalTime.of(14,0), LocalTime.of(0, 45), "Salle PDF", "PDF Subject", List.of(cell), report); getTestSectionCell(
staticAuthorizedProject,
1L,
"Cell for PDF Test",
LocalDateTime.now()));
Report report =
new Report(null, "PDF Report Content // Point 2 PDF Content"); // ID set by DB
Appointment appointment =
getTestAppointment(
LocalDate.now().plusDays(20),
LocalTime.of(14, 0),
LocalTime.of(0, 45),
"Salle PDF",
"PDF Subject",
List.of(cell),
report);
Appointment savedAppointment = appointmentService.addNewAppointment(appointment); Appointment savedAppointment = appointmentService.addNewAppointment(appointment);
// Mock getAppointmentById to return the saved appointment for the service to use // Mock getAppointmentById to return the saved appointment for the service to use
when(appointmentService.getAppointmentById(eq(savedAppointment.getIdAppointment()))).thenReturn(savedAppointment); when(appointmentService.getAppointmentById(eq(savedAppointment.getIdAppointment())))
// mockUtilsService is configured in BeforeEach to allow staticAuthorizedMail for staticAuthorizedProject .thenReturn(savedAppointment);
// mockUtilsService is configured in BeforeEach to allow staticAuthorizedMail for
// staticAuthorizedProject
// Act & Assert (Just assert no authorization exception is thrown) // Act & Assert (Just assert no authorization exception is thrown)
assertDoesNotThrow(() -> sharedApiService.getPDFReport(savedAppointment.getIdAppointment(), staticAuthorizedMail)); assertDoesNotThrow(
() ->
sharedApiService.getPDFReport(
savedAppointment.getIdAppointment(), staticAuthorizedMail));
// Note: Actual PDF generation and file operations are not tested here, // Note: Actual PDF generation and file operations are not tested here,
// as that requires mocking external libraries and file system operations. // as that requires mocking external libraries and file system operations.
@ -452,21 +533,43 @@ public class SharedApiServiceTest {
* for the project linked to the appointment's section cell. * for the project linked to the appointment's section cell.
* Verifies that an Unauthorized ResponseStatusException is thrown. * Verifies that an Unauthorized ResponseStatusException is thrown.
*/ */
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetPDFReport_Unauthorized() { void testGetPDFReport_Unauthorized() {
// Arrange: Create a specific appointment linked to the static *unauthorized* project // Arrange: Create a specific appointment linked to the static *unauthorized* project
SectionCell cell = sectionCellService.addNewSectionCell(getTestSectionCell(staticUnauthorizedProject, 1L, "Cell for Unauthorized PDF Test", LocalDateTime.now())); SectionCell cell =
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticUnauthorizedProject,
1L,
"Cell for Unauthorized PDF Test",
LocalDateTime.now()));
Report report = new Report(null, "Unauthorized PDF Report Content"); Report report = new Report(null, "Unauthorized PDF Report Content");
Appointment appointment = getTestAppointment(LocalDate.now().plusDays(21), LocalTime.of(15,0), LocalTime.of(0, 30), "Salle Unauthorized PDF", "Unauthorized PDF Subject", List.of(cell), report); Appointment appointment =
getTestAppointment(
LocalDate.now().plusDays(21),
LocalTime.of(15, 0),
LocalTime.of(0, 30),
"Salle Unauthorized PDF",
"Unauthorized PDF Subject",
List.of(cell),
report);
Appointment savedAppointment = appointmentService.addNewAppointment(appointment); Appointment savedAppointment = appointmentService.addNewAppointment(appointment);
// Mock getAppointmentById to return the saved appointment // Mock getAppointmentById to return the saved appointment
when(appointmentService.getAppointmentById(eq(savedAppointment.getIdAppointment()))).thenReturn(savedAppointment); when(appointmentService.getAppointmentById(eq(savedAppointment.getIdAppointment())))
// mockUtilsService is configured in BeforeEach to DENY staticUnauthorizedMail for staticUnauthorizedProject .thenReturn(savedAppointment);
// mockUtilsService is configured in BeforeEach to DENY staticUnauthorizedMail for
// staticUnauthorizedProject
// Act & Assert // Act & Assert
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { ResponseStatusException exception =
sharedApiService.getPDFReport(savedAppointment.getIdAppointment(), staticUnauthorizedMail); // Unauthorized user mail assertThrows(
ResponseStatusException.class,
() -> {
sharedApiService.getPDFReport(
savedAppointment.getIdAppointment(),
staticUnauthorizedMail); // Unauthorized user mail
}); });
assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, exception.getStatusCode());
@ -478,7 +581,8 @@ public class SharedApiServiceTest {
* Verifies that the appointment and its relationships are saved correctly in the database. * Verifies that the appointment and its relationships are saved correctly in the database.
*/ */
// Tests createAppointmentRequest // Tests createAppointmentRequest
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testCreateAppointmentRequest_Authorized_Success() { void testCreateAppointmentRequest_Authorized_Success() {
// Arrange: Create transient appointment linked to a cell in the static authorized project // Arrange: Create transient appointment linked to a cell in the static authorized project
LocalDate date = LocalDate.parse("2026-01-01"); LocalDate date = LocalDate.parse("2026-01-01");
@ -488,28 +592,52 @@ public class SharedApiServiceTest {
String subject = "Discuss Project Integrated"; String subject = "Discuss Project Integrated";
String reportContent = "Initial Report Integrated"; String reportContent = "Initial Report Integrated";
SectionCell linkedCell = sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, 1L, "Related Section Content Integrated", LocalDateTime.now())); SectionCell linkedCell =
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticAuthorizedProject,
1L,
"Related Section Content Integrated",
LocalDateTime.now()));
Report newReport = getTestReport(reportContent); // Uses no-arg constructor Report newReport = getTestReport(reportContent); // Uses no-arg constructor
Appointment newAppointment = getTestAppointment(date, time, duration, place, subject, List.of(linkedCell), newReport); Appointment newAppointment =
getTestAppointment(
date, time, duration, place, subject, List.of(linkedCell), newReport);
// mockUtilsService is configured in BeforeEach to allow staticAuthorizedMail for staticAuthorizedProject // mockUtilsService is configured in BeforeEach to allow staticAuthorizedMail for
// staticAuthorizedProject
// Act // Act
// Allow the service method to call the actual appointmentService.addNewAppointment // Allow the service method to call the actual appointmentService.addNewAppointment
assertDoesNotThrow(() -> sharedApiService.createAppointmentRequest(newAppointment, staticAuthorizedMail)); assertDoesNotThrow(
() ->
sharedApiService.createAppointmentRequest(
newAppointment, staticAuthorizedMail));
// Assert: Retrieve the appointment from the DB and verify it and its relationships were saved // Assert: Retrieve the appointment from the DB and verify it and its relationships were
// saved
// We find it by looking for appointments linked to the authorized project's cells // We find it by looking for appointments linked to the authorized project's cells
Iterable<SectionCell> projectCells = sectionCellService.getSectionCellsByProject(staticAuthorizedProject, 1L); // Fetch relevant cells Iterable<SectionCell> projectCells =
sectionCellService.getSectionCellsByProject(
staticAuthorizedProject, 1L); // Fetch relevant cells
List<Appointment> projectAppointmentsList = new ArrayList<>(); List<Appointment> projectAppointmentsList = new ArrayList<>();
projectCells.forEach(cell -> projectAppointmentsList.addAll(sectionCellService.getAppointmentsBySectionCellId(cell.getIdSectionCell()))); // Get appointments for those cells projectCells.forEach(
cell ->
projectAppointmentsList.addAll(
sectionCellService.getAppointmentsBySectionCellId(
cell
.getIdSectionCell()))); // Get appointments for
// those cells
Optional<Appointment> createdAppointmentOpt = projectAppointmentsList.stream() Optional<Appointment> createdAppointmentOpt =
.filter(a -> a.getAppointmentDate().equals(date) && projectAppointmentsList.stream()
a.getAppointmentTime().equals(time) && .filter(
a.getAppointmentPlace().equals(place) && a ->
a.getAppointmentSubject().equals(subject)) a.getAppointmentDate().equals(date)
&& a.getAppointmentTime().equals(time)
&& a.getAppointmentPlace().equals(place)
&& a.getAppointmentSubject().equals(subject))
.findFirst(); .findFirst();
assertTrue(createdAppointmentOpt.isPresent()); assertTrue(createdAppointmentOpt.isPresent());
@ -518,16 +646,30 @@ public class SharedApiServiceTest {
assertNotNull(createdAppointment.getAppointmentReport()); assertNotNull(createdAppointment.getAppointmentReport());
assertEquals(reportContent, createdAppointment.getAppointmentReport().getReportContent()); assertEquals(reportContent, createdAppointment.getAppointmentReport().getReportContent());
// FIX: Corrected bidirectional link check // FIX: Corrected bidirectional link check
assertEquals(createdAppointment.getIdAppointment(), createdAppointment.getAppointmentReport().getAppointmentReport().getIdAppointment()); assertEquals(
createdAppointment.getIdAppointment(),
createdAppointment
.getAppointmentReport()
.getAppointmentReport()
.getIdAppointment());
assertEquals(1, createdAppointment.getAppointmentListSectionCell().size()); assertEquals(1, createdAppointment.getAppointmentListSectionCell().size());
assertTrue(createdAppointment.getAppointmentListSectionCell().stream().anyMatch(sc -> sc.getIdSectionCell().equals(linkedCell.getIdSectionCell()))); assertTrue(
createdAppointment.getAppointmentListSectionCell().stream()
.anyMatch(
sc -> sc.getIdSectionCell().equals(linkedCell.getIdSectionCell())));
List<Appointment> appointmentsLinkedToCell = TestUtils.toList(sectionCellService.getAppointmentsBySectionCellId(linkedCell.getIdSectionCell())); List<Appointment> appointmentsLinkedToCell =
assertTrue(appointmentsLinkedToCell.stream().anyMatch(a -> a.getIdAppointment().equals(createdAppointment.getIdAppointment()))); TestUtils.toList(
sectionCellService.getAppointmentsBySectionCellId(
linkedCell.getIdSectionCell()));
assertTrue(
appointmentsLinkedToCell.stream()
.anyMatch(
a ->
a.getIdAppointment()
.equals(createdAppointment.getIdAppointment())));
} }
// --- Test Methods (Use static data from @BeforeAll where possible) --- // --- Test Methods (Use static data from @BeforeAll where possible) ---
/* /*
@ -535,19 +677,39 @@ public class SharedApiServiceTest {
* when the user is authorized and matching cells exist. * when the user is authorized and matching cells exist.
* Verifies that only the correct cells are returned. * Verifies that only the correct cells are returned.
*/ */
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetSectionCells_Authorized_Found() { void testGetSectionCells_Authorized_Found() {
// Arrange: Create specific SectionCells for this test scenario // Arrange: Create specific SectionCells for this test scenario
Long targetSectionId = 1L; Long targetSectionId = 1L;
LocalDateTime dateFilter = LocalDateTime.now().plusDays(1); LocalDateTime dateFilter = LocalDateTime.now().plusDays(1);
sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, targetSectionId, "Old Content", LocalDateTime.now().minusDays(2))); sectionCellService.addNewSectionCell(
SectionCell recentCell = sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, targetSectionId, "Recent Content", LocalDateTime.now().minusDays(1))); getTestSectionCell(
sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, 2L, "Other Section", LocalDateTime.now())); staticAuthorizedProject,
sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, targetSectionId, "Future Content", LocalDateTime.now().plusDays(2))); targetSectionId,
"Old Content",
LocalDateTime.now().minusDays(2)));
SectionCell recentCell =
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticAuthorizedProject,
targetSectionId,
"Recent Content",
LocalDateTime.now().minusDays(1)));
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticAuthorizedProject, 2L, "Other Section", LocalDateTime.now()));
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticAuthorizedProject,
targetSectionId,
"Future Content",
LocalDateTime.now().plusDays(2)));
// Act // Act
Iterable<SectionCell> result = sharedApiService.getSectionCells( Iterable<SectionCell> result =
sharedApiService.getSectionCells(
staticAuthorizedProject.getIdProject(), // Use static project ID staticAuthorizedProject.getIdProject(), // Use static project ID
targetSectionId, targetSectionId,
dateFilter.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), dateFilter.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")),
@ -566,36 +728,54 @@ public class SharedApiServiceTest {
* Verifies that only the latest version of each referenced cell is returned. * Verifies that only the latest version of each referenced cell is returned.
*/ */
// Tests getAllSectionCells // Tests getAllSectionCells
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetAllSectionCells_Authorized_FoundLatest() { void testGetAllSectionCells_Authorized_FoundLatest() {
// Arrange: Create specific SectionCells for this test // Arrange: Create specific SectionCells for this test
Long refId1 = 101L; Long refId1 = 101L;
Long refId2 = 102L; Long refId2 = 102L;
SectionCell tempOldCell1 = getTestSectionCell(staticAuthorizedProject, 1L, "Ref1 Old", LocalDateTime.now().minusDays(3)); SectionCell tempOldCell1 =
getTestSectionCell(
staticAuthorizedProject, 1L, "Ref1 Old", LocalDateTime.now().minusDays(3));
tempOldCell1.setIdReference(refId1); tempOldCell1.setIdReference(refId1);
final SectionCell oldCell1 = sectionCellService.addNewSectionCell(tempOldCell1); final SectionCell oldCell1 = sectionCellService.addNewSectionCell(tempOldCell1);
SectionCell tempNewerCell1 = getTestSectionCell(staticAuthorizedProject, 1L, "Ref1 Newer", LocalDateTime.now().minusDays(2)); SectionCell tempNewerCell1 =
getTestSectionCell(
staticAuthorizedProject,
1L,
"Ref1 Newer",
LocalDateTime.now().minusDays(2));
tempNewerCell1.setIdReference(refId1); tempNewerCell1.setIdReference(refId1);
final SectionCell newerCell1 = sectionCellService.addNewSectionCell(tempNewerCell1); final SectionCell newerCell1 = sectionCellService.addNewSectionCell(tempNewerCell1);
SectionCell tempOldCell2 = getTestSectionCell(staticAuthorizedProject, 2L, "Ref2 Old", LocalDateTime.now().minusDays(1)); SectionCell tempOldCell2 =
getTestSectionCell(
staticAuthorizedProject, 2L, "Ref2 Old", LocalDateTime.now().minusDays(1));
tempOldCell2.setIdReference(refId2); tempOldCell2.setIdReference(refId2);
final SectionCell oldCell2 = sectionCellService.addNewSectionCell(tempOldCell2); final SectionCell oldCell2 = sectionCellService.addNewSectionCell(tempOldCell2);
SectionCell tempNewerCell2 = getTestSectionCell(staticAuthorizedProject, 2L, "Ref2 Newer", LocalDateTime.now()); SectionCell tempNewerCell2 =
getTestSectionCell(staticAuthorizedProject, 2L, "Ref2 Newer", LocalDateTime.now());
tempNewerCell2.setIdReference(refId2); tempNewerCell2.setIdReference(refId2);
final SectionCell newerCell2 = sectionCellService.addNewSectionCell(tempNewerCell2); final SectionCell newerCell2 = sectionCellService.addNewSectionCell(tempNewerCell2);
Project otherProject = projectService.addNewProject(getTestProject("other_project_for_cell_test", administratorService.addAdministrator(getTestAdmin("other_admin_cell_test")))); Project otherProject =
SectionCell tempOtherProjectCell = getTestSectionCell(otherProject, 1L, "Other Project Cell", LocalDateTime.now()); projectService.addNewProject(
getTestProject(
"other_project_for_cell_test",
administratorService.addAdministrator(
getTestAdmin("other_admin_cell_test"))));
SectionCell tempOtherProjectCell =
getTestSectionCell(otherProject, 1L, "Other Project Cell", LocalDateTime.now());
tempOtherProjectCell.setIdReference(103L); tempOtherProjectCell.setIdReference(103L);
final SectionCell otherProjectCell = sectionCellService.addNewSectionCell(tempOtherProjectCell); final SectionCell otherProjectCell =
sectionCellService.addNewSectionCell(tempOtherProjectCell);
// Act // Act
Iterable<SectionCell> result = sharedApiService.getAllSectionCells( Iterable<SectionCell> result =
sharedApiService.getAllSectionCells(
staticAuthorizedProject.getIdProject(), // Use static project ID staticAuthorizedProject.getIdProject(), // Use static project ID
staticAuthorizedMail); // Use static authorized mail staticAuthorizedMail); // Use static authorized mail
@ -604,12 +784,37 @@ public class SharedApiServiceTest {
// Assert // Assert
assertEquals(2, resultList.size()); // Expect 2 cells (one per idReference) assertEquals(2, resultList.size()); // Expect 2 cells (one per idReference)
assertTrue(resultList.stream().anyMatch(cell -> cell.getIdSectionCell().equals(newerCell1.getIdSectionCell()))); assertTrue(
assertTrue(resultList.stream().anyMatch(cell -> cell.getIdSectionCell().equals(newerCell2.getIdSectionCell()))); resultList.stream()
.anyMatch(
cell ->
cell.getIdSectionCell()
.equals(newerCell1.getIdSectionCell())));
assertTrue(
resultList.stream()
.anyMatch(
cell ->
cell.getIdSectionCell()
.equals(newerCell2.getIdSectionCell())));
assertFalse(resultList.stream().anyMatch(cell -> cell.getIdSectionCell().equals(oldCell1.getIdSectionCell()))); assertFalse(
assertFalse(resultList.stream().anyMatch(cell -> cell.getIdSectionCell().equals(oldCell2.getIdSectionCell()))); resultList.stream()
assertFalse(resultList.stream().anyMatch(cell -> cell.getIdSectionCell().equals(otherProjectCell.getIdSectionCell()))); .anyMatch(
cell ->
cell.getIdSectionCell()
.equals(oldCell1.getIdSectionCell())));
assertFalse(
resultList.stream()
.anyMatch(
cell ->
cell.getIdSectionCell()
.equals(oldCell2.getIdSectionCell())));
assertFalse(
resultList.stream()
.anyMatch(
cell ->
cell.getIdSectionCell()
.equals(otherProjectCell.getIdSectionCell())));
} }
/* /*
@ -618,28 +823,37 @@ public class SharedApiServiceTest {
* Verifies that the correct entrepreneurs are returned. * Verifies that the correct entrepreneurs are returned.
*/ */
// Tests getEntrepreneursByProjectId // Tests getEntrepreneursByProjectId
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetEntrepreneursByProjectId_Authorized_Found() { void testGetEntrepreneursByProjectId_Authorized_Found() {
// Arrange: Create entrepreneur and link to static project for this test // Arrange: Create entrepreneur and link to static project for this test
Entrepreneur linkedEntrepreneur = entrepreneurService.addEntrepreneur(getTestEntrepreneur("linked_entrepreneur_test")); Entrepreneur linkedEntrepreneur =
entrepreneurService.addEntrepreneur(
getTestEntrepreneur("linked_entrepreneur_test"));
// Fetch the static project to update its list // Fetch the static project to update its list
Project projectToUpdate = projectService.getProjectById(staticAuthorizedProject.getIdProject()); Project projectToUpdate =
projectService.getProjectById(staticAuthorizedProject.getIdProject());
projectToUpdate.updateListEntrepreneurParticipation(linkedEntrepreneur); projectToUpdate.updateListEntrepreneurParticipation(linkedEntrepreneur);
projectService.addNewProject(projectToUpdate); // Save the updated project projectService.addNewProject(projectToUpdate); // Save the updated project
Entrepreneur otherEntrepreneur = entrepreneurService.addEntrepreneur(getTestEntrepreneur("other_entrepreneur_test")); Entrepreneur otherEntrepreneur =
entrepreneurService.addEntrepreneur(getTestEntrepreneur("other_entrepreneur_test"));
// Act // Act
Iterable<Entrepreneur> result = sharedApiService.getEntrepreneursByProjectId( Iterable<Entrepreneur> result =
staticAuthorizedProject.getIdProject(), sharedApiService.getEntrepreneursByProjectId(
staticAuthorizedMail); staticAuthorizedProject.getIdProject(), staticAuthorizedMail);
List<Entrepreneur> resultList = TestUtils.toList(result); List<Entrepreneur> resultList = TestUtils.toList(result);
// Assert // Assert
assertEquals(1, resultList.size()); assertEquals(1, resultList.size());
assertTrue(resultList.stream().anyMatch(e -> e.getIdUser().equals(linkedEntrepreneur.getIdUser()))); assertTrue(
assertFalse(resultList.stream().anyMatch(e -> e.getIdUser().equals(otherEntrepreneur.getIdUser()))); resultList.stream()
.anyMatch(e -> e.getIdUser().equals(linkedEntrepreneur.getIdUser())));
assertFalse(
resultList.stream()
.anyMatch(e -> e.getIdUser().equals(otherEntrepreneur.getIdUser())));
} }
/* /*
@ -648,26 +862,68 @@ public class SharedApiServiceTest {
* Verifies that the correct appointments are returned. * Verifies that the correct appointments are returned.
*/ */
// Tests getAppointmentsByProjectId // Tests getAppointmentsByProjectId
/*@Test*/ // Commenting out failing test /*@Test*/
// Commenting out failing test
void testGetAppointmentsByProjectId_Authorized_Found() { void testGetAppointmentsByProjectId_Authorized_Found() {
// Arrange: Create specific SectionCells and Appointments for this test // Arrange: Create specific SectionCells and Appointments for this test
SectionCell cell1 = sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, 1L, "Cell 1 Test", LocalDateTime.now())); SectionCell cell1 =
SectionCell cell2 = sectionCellService.addNewSectionCell(getTestSectionCell(staticAuthorizedProject, 2L, "Cell 2 Test", LocalDateTime.now())); sectionCellService.addNewSectionCell(
Project otherProject = projectService.addNewProject(getTestProject("other_project_app_test", administratorService.addAdministrator(getTestAdmin("other_admin_app_test")))); getTestSectionCell(
SectionCell otherProjectCell = sectionCellService.addNewSectionCell(getTestSectionCell(otherProject, 1L, "Other Project Cell App Test", LocalDateTime.now())); staticAuthorizedProject, 1L, "Cell 1 Test", LocalDateTime.now()));
SectionCell cell2 =
sectionCellService.addNewSectionCell(
getTestSectionCell(
staticAuthorizedProject, 2L, "Cell 2 Test", LocalDateTime.now()));
Project otherProject =
projectService.addNewProject(
getTestProject(
"other_project_app_test",
administratorService.addAdministrator(
getTestAdmin("other_admin_app_test"))));
SectionCell otherProjectCell =
sectionCellService.addNewSectionCell(
getTestSectionCell(
otherProject,
1L,
"Other Project Cell App Test",
LocalDateTime.now()));
Appointment app1 = getTestAppointment(LocalDate.now().plusDays(10), LocalTime.NOON, LocalTime.of(0, 30), "Place 1 App Test", "Subject 1 App Test", List.of(cell1), null); Appointment app1 =
getTestAppointment(
LocalDate.now().plusDays(10),
LocalTime.NOON,
LocalTime.of(0, 30),
"Place 1 App Test",
"Subject 1 App Test",
List.of(cell1),
null);
Appointment savedApp1 = appointmentService.addNewAppointment(app1); Appointment savedApp1 = appointmentService.addNewAppointment(app1);
Appointment app2 = getTestAppointment(LocalDate.now().plusDays(11), LocalTime.NOON.plusHours(1), LocalTime.of(1, 0), "Place 2 App Test", "Subject 2 App Test", List.of(cell1, cell2), null); Appointment app2 =
getTestAppointment(
LocalDate.now().plusDays(11),
LocalTime.NOON.plusHours(1),
LocalTime.of(1, 0),
"Place 2 App Test",
"Subject 2 App Test",
List.of(cell1, cell2),
null);
Appointment savedApp2 = appointmentService.addNewAppointment(app2); Appointment savedApp2 = appointmentService.addNewAppointment(app2);
Appointment otherApp = getTestAppointment(LocalDate.now().plusDays(12), LocalTime.MIDNIGHT, LocalTime.of(0, 15), "Other Place App Test", "Other Subject App Test", List.of(otherProjectCell), null); Appointment otherApp =
getTestAppointment(
LocalDate.now().plusDays(12),
LocalTime.MIDNIGHT,
LocalTime.of(0, 15),
"Other Place App Test",
"Other Subject App Test",
List.of(otherProjectCell),
null);
appointmentService.addNewAppointment(otherApp); appointmentService.addNewAppointment(otherApp);
// Act // Act
Iterable<Appointment> result = sharedApiService.getAppointmentsByProjectId( Iterable<Appointment> result =
sharedApiService.getAppointmentsByProjectId(
staticAuthorizedProject.getIdProject(), // Use static project ID staticAuthorizedProject.getIdProject(), // Use static project ID
staticAuthorizedMail); // Use static authorized mail staticAuthorizedMail); // Use static authorized mail
@ -676,10 +932,21 @@ public class SharedApiServiceTest {
// Assert // Assert
assertEquals(2, resultList.size()); assertEquals(2, resultList.size());
assertTrue(resultList.stream().anyMatch(a -> a.getIdAppointment().equals(savedApp1.getIdAppointment()))); assertTrue(
assertTrue(resultList.stream().anyMatch(a -> a.getIdAppointment().equals(savedApp2.getIdAppointment()))); resultList.stream()
.anyMatch(a -> a.getIdAppointment().equals(savedApp1.getIdAppointment())));
assertFalse(resultList.stream().anyMatch(a -> a.getIdAppointment().equals(otherApp.getIdAppointment()))); // Ensure appointment from other project is not included assertTrue(
resultList.stream()
.anyMatch(a -> a.getIdAppointment().equals(savedApp2.getIdAppointment())));
assertFalse(
resultList.stream()
.anyMatch(
a ->
a.getIdAppointment()
.equals(
otherApp
.getIdAppointment()))); // Ensure
// appointment from other project is not included
} }
} }