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
06821446
authored
Apr 18, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [TestRecursosController]: Actualizados los test por las modificaciones en el dto y recurso
parent
c48f6391
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
20 deletions
src/test/java/com/ujaen/tfg/mangaffinity/rest/TestRecursosController.java
src/test/java/com/ujaen/tfg/mangaffinity/rest/TestRecursosController.java
View file @
06821446
...
...
@@ -56,7 +56,8 @@ public class TestRecursosController {
//Intento crear un recurso correctamente con autenticación de admin
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
formData
.
add
(
"recurso"
,
new
DTORecurso
(
null
,
"Titulo Prueba"
,
"Descripción de prueba"
,
LocalDate
.
now
(),
"Autor Prueba"
,
null
,
new
HashSet
<>()));
formData
.
add
(
"recurso"
,
new
DTORecurso
(
null
,
"Titulo Prueba"
,
"Descripción de prueba"
,
LocalDate
.
now
(),
"Autor Prueba"
,
null
,
new
HashSet
<>(),
0.0
));
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
@Override
public
String
getFilename
()
{
...
...
@@ -96,7 +97,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso con tipos"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>()
null
,
"Recurso con tipos"
,
"Desc"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -153,7 +155,8 @@ public class TestRecursosController {
assertThat
(
respuesta404
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
// Recurso sin capítulos
DTORecurso
vacio
=
new
DTORecurso
(
null
,
"Vacio"
,
"No tiene caps"
,
LocalDate
.
now
(),
"Autor2"
,
null
,
new
HashSet
<>());
DTORecurso
vacio
=
new
DTORecurso
(
null
,
"Vacio"
,
"No tiene caps"
,
LocalDate
.
now
(),
"Autor2"
,
null
,
new
HashSet
<>(),
0.0
);
MultiValueMap
<
String
,
Object
>
datosVacios
=
new
LinkedMultiValueMap
<>();
datosVacios
.
add
(
"recurso"
,
vacio
);
datosVacios
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -196,7 +199,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
recursoDTO
=
new
DTORecurso
(
null
,
"Dragon Ball"
,
"Manga de peleas"
,
LocalDate
.
of
(
1984
,
11
,
20
),
"Akira Toriyama"
,
null
,
new
HashSet
<>(
Collections
.
singleton
(
Genero
.
ACCION
)));
new
HashSet
<>(
Collections
.
singleton
(
Genero
.
ACCION
)),
0.0
);
formData
.
add
(
"recurso"
,
recursoDTO
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -263,7 +267,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Titulo Prueba"
,
"Descripción de prueba"
,
LocalDate
.
now
(),
"Autor Prueba"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -323,7 +328,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Titulo Buscado"
,
"Descripción"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -413,7 +419,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso para borrar"
,
"Descripción"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -479,7 +486,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Titulo Original"
,
"Descripción Original"
,
LocalDate
.
of
(
2022
,
5
,
10
),
"Autor Original"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -505,7 +513,8 @@ public class TestRecursosController {
// Modificar todos los campos (SIN modificar la foto)
DTORecurso
nuevosDatos
=
new
DTORecurso
(
recursoId
,
"Titulo Modificado"
,
"Descripción Modificada"
,
LocalDate
.
of
(
2024
,
1
,
1
),
"Autor Modificado"
,
null
,
new
HashSet
<>(
Set
.
of
(
Genero
.
ACCION
,
Genero
.
AVENTURA
)));
new
HashSet
<>(
Set
.
of
(
Genero
.
ACCION
,
Genero
.
AVENTURA
)),
0.0
);
MultiValueMap
<
String
,
Object
>
updateFormData
=
new
LinkedMultiValueMap
<>();
updateFormData
.
add
(
"recurso"
,
nuevosDatos
);
...
...
@@ -535,7 +544,8 @@ public class TestRecursosController {
// Intento modificar un recurso que NO existe
DTORecurso
datosFalsos
=
new
DTORecurso
(
null
,
"Titulo Inexistente"
,
"Descripción"
,
LocalDate
.
of
(
2024
,
1
,
1
),
"Autor"
,
null
,
new
HashSet
<>(
Set
.
of
(
Genero
.
DRAMA
)));
LocalDate
.
of
(
2024
,
1
,
1
),
"Autor"
,
null
,
new
HashSet
<>(
Set
.
of
(
Genero
.
DRAMA
)),
0.0
);
MultiValueMap
<
String
,
Object
>
fakeFormData
=
new
LinkedMultiValueMap
<>();
fakeFormData
.
add
(
"recurso"
,
datosFalsos
);
...
...
@@ -597,7 +607,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
recursoDTO
=
new
DTORecurso
(
null
,
"Bleach"
,
"Shinigamis y hollows"
,
LocalDate
.
of
(
2001
,
8
,
7
),
"Tite Kubo"
,
null
,
new
HashSet
<>(
Set
.
of
(
Genero
.
ACCION
)));
new
HashSet
<>(
Set
.
of
(
Genero
.
ACCION
)),
0.0
);
formData
.
add
(
"recurso"
,
recursoDTO
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -648,7 +659,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Naruto"
,
"Ninjas"
,
LocalDate
.
of
(
1999
,
9
,
21
),
"Masashi Kishimoto"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -712,7 +724,8 @@ public class TestRecursosController {
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Fullmetal Alchemist"
,
"Alquimia y acción"
,
LocalDate
.
of
(
2001
,
1
,
1
),
"Hiromu Arakawa"
,
null
,
new
HashSet
<>()
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -753,7 +766,8 @@ public class TestRecursosController {
assertThat
(
respuesta
.
getBody
()[
0
].
getTitulo
()).
isEqualTo
(
"Capítulo 1"
);
// Creo otro recurso sin añadir capítulos
DTORecurso
sinCaps
=
new
DTORecurso
(
null
,
"Vacío"
,
"Sin capítulos"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>());
DTORecurso
sinCaps
=
new
DTORecurso
(
null
,
"Vacío"
,
"Sin capítulos"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>(),
0.0
);
formData
.
set
(
"recurso"
,
sinCaps
);
var
sinCapsResponse
=
restTemplate
.
exchange
(
"/recursos/"
,
HttpMethod
.
POST
,
crearRequest
,
Void
.
class
);
assertThat
(
sinCapsResponse
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
CREATED
);
...
...
@@ -791,7 +805,8 @@ public class TestRecursosController {
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
token
);
headers
.
setContentType
(
MediaType
.
MULTIPART_FORM_DATA
);
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso ModCap"
,
"desc"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>());
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso ModCap"
,
"desc"
,
LocalDate
.
now
(),
"Autor"
,
null
,
new
HashSet
<>(),
0.0
);
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -870,7 +885,8 @@ public class TestRecursosController {
headers
.
setContentType
(
MediaType
.
MULTIPART_FORM_DATA
);
DTORecurso
recursoDTO
=
new
DTORecurso
(
null
,
"One Piece"
,
"Manga"
,
LocalDate
.
of
(
1997
,
7
,
22
),
"Eiichiro Oda"
,
null
,
new
HashSet
<>());
LocalDate
.
of
(
1997
,
7
,
22
),
"Eiichiro Oda"
,
null
,
new
HashSet
<>(),
0.0
);
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
formData
.
add
(
"recurso"
,
recursoDTO
);
...
...
@@ -968,7 +984,8 @@ public class TestRecursosController {
for
(
int
i
=
1
;
i
<=
5
;
i
++)
{
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso "
+
i
,
"Descripción "
+
i
,
LocalDate
.
now
(),
"Autor "
+
i
,
null
,
new
HashSet
<>()
null
,
"Recurso "
+
i
,
"Descripción "
+
i
,
LocalDate
.
now
(),
"Autor "
+
i
,
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -1015,7 +1032,8 @@ public class TestRecursosController {
for
(
int
i
=
6
;
i
<=
8
;
i
++)
{
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Recurso Sin Accesos "
+
i
,
"Descripción "
+
i
,
LocalDate
.
now
(),
"Autor "
+
i
,
null
,
new
HashSet
<>()
null
,
"Recurso Sin Accesos "
+
i
,
"Descripción "
+
i
,
LocalDate
.
now
(),
"Autor "
+
i
,
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
@@ -1067,8 +1085,18 @@ public class TestRecursosController {
// Creo un recurso
MultiValueMap
<
String
,
Object
>
formData
=
new
LinkedMultiValueMap
<>();
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Death Note"
,
"Shinigamis y cuadernos"
,
LocalDate
.
of
(
2003
,
12
,
1
),
"Tsugumi Ohba"
,
null
,
new
HashSet
<>());
DTORecurso
dtoRecurso
=
new
DTORecurso
(
null
,
"Death Note"
,
"Shinigamis y cuadernos"
,
LocalDate
.
of
(
2003
,
12
,
1
),
"Tsugumi Ohba"
,
null
,
new
HashSet
<>(),
0.0
);
formData
.
add
(
"recurso"
,
dtoRecurso
);
formData
.
add
(
"foto"
,
new
ByteArrayResource
(
new
byte
[
0
])
{
...
...
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