Refacto Lombok pour Personne et optimisation du POM
This commit is contained in:
parent
8975984b2a
commit
237c8bcf66
3 changed files with 45 additions and 111 deletions
11
pom.xml
11
pom.xml
|
@ -70,12 +70,6 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
|
||||||
<version>5.12.2</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.38</version>
|
<version>1.18.38</version>
|
||||||
|
@ -89,6 +83,11 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.2.5</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -4,121 +4,43 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.*;
|
||||||
import jakarta.persistence.Column;
|
import lombok.AllArgsConstructor;
|
||||||
import jakarta.persistence.ElementCollection;
|
import lombok.Builder;
|
||||||
import jakarta.persistence.Entity;
|
import lombok.Data;
|
||||||
import jakarta.persistence.EnumType;
|
import lombok.NoArgsConstructor;
|
||||||
import jakarta.persistence.Enumerated;
|
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.OneToMany;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public class Personne {
|
public class Personne {
|
||||||
private int id;
|
|
||||||
private String nom;
|
|
||||||
private String prenom;
|
|
||||||
private String email;
|
|
||||||
private String password;
|
|
||||||
private Collection<Preference> preference = new ArrayList<>();
|
|
||||||
private List<EnumRole> roleList;
|
|
||||||
|
|
||||||
public Personne() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Personne(String nom, String prenom, String email, String password, List<EnumRole> roleList) {
|
|
||||||
super();
|
|
||||||
this.nom = nom;
|
|
||||||
this.prenom = prenom;
|
|
||||||
this.email = email;
|
|
||||||
this.password = password;
|
|
||||||
this.roleList = roleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Personne(String email, String password, List<EnumRole> roleList) {
|
|
||||||
super();
|
|
||||||
this.email = email;
|
|
||||||
this.password = password;
|
|
||||||
this.roleList = roleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Personne(String nom, String prenom, String email, String password) {
|
|
||||||
super();
|
|
||||||
this.nom = nom;
|
|
||||||
this.prenom = prenom;
|
|
||||||
this.email = email;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_personne")
|
@Column(name = "id_personne")
|
||||||
public int getId() {
|
private int id;
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
public void setNom(String nom) {
|
|
||||||
this.nom = nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String getPrenom() {
|
private String nom;
|
||||||
return prenom;
|
|
||||||
}
|
|
||||||
public void setPrenom(String prenom) {
|
|
||||||
this.prenom = prenom;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String getEmail() {
|
private String prenom;
|
||||||
return email;
|
|
||||||
}
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String getPassword() {
|
private String email;
|
||||||
return password;
|
|
||||||
}
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
|
@Column(nullable = false)
|
||||||
//@JsonIgnore
|
private String password;
|
||||||
public Collection<Preference> getPreference() {
|
|
||||||
return preference;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
|
||||||
|
//@JsonIgnore
|
||||||
|
@Builder.Default
|
||||||
|
private Collection<Preference> preference = new ArrayList<>();
|
||||||
|
|
||||||
public void setPreference(Collection<Preference> preference) {
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
this.preference = preference;
|
@Enumerated(EnumType.STRING)
|
||||||
}
|
private List<EnumRole> roleList;
|
||||||
|
|
||||||
|
|
||||||
@ElementCollection(fetch = FetchType.EAGER)
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
public List<EnumRole> getRoleList() {
|
|
||||||
return roleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setRoleList(List<EnumRole> roleList) {
|
|
||||||
this.roleList = roleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package fr.vincent.ramiere.mangerautourdesimplonback.models;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class PersonneTest {
|
||||||
|
@Test
|
||||||
|
void testBuilder() {
|
||||||
|
Personne p = Personne.builder().nom("Test").prenom("Test").email("t@t.fr").password("1234").build();
|
||||||
|
assertEquals("Test", p.getNom());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue