Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alvaro Ordóñez Romero
/
DAE-aha00026-aor00039
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
1d067715
authored
Dec 14, 2023
by
Alvaro Ordóñez Romero
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Modificaciones tests
parent
3f6749d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
89 deletions
src/test/java/com/carpooling/carpoolingaoraha/entidades/SistemaCarPoolingTest.java
src/test/java/com/carpooling/carpoolingaoraha/entidades/UsuarioTest.java
src/test/java/com/carpooling/carpoolingaoraha/services/ServicioCarPoolingTest.java
src/test/java/com/carpooling/carpoolingaoraha/entidades/SistemaCarPoolingTest.java
deleted
100644 → 0
View file @
3f6749d0
package
com
.
carpooling
.
carpoolingaoraha
.
entidades
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
static
org
.
junit
.
Assert
.*;
public
class
SistemaCarPoolingTest
{
private
SistemaCarPooling
sistema
;
@Before
public
void
setUp
()
{
sistema
=
new
SistemaCarPooling
();
}
@Test
public
void
testAddViaje
()
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
fecha
=
dateFormat
.
parse
(
"2023-10-07"
);
Viaje
viaje
=
new
Viaje
(
"Origen"
,
"Destino"
,
fecha
,
3
,
10
,
5
);
sistema
.
addViaje
(
viaje
);
assertTrue
(
sistema
.
getViajes
().
contains
(
viaje
));
}
@Test
public
void
testAddReserva
()
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
fecha
=
dateFormat
.
parse
(
"2023-10-07"
);
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
Viaje
viaje
=
new
Viaje
(
"Origen"
,
"Destino"
,
fecha
,
3
,
10
,
5
);
sistema
.
addViaje
(
viaje
);
Usuario
usuario
=
new
Usuario
(
"usuario"
,
"usuario"
,
fecha
,
"78162640S"
,
957634276
,
"aor00039@red.ujaen.es"
,
"12345"
,
Usuario
.
Rol
.
CONDUCTOR
,
sistema
);
Reserva
reserva
=
new
Reserva
(
usuario
,
"origen"
,
"destino"
,
fecha
,
3
,
10
);
sistema
.
addReserva
(
reserva
);
assertTrue
(
sistema
.
getReservas
().
contains
(
reserva
));
}
@Test
public
void
testGetNombre
()
{
assertEquals
(
"Blablacar"
,
sistema
.
getNombre
());
}
@Test
public
void
testSetNombre
()
{
sistema
.
setNombre
(
"NuevoNombre"
);
assertEquals
(
"NuevoNombre"
,
sistema
.
getNombre
());
}
@Test
public
void
testGetUsuarios
()
{
assertNotNull
(
sistema
.
getUsuarios
());
}
@Test
public
void
testGetViajes
()
{
assertNotNull
(
sistema
.
getViajes
());
}
@Test
public
void
testGetReservas
()
{
assertNotNull
(
sistema
.
getReservas
());
}
}
src/test/java/com/carpooling/carpoolingaoraha/entidades/UsuarioTest.java
View file @
1d067715
...
...
@@ -11,9 +11,7 @@ import com.carpooling.carpoolingaoraha.entidades.Usuario.Rol;
public
class
UsuarioTest
{
@Test
public
void
testCambiarRol
()
{
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
Usuario
usuario
=
new
Usuario
(
"Nombre"
,
"Apellidos"
,
new
Date
(),
"12345678A"
,
123456789
,
"correo@example.com"
,
"clave"
,
CONDUCTOR
,
sis
);
public
void
testCambiarRol
()
{
Usuario
usuario
=
new
Usuario
(
"Nombre"
,
"Apellidos"
,
new
Date
(),
"12345678A"
,
123456789
,
"correo@example.com"
,
"clave"
,
CONDUCTOR
);
assertEquals
(
CONDUCTOR
,
usuario
.
getRol
());
...
...
@@ -25,8 +23,7 @@ public class UsuarioTest {
@Test
public
void
testOfrecerViaje
()
{
// Configuración inicial
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
Usuario
conductor
=
new
Usuario
(
"Conductor"
,
"ApellidoConductor"
,
new
Date
(),
"12345678A"
,
123456789
,
"conductor@example.com"
,
"clave"
,
CONDUCTOR
,
sis
);
Usuario
conductor
=
new
Usuario
(
"Conductor"
,
"ApellidoConductor"
,
new
Date
(),
"12345678A"
,
123456789
,
"conductor@example.com"
,
"clave"
,
CONDUCTOR
);
// Acción: Intentar ofrecer un viaje
boolean
exito
=
conductor
.
ofrecerViaje
(
"Origen"
,
"Destino"
,
new
Date
(),
3
,
20
);
...
...
@@ -40,9 +37,8 @@ public class UsuarioTest {
@Test
public
void
testAsignarPuntuacion
()
{
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
Usuario
conductor
=
new
Usuario
(
"Conductor"
,
"ApellidoConductor"
,
new
Date
(),
"12345678A"
,
123456789
,
"conductor@example.com"
,
"clave"
,
CONDUCTOR
,
sis
);
Usuario
pasajero
=
new
Usuario
(
"Pasajero"
,
"ApellidoPasajero"
,
new
Date
(),
"87654321B"
,
987654321
,
"pasajero@example.com"
,
"clave"
,
Rol
.
PASAJERO
,
sis
);
Usuario
conductor
=
new
Usuario
(
"Conductor"
,
"ApellidoConductor"
,
new
Date
(),
"12345678A"
,
123456789
,
"conductor@example.com"
,
"clave"
,
CONDUCTOR
);
Usuario
pasajero
=
new
Usuario
(
"Pasajero"
,
"ApellidoPasajero"
,
new
Date
(),
"87654321B"
,
987654321
,
"pasajero@example.com"
,
"clave"
,
Rol
.
PASAJERO
);
assertTrue
(
conductor
.
asignarPuntuacion
(
1
,
"87654321B"
,
4
));
...
...
@@ -52,8 +48,7 @@ public class UsuarioTest {
@Test
public
void
testBuscarViaje
()
{
// Inicializar un usuario de ejemplo
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
Usuario
usuario
=
new
Usuario
(
"Nombre"
,
"Apellidos"
,
new
Date
(),
"123456789"
,
123456789
,
"usuario@example.com"
,
"clave"
,
Rol
.
PASAJERO
,
sis
);
Usuario
usuario
=
new
Usuario
(
"Nombre"
,
"Apellidos"
,
new
Date
(),
"123456789"
,
123456789
,
"usuario@example.com"
,
"clave"
,
Rol
.
PASAJERO
);
// Inicializar la lista de viajes con datos de ejemplo
List
<
Viaje
>
todosLosViajes
=
new
ArrayList
<>();
...
...
src/test/java/com/carpooling/carpoolingaoraha/services/ServicioCarPoolingTest.java
View file @
1d067715
...
...
@@ -49,9 +49,8 @@ public class ServicioCarPoolingTest
sb
.
append
(
randomChar
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
java
.
util
.
Date
yourDate
=
sdf
.
parse
(
"1992-07-26"
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
"78162640S"
,
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
,
sis
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
"78162640S"
,
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
);
Usuario
usuarioGuardado
=
servicio
.
altaCliente
(
usuario
);
assertNotNull
(
usuarioGuardado
);
...
...
@@ -89,7 +88,7 @@ public class ServicioCarPoolingTest
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
java
.
util
.
Date
yourDate
=
sdf
.
parse
(
"1992-07-26"
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
,
new
SistemaCarPooling
()
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
);
servicio
.
altaCliente
(
usuario
);
// Modificar los datos del usuario
...
...
@@ -142,7 +141,6 @@ public class ServicioCarPoolingTest
Random
r
=
new
Random
();
int
idReserva
=
r
.
nextInt
(
10000000
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
java
.
util
.
Date
yourDate
=
sdf
.
parse
(
"2025-12-03"
);
Viaje
v
=
new
Viaje
(
"origen"
,
"destino"
,
yourDate
,
3
,
20
,
idReserva
);
Viaje
viajePrueba
=
servicio
.
altaViaje
(
v
);
...
...
@@ -201,7 +199,7 @@ public class ServicioCarPoolingTest
Usuario
usuario
=
new
Usuario
();
usuario
.
setDNI
(
dni
);
servicio
.
altaCliente
(
usuario
);
Reserva
reserva
=
servicio
.
crearReserva
(
dni
);
Reserva
reserva
=
servicio
.
crearReserva
(
dni
,
new
Reserva
()
);
assertNotNull
(
reserva
);
...
...
@@ -215,7 +213,7 @@ public class ServicioCarPoolingTest
Usuario
usuario
=
new
Usuario
();
usuario
.
setDNI
(
dni
);
servicio
.
altaCliente
(
usuario
);
Reserva
reserva
=
servicio
.
crearReserva
(
dni
);
Reserva
reserva
=
servicio
.
crearReserva
(
dni
,
new
Reserva
()
);
Solicitud
s
=
servicio
.
crearSolicitud
(
dni
,
reserva
.
getIdReserva
());
assertNotNull
(
s
);
...
...
@@ -239,9 +237,8 @@ public class ServicioCarPoolingTest
sb
.
append
(
randomChar
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
java
.
util
.
Date
yourDate
=
sdf
.
parse
(
"1992-07-26"
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
,
sis
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Rol
.
PASAJERO
);
Usuario
usuarioGuardado
=
servicio
.
altaCliente
(
usuario
);
String
dni
=
sb
.
toString
();
double
nuevaPuntuacion
=
5
;
...
...
@@ -269,13 +266,12 @@ public class ServicioCarPoolingTest
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SistemaCarPooling
sis
=
new
SistemaCarPooling
();
java
.
util
.
Date
yourDate
=
sdf
.
parse
(
"1992-07-26"
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Usuario
.
Rol
.
PASAJERO
,
new
SistemaCarPooling
()
);
Usuario
usuario
=
new
Usuario
(
"Perico"
,
"Alonso"
,
yourDate
,
sb
.
toString
(),
670988953
,
"aor00039@red.ujaen.es"
,
"hola"
,
Usuario
.
Rol
.
PASAJERO
);
servicio
.
altaCliente
(
usuario
);
int
idReserva
=
1
;
Reserva
reserva
=
servicio
.
crearReserva
(
usuario
.
getDNI
());
Reserva
reserva
=
servicio
.
crearReserva
(
usuario
.
getDNI
()
,
new
Reserva
()
);
// Prueba de unirse a la reserva
assertTrue
(
servicio
.
unirseAReserva
(
usuario
.
getDNI
(),
idReserva
));
...
...
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