feat: added new tests and fixed few issues
This commit is contained in:
parent
52511dd4c4
commit
5ee3755548
@ -37,7 +37,6 @@ public class Entrepreneur extends User {
|
||||
public Entrepreneur() {}
|
||||
|
||||
public Entrepreneur(
|
||||
Long idUser,
|
||||
String userSurname,
|
||||
String username,
|
||||
String primaryMail,
|
||||
@ -46,7 +45,7 @@ public class Entrepreneur extends User {
|
||||
String school,
|
||||
String course,
|
||||
boolean sneeStatus) {
|
||||
super(idUser, userSurname, username, primaryMail, secondaryMail, phoneNumber);
|
||||
super(userSurname, username, primaryMail, secondaryMail, phoneNumber);
|
||||
this.school = school;
|
||||
this.course = course;
|
||||
this.sneeStatus = sneeStatus;
|
||||
|
@ -28,6 +28,8 @@ public class User {
|
||||
|
||||
public User() {}
|
||||
|
||||
// TODO: this should be removed as we shouldn't be able to chose the ID. Leaving it for
|
||||
// compatibility purposes, as soon as it's not used anymore, delete it
|
||||
public User(
|
||||
Long idUser,
|
||||
String userSurname,
|
||||
@ -43,6 +45,19 @@ public class User {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public User(
|
||||
String userSurname,
|
||||
String userName,
|
||||
String primaryMail,
|
||||
String secondaryMail,
|
||||
String phoneNumber) {
|
||||
this.userSurname = userSurname;
|
||||
this.userName = userName;
|
||||
this.primaryMail = primaryMail;
|
||||
this.secondaryMail = secondaryMail;
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public Long getIdUser() {
|
||||
return idUser;
|
||||
}
|
||||
|
@ -91,7 +91,9 @@ public class AdminApiService {
|
||||
newProject.getProjectAdministrator().updateListProject(newProject);
|
||||
}
|
||||
if (newProject.getEntrepreneurProposed() != null) {
|
||||
newProject.getEntrepreneurProposed().setProjectProposed(newProject);
|
||||
Entrepreneur proposed = newProject.getEntrepreneurProposed();
|
||||
proposed.setProjectProposed(newProject);
|
||||
proposed.setProjectParticipation(newProject);
|
||||
}
|
||||
newProject
|
||||
.getListEntrepreneurParticipation()
|
||||
|
@ -5,10 +5,12 @@ import static enseirb.myinpulse.model.ProjectDecisionValue.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import enseirb.myinpulse.model.Administrator;
|
||||
import enseirb.myinpulse.model.Entrepreneur;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.model.ProjectDecision;
|
||||
import enseirb.myinpulse.service.AdminApiService;
|
||||
import enseirb.myinpulse.service.database.AdministratorService;
|
||||
import enseirb.myinpulse.service.database.EntrepreneurService;
|
||||
import enseirb.myinpulse.service.database.ProjectService;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -26,13 +28,16 @@ import java.util.List;
|
||||
@Transactional
|
||||
public class AdminApiServiceTest {
|
||||
private static long administratorid;
|
||||
private static Administrator administrator;
|
||||
private static Entrepreneur entrepreneur;
|
||||
@Autowired private AdminApiService adminApiService;
|
||||
@Autowired private ProjectService projectService;
|
||||
|
||||
@BeforeAll
|
||||
static void setup(
|
||||
@Autowired AdministratorService administratorService,
|
||||
@Autowired ProjectService projectService) {
|
||||
@Autowired ProjectService projectService,
|
||||
@Autowired EntrepreneurService entrepreneurService) {
|
||||
administratorService.addAdministrator(
|
||||
new Administrator(
|
||||
"admin",
|
||||
@ -40,7 +45,7 @@ public class AdminApiServiceTest {
|
||||
"testAdminEmpty@example.com",
|
||||
"testAdmin@example.com",
|
||||
""));
|
||||
Administrator a =
|
||||
administrator =
|
||||
administratorService.addAdministrator(
|
||||
new Administrator(
|
||||
"admin2",
|
||||
@ -48,7 +53,18 @@ public class AdminApiServiceTest {
|
||||
"testAdminFull@example.com",
|
||||
"testAdmin@example.com",
|
||||
""));
|
||||
administratorid = a.getIdUser();
|
||||
administratorid = administrator.getIdUser();
|
||||
entrepreneur =
|
||||
new Entrepreneur(
|
||||
"JeSuisUnEntrepreneurDeCompet",
|
||||
"EtUé",
|
||||
"Entrepreneur@inpulse.com",
|
||||
"mail2",
|
||||
"phone",
|
||||
"Ensimag nan jdeconne ENSEIRB (-matmeca mais on s'en fout)",
|
||||
"info ofc",
|
||||
false);
|
||||
entrepreneurService.addEntrepreneur(entrepreneur);
|
||||
projectService.addNewProject(
|
||||
new Project(
|
||||
"sampleProjectAdminApiService",
|
||||
@ -161,6 +177,41 @@ public class AdminApiServiceTest {
|
||||
assertEquals(1, IterableToList(this.adminApiService.getPendingProjects()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addProjectToAdmin() {
|
||||
assertEquals(0, administrator.getListProject().size());
|
||||
Project p1 = new Project("assProjectToAdmin", null, LocalDate.now(), ACTIVE, administrator);
|
||||
this.adminApiService.addNewProject(p1);
|
||||
assertEquals(1, administrator.getListProject().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addProjectToUser() {
|
||||
assertNull(entrepreneur.getProjectParticipation());
|
||||
Project p1 =
|
||||
new Project("assProjectToAdmin", null, LocalDate.now(), ACTIVE, null, entrepreneur);
|
||||
this.adminApiService.addNewProject(p1);
|
||||
assertEquals(p1, entrepreneur.getProjectParticipation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addProjectWithManyUsers() {
|
||||
Entrepreneur e1 = new Entrepreneur();
|
||||
Entrepreneur e2 = new Entrepreneur();
|
||||
Entrepreneur e3 = new Entrepreneur();
|
||||
assertNull(e1.getProjectParticipation());
|
||||
assertNull(e2.getProjectParticipation());
|
||||
assertNull(e3.getProjectParticipation());
|
||||
Project p1 = new Project("assProjectToAdmin", null, LocalDate.now(), ACTIVE, null, null);
|
||||
p1.updateListEntrepreneurParticipation(e1);
|
||||
p1.updateListEntrepreneurParticipation(e2);
|
||||
p1.updateListEntrepreneurParticipation(e3);
|
||||
this.adminApiService.addNewProject(p1);
|
||||
assertEquals(p1, e1.getProjectParticipation());
|
||||
assertEquals(p1, e2.getProjectParticipation());
|
||||
assertEquals(p1, e3.getProjectParticipation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addDuplicateProject() {
|
||||
Project p1 =
|
||||
|
Loading…
x
Reference in New Issue
Block a user