tests ?
Some checks failed
Format / formatting (push) Successful in 6s
Build / build (push) Failing after 39s
CI / build (push) Successful in 14s

This commit is contained in:
Pierre Tellier 2025-04-21 18:01:10 +02:00
parent 8403bc0592
commit 6861d07dfc
2 changed files with 20 additions and 2 deletions

View File

@ -124,6 +124,7 @@ public class EntrepreneurService {
}
public void validateEntrepreneurById(Long id) {
System.out.println("\nVALIDATING\n");
Optional<Entrepreneur> e = this.entrepreneurRepository.findById(id);
if (e.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Entrepreneur n'existe pas");

View File

@ -29,8 +29,10 @@ public class AdminApiServiceTest {
private static long administratorid;
private static Administrator administrator;
private static Entrepreneur entrepreneur;
private static Appointment appt;
@Autowired private AdminApiService adminApiService;
@Autowired private ProjectService projectService;
@Autowired private EntrepreneurService entrepreneurService;
@BeforeAll
static void setup(
@ -84,7 +86,7 @@ public class AdminApiServiceTest {
entrepreneurService.updateEntrepreneurProjectParticipation(entrepreneur2.getIdUser(), p);
Appointment a =
appt =
new Appointment(
null,
LocalDate.now(),
@ -92,7 +94,7 @@ public class AdminApiServiceTest {
LocalTime.now(),
"Salle TD 15",
"Discussion importante");
appoitmentService.addNewAppointment(a);
appoitmentService.addNewAppointment(appt);
}
private <T> List<T> IterableToList(Iterable<T> iterable) {
@ -291,4 +293,19 @@ public class AdminApiServiceTest {
this.adminApiService.getUpcomingAppointments("Entrepreneur2@inpulse.com");
assertEquals(0, IterableToList(a).size());
}
@Test
void validateEntrepreneurAccount() {
assertTrue(entrepreneurService.getEntrepreneurById(entrepreneur.getIdUser()).isPending());
adminApiService.validateEntrepreneurAccount(entrepreneur.getIdUser(), "");
assertFalse(entrepreneurService.getEntrepreneurById(entrepreneur.getIdUser()).isPending());
}
@Test
void testCreateApptRepport() {
this.adminApiService.createAppointmentReport(
appt.getIdAppointment(),
new Report(null, "je rapporte de fou"),
"testAdminFull@example.com");
}
}