backend-test #10

Open
piair wants to merge 51 commits from backend-test into main
2 changed files with 20 additions and 2 deletions
Showing only changes of commit 6861d07dfc - Show all commits

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");
}
}