Compare commits

..

No commits in common. "04589392cb83a139b7b3593e0cf7ce19d1d29c2d" and "8153496a0f06d22203f736971382f338b8722701" have entirely different histories.

13 changed files with 27 additions and 64 deletions

View File

@ -23,13 +23,10 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-rest' implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.+' implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.16.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+' implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.16.0'
implementation 'org.postgresql:postgresql' implementation 'org.postgresql:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
} }

View File

@ -13,14 +13,14 @@ import java.util.List;
public class Administrator extends User { public class Administrator extends User {
@OneToMany(mappedBy = "projectAdministrator", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "projectAdministrator", fetch = FetchType.LAZY, orphanRemoval = true)
private final List<Project> listProject = new ArrayList<>(); private List<Project> listProject = new ArrayList<>();
/*@OneToMany(mappedBy = "administratorSectionCell", fetch = FetchType.LAZY, orphanRemoval = true) /*@OneToMany(mappedBy = "administratorSectionCell", fetch = FetchType.LAZY, orphanRemoval = true)
private List<SectionCell> listSectionCell = new ArrayList<>();*/ private List<SectionCell> listSectionCell = new ArrayList<>();*/
// should now be useless // should now be useless
@OneToMany(mappedBy = "administratorAnnotation", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "administratorAnnotation", fetch = FetchType.LAZY, orphanRemoval = true)
private final List<Annotation> listAnnotation = new ArrayList<>(); private List<Annotation> listAnnotation = new ArrayList<>();
/*@OneToMany(mappedBy = "administratorAppointment", fetch = FetchType.LAZY, orphanRemoval = true) /*@OneToMany(mappedBy = "administratorAppointment", fetch = FetchType.LAZY, orphanRemoval = true)
private final List<Appointment> listAppointment = new ArrayList<>();*/ private final List<Appointment> listAppointment = new ArrayList<>();*/
@ -32,11 +32,12 @@ public class Administrator extends User {
public Administrator() {} public Administrator() {}
public Administrator( public Administrator(
Long idUser,
String userSurname, String userSurname,
String username, String username,
String mainMail, String mainMail,
String secondaryMail, String secondaryMail,
String phoneNumber) { String phoneNumber) {
super(null, userSurname, username, mainMail, secondaryMail, phoneNumber); super(idUser, userSurname, username, mainMail, secondaryMail, phoneNumber);
} }
} }

View File

@ -1,12 +1,14 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "annotation") @Table(name = "annotation")
public class Annotation { public class Annotation {
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idAnnotation; private Long idAnnotation;

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
@ -16,6 +17,9 @@ public class Appointment {
new ArrayList<>(); */ new ArrayList<>(); */
// should now be useless // should now be useless
@OneToOne(mappedBy = "appointmentReport", fetch = FetchType.LAZY, orphanRemoval = true)
private Report report;
@ManyToMany( @ManyToMany(
fetch = FetchType.LAZY, fetch = FetchType.LAZY,
cascade = {CascadeType.ALL}) cascade = {CascadeType.ALL})
@ -24,9 +28,9 @@ public class Appointment {
joinColumns = @JoinColumn(name = "idAppointment"), joinColumns = @JoinColumn(name = "idAppointment"),
inverseJoinColumns = @JoinColumn(name = "idSectionCell")) inverseJoinColumns = @JoinColumn(name = "idSectionCell"))
List<SectionCell> listSectionCell = new ArrayList<>(); List<SectionCell> listSectionCell = new ArrayList<>();
@OneToOne(mappedBy = "appointmentReport", fetch = FetchType.LAZY, orphanRemoval = true)
private Report report;
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idAppointment; private Long idAppointment;

View File

@ -1,12 +1,14 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "make_appointment") @Table(name = "make_appointment")
public class MakeAppointment { public class MakeAppointment {
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idMakeAppointment; private Long idMakeAppointment;

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,6 +18,7 @@ public class Project {
private final List<SectionCell> listSectionCell = new ArrayList<>(); private final List<SectionCell> listSectionCell = new ArrayList<>();
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idProject; private Long idProject;

View File

@ -4,12 +4,14 @@ import jakarta.persistence.*;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "report") @Table(name = "report")
public class Report { public class Report {
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idReport; private Long idReport;

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,6 +18,7 @@ public class SectionCell {
private final List<Annotation> listAnnotation = new ArrayList<>(); private final List<Annotation> listAnnotation = new ArrayList<>();
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idSectionCell; private Long idSectionCell;

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "user_inpulse") @Table(name = "user_inpulse")
@ -8,6 +9,7 @@ import jakarta.persistence.*;
public class User { public class User {
@Id @Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idUser; private Long idUser;

View File

@ -1,6 +1,7 @@
spring.application.name=myinpulse spring.application.name=myinpulse
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test
logging.level.org.springframework.security=DEBUG
spring.datasource.url=jdbc:postgresql://${DATABASE_URL}/${BACKEND_DB} spring.datasource.url=jdbc:postgresql://${DATABASE_URL}/${BACKEND_DB}
spring.datasource.username=${BACKEND_USER} spring.datasource.username=${BACKEND_USER}
spring.datasource.password=${BACKEND_PASSWORD} spring.datasource.password=${BACKEND_PASSWORD}

View File

@ -1,51 +0,0 @@
package enseirb.myinpulse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import enseirb.myinpulse.model.Administrator;
import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.service.AdminApiService;
import enseirb.myinpulse.service.database.AdministratorService;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.server.ResponseStatusException;
import java.util.ArrayList;
import java.util.List;
@SpringBootTest
@Transactional
public class AdminApiServiceTest {
@Autowired private AdminApiService adminApiService;
@BeforeAll
static void setup(@Autowired AdministratorService administratorService) {
administratorService.addAdministrator(
new Administrator(
"admin", "admin", "testAdmin@example.com", "testAdmin@example.com", ""));
}
@Test
void getProjectOfAdminIsEmpty() throws Exception {
Iterable<Project> projects = adminApiService.getProjectsOfAdmin("testAdmin@example.com");
List<Project> l = new ArrayList<>();
projects.forEach(l::add);
assertEquals(0, l.size());
}
@Test
void getProjectOfInexistantAdminFails() throws Exception {
String nonExistentAdminEmail = "testInexistantAdmin@example.com";
assertThrows(
ResponseStatusException.class,
() -> {
adminApiService.getProjectsOfAdmin(nonExistentAdminEmail);
});
}
}

View File

@ -1,6 +1,5 @@
package enseirb.myinpulse; package enseirb.myinpulse;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -8,6 +7,5 @@ import org.springframework.boot.test.context.SpringBootTest;
class MyinpulseApplicationTests { class MyinpulseApplicationTests {
@Test @Test
@DisplayName("contextLoad => Test if the context can load, i.e. the application can start")
void contextLoads() {} void contextLoads() {}
} }

View File

@ -6,5 +6,6 @@ spring.sql.init.mode=never
spring.application.name=myinpulse-test spring.application.name=myinpulse-test
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test
logging.level.org.springframework.security=DEBUG
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
logging.pattern.console=%d{yyyy-MMM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n logging.pattern.console=%d{yyyy-MMM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n