Compare commits
5 Commits
8153496a0f
...
04589392cb
Author | SHA1 | Date | |
---|---|---|---|
|
04589392cb | ||
|
1106cf8478 | ||
|
215d80ad70 | ||
|
dded62c25a | ||
|
3de7ebe2b1 |
@ -23,10 +23,13 @@ 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.16.0'
|
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.+'
|
||||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.16.0'
|
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+'
|
||||||
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'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 List<Project> listProject = new ArrayList<>();
|
private final 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 List<Annotation> listAnnotation = new ArrayList<>();
|
private final 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,12 +32,11 @@ 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(idUser, userSurname, username, mainMail, secondaryMail, phoneNumber);
|
super(null, userSurname, username, mainMail, secondaryMail, phoneNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
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;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@ -17,9 +16,6 @@ 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})
|
||||||
@ -28,9 +24,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;
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
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;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@ -18,7 +17,6 @@ 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;
|
||||||
|
|
||||||
|
@ -4,14 +4,12 @@ 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;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@ -18,7 +17,6 @@ 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;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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")
|
||||||
@ -9,7 +8,6 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@NotNull
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long idUser;
|
private Long idUser;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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}
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
@ -7,5 +8,6 @@ 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() {}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,5 @@ 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
|
Loading…
x
Reference in New Issue
Block a user