Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rubén Ramírez
/
MangAffinity
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
44d94794
authored
Apr 20, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [TestServicioBibliotecaPersonal]: Testeadas las funciones para la gestión de favoritos
parent
07b3f3a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
src/test/java/com/ujaen/tfg/mangaffinity/servicios/TestServicioBibliotecaPersonal.java
src/test/java/com/ujaen/tfg/mangaffinity/servicios/TestServicioBibliotecaPersonal.java
View file @
44d94794
...
...
@@ -202,4 +202,65 @@ public class TestServicioBibliotecaPersonal {
assertThat
(
resultadoInexistente
).
isEmpty
();
}
@Test
@DirtiesContext
void
testAnadirFavorito
()
{
// Creo usuario y recurso
Usuario
usuario
=
new
Usuario
(
"fav@correo.com"
,
"usuarioFav"
,
"claveFav"
);
servicioUsuarios
.
crearUsuario
(
usuario
);
BibliotecaPersonal
biblioteca
=
usuario
.
getBibliotecaPersonal
();
Recurso
recurso
=
new
Recurso
(
"Manga Favorito"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
new
byte
[
0
]);
servicioRecursos
.
crearRecurso
(
recurso
);
Long
recursoId
=
servicioRecursos
.
buscarRecursoPorTitulo
(
"Manga Favorito"
).
getFirst
().
getId
();
// Añadir a favoritos
servicioBibliotecaPersonal
.
anadirFavorito
(
biblioteca
.
getId
(),
recursoId
);
List
<
Long
>
favoritos
=
servicioBibliotecaPersonal
.
obtenerFavoritos
(
biblioteca
.
getId
());
assertThat
(
favoritos
).
containsExactly
(
recursoId
);
}
@Test
@DirtiesContext
void
testEliminarFavorito
()
{
// Setup
Usuario
usuario
=
new
Usuario
(
"quitar@correo.com"
,
"usuarioQ"
,
"claveQ"
);
servicioUsuarios
.
crearUsuario
(
usuario
);
BibliotecaPersonal
biblioteca
=
usuario
.
getBibliotecaPersonal
();
Recurso
recurso
=
new
Recurso
(
"Manga Eliminar"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
new
byte
[
0
]);
servicioRecursos
.
crearRecurso
(
recurso
);
Long
recursoId
=
servicioRecursos
.
buscarRecursoPorTitulo
(
"Manga Eliminar"
).
getFirst
().
getId
();
servicioBibliotecaPersonal
.
anadirFavorito
(
biblioteca
.
getId
(),
recursoId
);
assertThat
(
servicioBibliotecaPersonal
.
obtenerFavoritos
(
biblioteca
.
getId
())).
contains
(
recursoId
);
// Eliminar
servicioBibliotecaPersonal
.
eliminarFavorito
(
biblioteca
.
getId
(),
recursoId
);
assertThat
(
servicioBibliotecaPersonal
.
obtenerFavoritos
(
biblioteca
.
getId
())).
doesNotContain
(
recursoId
);
}
@Test
@DirtiesContext
void
testObtenerFavoritos
()
{
Usuario
usuario
=
new
Usuario
(
"ver@correo.com"
,
"usuarioVer"
,
"claveVer"
);
servicioUsuarios
.
crearUsuario
(
usuario
);
BibliotecaPersonal
biblioteca
=
usuario
.
getBibliotecaPersonal
();
Recurso
r1
=
new
Recurso
(
"Manga A"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
new
byte
[
0
]);
Recurso
r2
=
new
Recurso
(
"Manga B"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
new
byte
[
0
]);
servicioRecursos
.
crearRecurso
(
r1
);
servicioRecursos
.
crearRecurso
(
r2
);
Long
id1
=
servicioRecursos
.
buscarRecursoPorTitulo
(
"Manga A"
).
getFirst
().
getId
();
Long
id2
=
servicioRecursos
.
buscarRecursoPorTitulo
(
"Manga B"
).
getFirst
().
getId
();
servicioBibliotecaPersonal
.
anadirFavorito
(
biblioteca
.
getId
(),
id1
);
servicioBibliotecaPersonal
.
anadirFavorito
(
biblioteca
.
getId
(),
id2
);
List
<
Long
>
favoritos
=
servicioBibliotecaPersonal
.
obtenerFavoritos
(
biblioteca
.
getId
());
assertThat
(
favoritos
).
containsExactlyInAnyOrder
(
id1
,
id2
);
}
}
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