Skip to content

Commit

Permalink
Merge branch 'main' into asvs-new-feats
Browse files Browse the repository at this point in the history
MiguelFerreira18 authored May 17, 2024
2 parents 94caac6 + d932956 commit b7a0218
Showing 22 changed files with 2,167 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
public class EncomendaDTOPatchRequest {

@NotNull
@Positive
private Long encomendaId;

@Min(value = 1, message = "Número de refeições por semana inválido")
@@ -31,8 +32,10 @@ public class EncomendaDTOPatchRequest {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime dataEncomenda;
@NotNull
@Positive
private Long pacoteId;
@NotNull
@Positive
private Long userId;

private Estado estado;
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@

public class EncomendaDTOResponse {

@NotNull
@Positive
private Long encomendaId;
@Min(value = 1, message = "Número de refeições por semana inválido")
@Max(value = 7, message = "Número de refeições por semana inválido")
Original file line number Diff line number Diff line change
@@ -30,8 +30,10 @@ public class EncomendaDTOSaveRequest {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime dataEncomenda;
@NotNull
@Positive
private Long pacoteId;
@NotNull
@Positive
private Long userId;

private Estado estado;
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

public class EncomendaDTOServicePatchRequest {
@NotNull
@Positive
private Long encomendaId;

@Min(value = 1, message = "Número de refeições por semana inválido")
@@ -28,8 +29,10 @@ public class EncomendaDTOServicePatchRequest {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime dataEncomenda;
@NotNull
@Positive
private Long pacoteId;
@NotNull
@Positive
private Long userId;


Original file line number Diff line number Diff line change
@@ -25,8 +25,10 @@ public class EncomendaDTOServiceRequest {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime dataEncomenda;
@NotNull
@Positive
private Long pacoteId;
@NotNull
@Positive
private Long userId;


Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
public class EncomendaDTOServiceResponse {

@NotNull
@Positive
private Long encomendaId;
@Min(value = 1, message = "Número de refeições por semana inválido")
@Max(value = 7, message = "Número de refeições por semana inválido")
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@

public class EncomendaPatchDTOService {
@NotNull
@Positive
private Long encomendaId;

@Min(value = 1, message = "Número de refeições por semana inválido")
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
public class PacoteDTOPatchRequest {

@NotNull
@Positive
private final Long pacoteId;


@@ -14,7 +15,6 @@ public class PacoteDTOPatchRequest {
@Size(max = 16, message = "Nome do pacote inválido")
private final String nome;

@NotBlank
@Min(value = 0, message = "Preço base do pacote inválido")
@Max(value = 500, message = "Preço base do pacote inválido")
private final double pacoteBasePrice;
@@ -25,6 +25,8 @@ public class PacoteDTOPatchRequest {
private final String pacoteDescription;

private final boolean disabled;
@Positive
@NotNull
private final Long tipoPacote;

public PacoteDTOPatchRequest(Long pacoteId,String nome, double pacoteBasePrice, String pacoteDescription, boolean disabled, Long tipoPacote) {
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ public class PacoteDTOSaveRequest {
private final String pacoteDescription;

private final boolean disabled;
@NotNull
@Positive
private final Long tipoPacote;

public PacoteDTOSaveRequest(String nome, double pacoteBasePrice, String pacoteDescription, boolean disabled, Long tipoPacote) {
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

public class PacoteDTOServicePatchRequest {
@NotNull
@Positive
private final Long pacoteId;


@@ -24,6 +25,8 @@ public class PacoteDTOServicePatchRequest {
private final String pacoteDescription;

private final boolean disabled;
@Positive
@NotNull
private final Long tipoPacote;

public PacoteDTOServicePatchRequest(Long pacoteId,String nome, double pacoteBasePrice, String pacoteDescription, boolean disabled, Long tipoPacote) {
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@ public class PacoteDTOServiceRequest {
private final String pacoteDescription;

private final boolean disabled;
@Positive
@NotNull
private final Long tipoPacote;

public PacoteDTOServiceRequest(String nome, double pacoteBasePrice, String pacoteDescription, boolean disabled, Long tipoPacote) {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
public class PacotePatchDTOService {

@NotNull
@Positive
private final Long pacoteId;


Original file line number Diff line number Diff line change
@@ -19,8 +19,10 @@ public class ReviewDTOPatchRequest {
private final int rating;

@NotNull
@Positive
private final Long user;
@NotNull
@Positive
private final Long pacote;

public ReviewDTOPatchRequest(Long reviewId,String reviewText, int rating, Long user, Long pacote) {
Original file line number Diff line number Diff line change
@@ -16,8 +16,10 @@ public class ReviewDTOSaveRequest {
private final int rating;

@NotNull
@Positive
private final Long user;
@NotNull
@Positive
private final Long pacote;

public ReviewDTOSaveRequest(String reviewText, int rating, Long user, Long pacote) {
Original file line number Diff line number Diff line change
@@ -19,8 +19,10 @@ public class ReviewDTOServicePatchRequest {
private final int rating;

@NotNull
@Positive
private final Long user;
@NotNull
@Positive
private final Long pacote;

public ReviewDTOServicePatchRequest(Long reviewId,String reviewText, int rating, Long user, Long pacote) {
Original file line number Diff line number Diff line change
@@ -7,10 +7,7 @@
import isep.ipp.pt.api.desofs.Model.TipoPacote;
import isep.ipp.pt.api.desofs.Model.UserModel.Role;
import isep.ipp.pt.api.desofs.Model.UserModel.User;
import isep.ipp.pt.api.desofs.Repository.Interface.EncomendaServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.PacoteServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.TipoPacoteServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.UserServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.*;
import isep.ipp.pt.api.desofs.Service.EncomendaService.EncomendaService;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
@@ -41,9 +38,15 @@ class EncomendaControllerTest {

@Autowired
private UserServiceRepo userRepo;
@Autowired
private ReviewServiceRepo reviewServiceRepo;
@Autowired
private ReceitaServiceRepo receitaServiceRepo;

@BeforeEach
public void populate() {
receitaServiceRepo.deleteAll();
reviewServiceRepo.deleteAll();
encomendaRepo.deleteAll();
pacoteRepo.deleteAll();
userRepo.deleteAll();
@@ -60,6 +63,8 @@ public void populate() {

@AfterEach
public void clean() {
receitaServiceRepo.deleteAll();
reviewServiceRepo.deleteAll();
encomendaRepo.deleteAll();
pacoteRepo.deleteAll();
userRepo.deleteAll();
Original file line number Diff line number Diff line change
@@ -4,9 +4,7 @@
import isep.ipp.pt.api.desofs.Dto.PacoteDTO.ControllerLayer.PacoteDTOSaveRequest;
import isep.ipp.pt.api.desofs.Model.Pacote;
import isep.ipp.pt.api.desofs.Model.TipoPacote;
import isep.ipp.pt.api.desofs.Repository.Interface.PacoteServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.ReviewServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.TipoPacoteServiceRepo;
import isep.ipp.pt.api.desofs.Repository.Interface.*;
import isep.ipp.pt.api.desofs.Service.PacoteService.PacoteService;
import org.apache.catalina.core.ApplicationContext;
import org.junit.jupiter.api.*;
@@ -32,10 +30,16 @@ class PacoteControllerTest {
private TipoPacoteServiceRepo tipoPacoteServiceRepo;
@Autowired
private ReviewServiceRepo reviewServiceRepo;
@Autowired
private EncomendaServiceRepo encomendaServiceRepo;

@Autowired
private ReceitaServiceRepo receitaServiceRepo;

@BeforeEach
public void setUp() {
receitaServiceRepo.deleteAll();
encomendaServiceRepo.deleteAll();
reviewServiceRepo.deleteAll();
pacoteServiceRepo.deleteAll();
TipoPacote tp1 = new TipoPacote(1L, "TugaTube");
@@ -45,6 +49,9 @@ public void setUp() {

@AfterEach
public void tearDown() {
receitaServiceRepo.deleteAll();
encomendaServiceRepo.deleteAll();
reviewServiceRepo.deleteAll();
pacoteServiceRepo.deleteAll();
tipoPacoteServiceRepo.deleteAll();
}
Original file line number Diff line number Diff line change
@@ -8,13 +8,15 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Collections;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when;

@SpringBootTest
class PersonalValidationTest {

private PersonalValidation personalValidation;
Loading

0 comments on commit b7a0218

Please sign in to comment.