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
d37a0945
authored
Oct 07, 2023
by
Alvaro Ordóñez Romero
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Tests de la clase SistemaCarPooling
parent
82c97c12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
src/test/java/com/carpooling/carpoolingaoraha/entidades/SistemaCarPoolingTests.java
src/test/java/com/carpooling/carpoolingaoraha/entidades/SistemaCarPoolingTests.java
0 → 100644
View file @
d37a0945
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
SistemaCarPoolingTests
{
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
);
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"
);
Usuario
usuario
=
new
Usuario
(
"usuario"
,
"usuario"
,
fecha
,
"78162640S"
,
957634276
,
"aor00039@red.ujaen.es"
,
"12345"
,
Rol
.
CONDUCTOR
);
Reserva
reserva
=
new
Reserva
(
usuario
,
"origen"
,
"destino"
,
fecha
,
3
,
10
);
sistema
.
addReserva
(
reserva
);
assertTrue
(
sistema
.
getReservas
().
contains
(
reserva
));
}
@Test
public
void
testLoginSuccess
()
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
fecha
=
dateFormat
.
parse
(
"2023-10-07"
);
Usuario
usuario
=
new
Usuario
(
"usuario"
,
"usuario"
,
fecha
,
"78162640S"
,
957634276
,
"aor00039@red.ujaen.es"
,
"12345"
,
Rol
.
CONDUCTOR
);
sistema
.
getUsuarios
().
add
(
usuario
);
assertTrue
(
sistema
.
login
(
"aor00039@red.ujaen.es"
,
"12345"
));
}
@Test
public
void
testLoginFailure
()
{
assertFalse
(
sistema
.
login
(
"usuario2"
,
"claveincorrecta"
));
}
@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
());
}
}
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