Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Antonio Rueda
/
reserva-hoteles
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b858f151
authored
Oct 02, 2024
by
Antonio Rueda
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Test de creación de usuarios inválidos
parent
e8f6ca7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
src/test/java/es/ujaen/dae/reservahoteles/servicios/TestServicioReservas.java
src/test/java/es/ujaen/dae/reservahoteles/servicios/TestServicioReservas.java
View file @
b858f151
...
...
@@ -3,9 +3,12 @@ package es.ujaen.dae.reservahoteles.servicios;
import
es.ujaen.dae.reservahoteles.entidades.Cliente
;
import
es.ujaen.dae.reservahoteles.entidades.Hotel
;
import
es.ujaen.dae.reservahoteles.excepciones.ClienteYaRegistrado
;
import
jakarta.validation.ConstraintViolationException
;
import
java.time.LocalDate
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatThrownBy
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -24,6 +27,20 @@ public class TestServicioReservas {
@Test
@DirtiesContext
void
testNuevoClienteInvalido
()
{
// Test con teléfono e email inválidos
var
cliente
=
new
Cliente
(
"Pedro"
,
"Jaén Jaén"
,
"611225"
,
"pjaengmail.com"
,
"miClAvE"
);
assertThatThrownBy
(()
->
servicio
.
nuevoCliente
(
cliente
)).
isInstanceOf
(
ConstraintViolationException
.
class
);
// Test de intento de creación repetido
var
cliente2
=
new
Cliente
(
"Pedro"
,
"Jaén Jaén"
,
"611301114"
,
"pjaen@gmail.com"
,
"miClAvE"
);
servicio
.
nuevoCliente
(
cliente2
);
assertThatThrownBy
(()
->
servicio
.
nuevoCliente
(
cliente2
)).
isInstanceOf
(
ClienteYaRegistrado
.
class
);
}
@Test
@DirtiesContext
void
testLoginCliente
()
{
var
cliente
=
new
Cliente
(
"Pedro"
,
"Jaén Jaén"
,
"611203025"
,
"pjaen@gmail.com"
,
"miClAvE"
);
servicio
.
nuevoCliente
(
cliente
);
...
...
@@ -60,8 +77,8 @@ public class TestServicioReservas {
servicio
.
nuevoHotel
(
hotel3
);
List
<
Hotel
>
hoteles
=
servicio
.
buscarHotelesDisponiblesPorLocalidad
(
"almeria"
,
LocalDate
.
now
().
plus
Weeks
(
2
),
LocalDate
.
now
().
plus
Weeks
(
2
).
plusDays
(
2
),
LocalDate
.
now
().
plus
Days
(
7
),
LocalDate
.
now
().
plus
Days
(
9
),
0
,
2
);
assertThat
(
hoteles
).
hasSize
(
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment