fix (kinda) : refactored update of data, still trying to fix bug
from EntrepreneurApiServiceTests (code is a bit messy with prints and comments dw)
This commit is contained in:
parent
9b9cfbdb2e
commit
aaa6e46d0c
MyINPulse-back/src
main/java/enseirb/myinpulse
model
repository
service
test/java/enseirb/myinpulse
@ -5,7 +5,6 @@ import jakarta.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "project")
|
||||
@ -69,17 +68,11 @@ public class Project {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
Project project = (Project) o;
|
||||
return Objects.equals(listEntrepreneurParticipation, project.listEntrepreneurParticipation)
|
||||
&& Objects.equals(listSectionCell, project.listSectionCell)
|
||||
&& Objects.equals(idProject, project.idProject)
|
||||
&& Objects.equals(projectName, project.projectName)
|
||||
&& Objects.deepEquals(logo, project.logo)
|
||||
&& Objects.equals(creationDate, project.creationDate)
|
||||
&& projectStatus == project.projectStatus
|
||||
&& Objects.equals(projectAdministrator, project.projectAdministrator)
|
||||
&& Objects.equals(entrepreneurProposed, project.entrepreneurProposed);
|
||||
return this.idProject == project.idProject;
|
||||
}
|
||||
|
||||
public Long getIdProject() {
|
||||
|
@ -9,7 +9,7 @@ import java.util.Optional;
|
||||
|
||||
@RepositoryRestResource
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
Optional<User> findByPrimaryMail(String email);
|
||||
Optional<User> findByPrimaryMail(String primaryMail);
|
||||
|
||||
/* @Query("SELECT u from User u")
|
||||
User findAllUser(); */
|
||||
|
@ -97,8 +97,9 @@ public class AdminApiService {
|
||||
decision.projectId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(decision.isAccepted == 1) ? ACTIVE : REJECTED,
|
||||
null,
|
||||
null,
|
||||
this.administratorService.getAdministratorById(decision.adminId));
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class EntrepreneurApiService {
|
||||
mail,
|
||||
sectionCellId,
|
||||
this.sectionCellService.getProjectId(sectionCellId));
|
||||
sectionCellService.updateSectionCell(sectionCellId, content);
|
||||
sectionCellService.updateSectionCell(sectionCellId, content, null, null, null);
|
||||
}
|
||||
|
||||
public void removeSectionCell(Long sectionCellId, String mail) {
|
||||
@ -71,7 +71,7 @@ public class EntrepreneurApiService {
|
||||
"User {} tried to remove section cells {} of the project {} but is not allowed to.",
|
||||
mail,
|
||||
sectionCellId,
|
||||
this.sectionCellService.getSectionCellById(sectionCellId));
|
||||
this.sectionCellService.getProjectId(sectionCellId));
|
||||
throw new ResponseStatusException(
|
||||
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class UtilsService {
|
||||
User user = this.userService.getUserByEmail(mail);
|
||||
Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(user.getIdUser());
|
||||
Project project = this.projectService.getProjectById(projectId);
|
||||
return entrepreneur.getProjectParticipation() == project;
|
||||
return entrepreneur.getProjectParticipation().equals(project);
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
|
@ -1,6 +1,9 @@
|
||||
package enseirb.myinpulse.service.database;
|
||||
|
||||
import enseirb.myinpulse.model.Administrator;
|
||||
import enseirb.myinpulse.model.Annotation;
|
||||
import enseirb.myinpulse.model.MakeAppointment;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.repository.AdministratorRepository;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -52,6 +55,49 @@ public class AdministratorService {
|
||||
return this.administratorRepository.save(administrator);
|
||||
}
|
||||
|
||||
public void updateAdministratorListProject(long idAdministrator, Project project) {
|
||||
Administrator administrator = getAdministratorById(idAdministrator);
|
||||
administrator.updateListProject(project);
|
||||
this.administratorRepository.save(administrator);
|
||||
}
|
||||
|
||||
public void updateAdministratorListAnnotation(long idAdministrator, Annotation annotation) {
|
||||
Administrator administrator = getAdministratorById(idAdministrator);
|
||||
administrator.updateListAnnotation(annotation);
|
||||
this.administratorRepository.save(administrator);
|
||||
}
|
||||
|
||||
public void updateAdministratorMakeAppointment(
|
||||
long idAdministrator, MakeAppointment makeAppointment) {
|
||||
Administrator administrator = getAdministratorById(idAdministrator);
|
||||
administrator.setMakeAppointment(makeAppointment);
|
||||
this.administratorRepository.save(administrator);
|
||||
}
|
||||
|
||||
public Administrator updateAdministrator(
|
||||
Long idAdministrator,
|
||||
Project project,
|
||||
Annotation annotation,
|
||||
MakeAppointment makeAppointment) {
|
||||
Optional<Administrator> administrator = administratorRepository.findById(idAdministrator);
|
||||
if (administrator.isEmpty()) {
|
||||
logger.error(
|
||||
"updateAdministrator : No administrator found with id {}", idAdministrator);
|
||||
throw new ResponseStatusException(
|
||||
HttpStatus.NOT_FOUND, "Cet administrateur n'existe pas");
|
||||
}
|
||||
if (project != null) {
|
||||
administrator.get().updateListProject(project);
|
||||
}
|
||||
if (annotation != null) {
|
||||
administrator.get().updateListAnnotation(annotation);
|
||||
}
|
||||
if (makeAppointment != null) {
|
||||
administrator.get().setMakeAppointment(makeAppointment);
|
||||
}
|
||||
return this.administratorRepository.save(administrator.get());
|
||||
}
|
||||
|
||||
/*
|
||||
public Administrator getAdministratorByProject(Project project) {
|
||||
r
|
||||
|
@ -46,6 +46,12 @@ public class AnnotationService {
|
||||
this.annotationRepository.deleteById(id);
|
||||
}
|
||||
|
||||
public void updateAnnotationComment(long idAnnotation, String comment) {
|
||||
Annotation annotation = getAnnotationById(idAnnotation);
|
||||
annotation.setComment(comment);
|
||||
this.annotationRepository.save(annotation);
|
||||
}
|
||||
|
||||
public Annotation updateAnnotation(Long id, String comment) {
|
||||
Optional<Annotation> annotation = annotationRepository.findById(id);
|
||||
if (annotation.isEmpty()) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.service.database;
|
||||
|
||||
import enseirb.myinpulse.model.Appointment;
|
||||
import enseirb.myinpulse.model.SectionCell;
|
||||
import enseirb.myinpulse.repository.AppointmentRepository;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -47,13 +48,50 @@ public class AppointmentService {
|
||||
this.appointmentRepository.deleteById(id);
|
||||
}
|
||||
|
||||
public void updateAppointmentDate(long idAppointment, LocalDate date) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.setAppointmentDate(date);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public void updateAppointmentTime(long idAppointment, LocalTime time) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.setAppointmentTime(time);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public void updateAppointmentDuration(long idAppointment, LocalTime duration) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.setAppointmentDuration(duration);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public void updateAppointmentPlace(long idAppointment, String place) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.setAppointmentPlace(place);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public void updateAppointmentSubject(long idAppointment, String subject) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.setAppointmentSubject(subject);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public void updateAppointmentListSectionCell(long idAppointment, SectionCell sectionCell) {
|
||||
Appointment appointment = getAppointmentById(idAppointment);
|
||||
appointment.updateListSectionCell(sectionCell);
|
||||
this.appointmentRepository.save(appointment);
|
||||
}
|
||||
|
||||
public Appointment updateAppointment(
|
||||
Long id,
|
||||
LocalDate appointmentDate,
|
||||
LocalTime appointmentTime,
|
||||
LocalTime appointmentDuration,
|
||||
String appointmentPlace,
|
||||
String appointmentSubject) {
|
||||
String appointmentSubject,
|
||||
SectionCell sectionCell) {
|
||||
Optional<Appointment> appointment = this.appointmentRepository.findById(id);
|
||||
if (appointment.isEmpty()) {
|
||||
logger.error("updateAppointment : No appointment found with id {}", id);
|
||||
@ -74,6 +112,9 @@ public class AppointmentService {
|
||||
if (appointmentSubject != null) {
|
||||
appointment.get().setAppointmentSubject(appointmentSubject);
|
||||
}
|
||||
if (sectionCell != null) {
|
||||
appointment.get().updateListSectionCell(sectionCell);
|
||||
}
|
||||
return this.appointmentRepository.save(appointment.get());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.service.database;
|
||||
|
||||
import enseirb.myinpulse.model.Entrepreneur;
|
||||
import enseirb.myinpulse.model.MakeAppointment;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.repository.EntrepreneurRepository;
|
||||
|
||||
@ -41,8 +42,56 @@ public class EntrepreneurService {
|
||||
return this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurSchool(long idEntrepreneur, String school) {
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
entrepreneur.setSchool(school);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurCourse(long idEntrepreneur, String course) {
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
entrepreneur.setCourse(course);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurSneeStatus(long idEntrepreneur, boolean status) {
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
entrepreneur.setSneeStatus(status);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurProjectParticipation(
|
||||
long idEntrepreneur, Project projectParticipation) {
|
||||
System.out.println("expected");
|
||||
System.out.println(getEntrepreneurById(idEntrepreneur));
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
System.out.println("test");
|
||||
System.out.println(entrepreneur);
|
||||
entrepreneur.setProjectParticipation(projectParticipation);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurProjectProposed(long idEntrepreneur, Project projectProposed) {
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
entrepreneur.setProjectParticipation(projectProposed);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public void updateEntrepreneurMakeAppointment(
|
||||
long idEntrepreneur, MakeAppointment makeAppointment) {
|
||||
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
|
||||
entrepreneur.setMakeAppointment(makeAppointment);
|
||||
this.entrepreneurRepository.save(entrepreneur);
|
||||
}
|
||||
|
||||
public Entrepreneur updateEntrepreneur(
|
||||
Long id, String school, String course, Boolean sneeStatus) {
|
||||
Long id,
|
||||
String school,
|
||||
String course,
|
||||
Boolean sneeStatus,
|
||||
Project projectParticipation,
|
||||
Project projectProposed,
|
||||
MakeAppointment makeAppointment) {
|
||||
Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id);
|
||||
if (entrepreneur.isEmpty()) {
|
||||
logger.error("updateEntrepreneur : No entrepreneur found with id {}", id);
|
||||
@ -58,6 +107,15 @@ public class EntrepreneurService {
|
||||
if (sneeStatus != null) {
|
||||
entrepreneur.get().setSneeStatus(sneeStatus);
|
||||
}
|
||||
if (projectParticipation != null) {
|
||||
entrepreneur.get().setProjectParticipation(projectParticipation);
|
||||
}
|
||||
if (projectProposed != null) {
|
||||
entrepreneur.get().setProjectParticipation(projectProposed);
|
||||
}
|
||||
if (makeAppointment != null) {
|
||||
entrepreneur.get().setMakeAppointment(makeAppointment);
|
||||
}
|
||||
return this.entrepreneurRepository.save(entrepreneur.get());
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,7 @@ package enseirb.myinpulse.service.database;
|
||||
|
||||
import static enseirb.myinpulse.model.ProjectDecisionValue.PENDING;
|
||||
|
||||
import enseirb.myinpulse.model.Administrator;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.model.ProjectDecisionValue;
|
||||
import enseirb.myinpulse.model.*;
|
||||
import enseirb.myinpulse.repository.ProjectRepository;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -14,7 +12,6 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -52,12 +49,50 @@ public class ProjectService {
|
||||
return this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectName(long idProject, String name) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.setProjectName(name);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectLogo(long idProject, byte[] logo) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.setLogo(logo);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectStatus(long idProject, ProjectDecisionValue status) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.setProjectStatus(status);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectEntrepreneurParticipation(
|
||||
long idProject, Entrepreneur entrepreneurParticipation) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.updateListEntrepreneurParticipation(entrepreneurParticipation);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectListSectionCell(long idProject, SectionCell sectionCell) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.updateListSectionCell(sectionCell);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public void updateProjectAdministrator(long idProject, Administrator administrator) {
|
||||
Project project = getProjectById(idProject);
|
||||
project.setProjectAdministrator(administrator);
|
||||
this.projectRepository.save(project);
|
||||
}
|
||||
|
||||
public Project updateProject(
|
||||
Long id,
|
||||
String projectName,
|
||||
byte[] logo,
|
||||
LocalDate creationDate,
|
||||
ProjectDecisionValue projectStatus,
|
||||
Entrepreneur entrepreneurParticipation,
|
||||
SectionCell sectionCell,
|
||||
Administrator administrator) {
|
||||
Optional<Project> project = this.projectRepository.findById(id);
|
||||
|
||||
@ -73,11 +108,6 @@ public class ProjectService {
|
||||
if (logo != null) {
|
||||
project.get().setLogo(logo);
|
||||
}
|
||||
|
||||
if (creationDate != null) {
|
||||
project.get().setCreationDate(creationDate);
|
||||
}
|
||||
|
||||
if (projectStatus != null) {
|
||||
// TODO: check if this is really useful
|
||||
/*
|
||||
@ -89,7 +119,12 @@ public class ProjectService {
|
||||
*/
|
||||
project.get().setProjectStatus(projectStatus);
|
||||
}
|
||||
|
||||
if (entrepreneurParticipation != null) {
|
||||
project.get().updateListEntrepreneurParticipation(entrepreneurParticipation);
|
||||
}
|
||||
if (sectionCell != null) {
|
||||
project.get().updateListSectionCell(sectionCell);
|
||||
}
|
||||
if (administrator != null) {
|
||||
project.get().setProjectAdministrator(administrator);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package enseirb.myinpulse.service.database;
|
||||
|
||||
import enseirb.myinpulse.model.Appointment;
|
||||
import enseirb.myinpulse.model.Report;
|
||||
import enseirb.myinpulse.repository.ReportRepository;
|
||||
|
||||
@ -46,7 +47,19 @@ public class ReportService {
|
||||
this.reportRepository.deleteById(id);
|
||||
}
|
||||
|
||||
public Report updateReport(Long id, String reportContent) {
|
||||
public void updateReportContent(long idReport, String content) {
|
||||
Report report = getReportById(idReport);
|
||||
report.setReportContent(content);
|
||||
this.reportRepository.save(report);
|
||||
}
|
||||
|
||||
public void updateReportAppointment(long idReport, Appointment appointment) {
|
||||
Report report = getReportById(idReport);
|
||||
report.setAppointmentReport(appointment);
|
||||
this.reportRepository.save(report);
|
||||
}
|
||||
|
||||
public Report updateReport(Long id, String reportContent, Appointment appointment) {
|
||||
Optional<Report> report = this.reportRepository.findById(id);
|
||||
if (report.isEmpty()) {
|
||||
logger.error("updateReport : No report found with id {}", id);
|
||||
@ -55,6 +68,9 @@ public class ReportService {
|
||||
if (reportContent != null) {
|
||||
report.get().setReportContent(reportContent);
|
||||
}
|
||||
if (appointment != null) {
|
||||
report.get().setAppointmentReport(appointment);
|
||||
}
|
||||
return this.reportRepository.save(report.get());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package enseirb.myinpulse.service.database;
|
||||
|
||||
import enseirb.myinpulse.model.Annotation;
|
||||
import enseirb.myinpulse.model.Appointment;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.model.SectionCell;
|
||||
@ -50,7 +51,36 @@ public class SectionCellService {
|
||||
this.sectionCellRepository.deleteById(id);
|
||||
}
|
||||
|
||||
public SectionCell updateSectionCell(Long id, String contentSectionCell) {
|
||||
public void updateSectionCellContent(long idSectionCell, String content) {
|
||||
SectionCell sectionCell = getSectionCellById(idSectionCell);
|
||||
sectionCell.setContentSectionCell(content);
|
||||
this.sectionCellRepository.save(sectionCell);
|
||||
}
|
||||
|
||||
public void updateSectionCellListAppointment(long idSectionCell, Appointment appointment) {
|
||||
SectionCell sectionCell = getSectionCellById(idSectionCell);
|
||||
sectionCell.updateAppointmentSectionCell(appointment);
|
||||
this.sectionCellRepository.save(sectionCell);
|
||||
}
|
||||
|
||||
public void updateSectionCellListAnnotation(long idSectionCell, Annotation annotation) {
|
||||
SectionCell sectionCell = getSectionCellById(idSectionCell);
|
||||
sectionCell.updateListAnnotation(annotation);
|
||||
this.sectionCellRepository.save(sectionCell);
|
||||
}
|
||||
|
||||
public void updateSectionCellProject(long idSectionCell, Project project) {
|
||||
SectionCell sectionCell = getSectionCellById(idSectionCell);
|
||||
sectionCell.setProjectSectionCell(project);
|
||||
this.sectionCellRepository.save(sectionCell);
|
||||
}
|
||||
|
||||
public SectionCell updateSectionCell(
|
||||
Long id,
|
||||
String contentSectionCell,
|
||||
Appointment appointment,
|
||||
Annotation annotation,
|
||||
Project project) {
|
||||
Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id);
|
||||
if (sectionCell.isEmpty()) {
|
||||
logger.error("updateSectionCell : No sectionCell found with id {}", id);
|
||||
@ -61,11 +91,24 @@ public class SectionCellService {
|
||||
sectionCell.get().setContentSectionCell(contentSectionCell);
|
||||
sectionCell.get().setModificationDate(LocalDateTime.now());
|
||||
}
|
||||
if (appointment != null) {
|
||||
sectionCell.get().updateAppointmentSectionCell(appointment);
|
||||
sectionCell.get().setModificationDate(LocalDateTime.now());
|
||||
}
|
||||
if (annotation != null) {
|
||||
sectionCell.get().updateListAnnotation(annotation);
|
||||
sectionCell.get().setModificationDate(LocalDateTime.now());
|
||||
}
|
||||
if (project != null) {
|
||||
sectionCell.get().setProjectSectionCell(project);
|
||||
sectionCell.get().setModificationDate(LocalDateTime.now());
|
||||
}
|
||||
return this.sectionCellRepository.save(sectionCell.get());
|
||||
}
|
||||
|
||||
public Iterable<SectionCell> getSectionCellsByProject(Project project, Long sectionId) {
|
||||
return this.sectionCellRepository.findByProjectSectionCellAndSectionId(project, sectionId);
|
||||
public Iterable<SectionCell> getSectionCellsByProject(Project project, Long idSectionCell) {
|
||||
return this.sectionCellRepository.findByProjectSectionCellAndSectionId(
|
||||
project, idSectionCell);
|
||||
}
|
||||
|
||||
public Long getProjectId(Long sectionCellId) {
|
||||
|
@ -30,6 +30,15 @@ public class UserService {
|
||||
return this.userRepository.findAll();
|
||||
}
|
||||
|
||||
public User getUserById(long id) {
|
||||
Optional<User> user = this.userRepository.findById(id);
|
||||
if (user.isEmpty()) {
|
||||
logger.error("getUserById : No user found with id {}", id);
|
||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet utilisateur n'existe pas");
|
||||
}
|
||||
return user.get();
|
||||
}
|
||||
|
||||
// TODO
|
||||
public User getUserByEmail(String email) {
|
||||
Optional<User> opt_user = this.userRepository.findByPrimaryMail(email);
|
||||
@ -49,6 +58,36 @@ public class UserService {
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public void updateUserSurname(long idUser, String surname) {
|
||||
User user = getUserById(idUser);
|
||||
user.setUserSurname(surname);
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public void updateUserName(long idUser, String name) {
|
||||
User user = getUserById(idUser);
|
||||
user.setUserName(name);
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public void updateUserPrimaryMail(long idUser, String primaryMail) {
|
||||
User user = getUserById(idUser);
|
||||
user.setPrimaryMail(primaryMail);
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public void updateUserSecondaryMail(long idUser, String secondaryMail) {
|
||||
User user = getUserById(idUser);
|
||||
user.setSecondaryMail(secondaryMail);
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public void updateUserPhoneNumber(long idUser, String phoneNumber) {
|
||||
User user = getUserById(idUser);
|
||||
user.setPhoneNumber(phoneNumber);
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
public User updateUser(
|
||||
@PathVariable Long id,
|
||||
String userSurname,
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
@Transactional
|
||||
public class EntrepreneurApiServiceTest {
|
||||
private static Entrepreneur entrepreneur;
|
||||
private static Project project;
|
||||
private static Iterable<SectionCell> sectionCells;
|
||||
@Autowired private EntrepreneurApiService entrepreneurApiService;
|
||||
@Autowired private EntrepreneurService entrepreneurService;
|
||||
@ -60,20 +61,22 @@ public class EntrepreneurApiServiceTest {
|
||||
"ENSEGID",
|
||||
"",
|
||||
true));
|
||||
Project project =
|
||||
project =
|
||||
projectService.addNewProject(
|
||||
new Project("Project", null, LocalDate.now(), ACTIVE, null, entrepreneur));
|
||||
entrepreneur.setProjectParticipation(project);
|
||||
// projectService.updateProjectEntrepreneurParticipation(project.getIdProject(),
|
||||
// entrepreneur); proxy error because why not
|
||||
entrepreneurService.updateEntrepreneurProjectProposed(entrepreneur.getIdUser(), project);
|
||||
entrepreneurService.updateEntrepreneurProjectParticipation(
|
||||
entrepreneur.getIdUser(), project);
|
||||
System.out.println(("real"));
|
||||
System.out.println(entrepreneur);
|
||||
// System.out.println(entrepreneur.getProjectProposed());
|
||||
// System.out.println(entrepreneur.getProjectParticipation());
|
||||
sectionCellService.addNewSectionCell(
|
||||
new SectionCell(
|
||||
null,
|
||||
2L,
|
||||
"contenu très intéressant",
|
||||
LocalDateTime.now(),
|
||||
projectService.getProjectByName("Project")));
|
||||
sectionCells =
|
||||
sectionCellService.getSectionCellsByProject(
|
||||
projectService.getProjectByName("Project"), 2L);
|
||||
null, 2L, "contenu très intéressant", LocalDateTime.now(), project));
|
||||
sectionCells = sectionCellService.getSectionCellsByProject(project, 2L);
|
||||
}
|
||||
|
||||
private <T> List<T> IterableToList(Iterable<T> iterable) {
|
||||
@ -84,7 +87,6 @@ public class EntrepreneurApiServiceTest {
|
||||
|
||||
@Test
|
||||
void editValidSectionCell() {
|
||||
System.out.println(sectionCells);
|
||||
entrepreneurApiService.editSectionCell(
|
||||
IterableToList(sectionCells).getFirst().getIdSectionCell(),
|
||||
"modified content",
|
||||
@ -122,25 +124,13 @@ public class EntrepreneurApiServiceTest {
|
||||
SectionCell tmpCell =
|
||||
sectionCellService.addNewSectionCell(
|
||||
new SectionCell(
|
||||
null,
|
||||
2L,
|
||||
"contenu temporaire",
|
||||
LocalDateTime.now(),
|
||||
projectService.getProjectByName("Project")));
|
||||
null, 2L, "contenu temporaire", LocalDateTime.now(), project));
|
||||
assertEquals(
|
||||
2,
|
||||
IterableToList(
|
||||
sectionCellService.getSectionCellsByProject(
|
||||
projectService.getProjectByName("Project"), 2L))
|
||||
.size());
|
||||
2, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
|
||||
entrepreneurApiService.removeSectionCell(
|
||||
tmpCell.getIdSectionCell(), "entrepreneur@mail.fr");
|
||||
assertEquals(
|
||||
1,
|
||||
IterableToList(
|
||||
sectionCellService.getSectionCellsByProject(
|
||||
projectService.getProjectByName("Project"), 2L))
|
||||
.size());
|
||||
1, IterableToList(sectionCellService.getSectionCellsByProject(project, 2L)).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user