Skip to content
Snippets Groups Projects
Commit 39e02d02 authored by Abdellatif Kebraoui's avatar Abdellatif Kebraoui
Browse files

[REFAC] Update client repository structure and improve code consistency

parent 66103a00
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org</groupId>
......@@ -73,6 +75,12 @@
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.27</version>
</dependency>
</dependencies>
<build>
......
......@@ -3,7 +3,8 @@ package com.miage.glop;
import com.miage.glop.beneficiary.Beneficiary;
import com.miage.glop.beneficiary.BeneficiaryRepo;
import com.miage.glop.client.Client;
import com.miage.glop.client.ClientRepo;
import com.miage.glop.client.ClientRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
......@@ -11,11 +12,11 @@ import org.springframework.stereotype.Component;
@Component
public class DataInitializer implements CommandLineRunner {
private final ClientRepo clientRepo;
private final ClientRepository clientRepo;
private final BeneficiaryRepo beneficiaryRepo;
@Autowired
public DataInitializer(ClientRepo clientRepo, BeneficiaryRepo beneficiaryRepo) {
public DataInitializer(ClientRepository clientRepo, BeneficiaryRepo beneficiaryRepo) {
this.clientRepo = clientRepo;
this.beneficiaryRepo = beneficiaryRepo;
}
......
......@@ -5,7 +5,6 @@ import com.miage.glop.typeOfTransport.TypeOfTransport;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
......@@ -36,50 +35,40 @@ public class Client {
this.typeOfTransports = new ArrayList<>();
}
// Getters and setters...
public String getIdAuth() {
return idAuth;
}
public void setIdAuth(String idAuth) {
this.idAuth = idAuth;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public List<Beneficiary> getBeneficiaries() {
return beneficiaries;
}
public void setBeneficiaries(List<Beneficiary> beneficiaries) {
this.beneficiaries = beneficiaries;
}
public List<TypeOfTransport> getTypeOfTransports() {
return typeOfTransports;
}
public void setTypeOfTransports(List<TypeOfTransport> typeOfTransports) {
this.typeOfTransports = typeOfTransports;
}
......
......@@ -5,7 +5,6 @@ import com.miage.glop.beneficiary.BeneficiaryService;
import com.miage.glop.typeOfTransport.TypeOfTransport;
import com.miage.glop.typeOfTransport.TypeOfTransportService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
......@@ -22,7 +21,6 @@ public class ClientController {
private final BeneficiaryService beneficiaryService;
private final TypeOfTransportService typeOfTransportService;
@Autowired
public ClientController(ClientService clientService, BeneficiaryService beneficiaryService, TypeOfTransportService typeOfTransportService){
this.clientService = clientService;
this.beneficiaryService = beneficiaryService;
......
......@@ -4,5 +4,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ClientRepo extends JpaRepository<Client, String> {
public interface ClientRepository extends JpaRepository<Client, String> {
}
\ No newline at end of file
package com.miage.glop.client;
import com.miage.glop.exception.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -9,10 +8,9 @@ import java.util.List;
@Service
public class ClientServiceImpl implements ClientService {
private final ClientRepo clientRepo;
private final ClientRepository clientRepo;
@Autowired
public ClientServiceImpl(ClientRepo clientRepo){
public ClientServiceImpl(ClientRepository clientRepo){
this.clientRepo = clientRepo;
}
......
......@@ -5,7 +5,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import java.util.Collections;
......@@ -20,7 +19,7 @@ class ClientServiceTest {
private ClientServiceImpl clientService;
@Autowired
private ClientRepo clientRepo;
private ClientRepository clientRepo;
private Client client;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment