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
f116e1bf
authored
Feb 24, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: [DTOBibliotecaPersonal]: Corregida errata
parent
4da14105
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
src/main/java/com/ujaen/tfg/mangaffinity/rest/DTO/DTOBibliotecaPersonal.java
src/test/java/com/ujaen/tfg/mangaffinity/rest/TestUsuariosController.java
src/main/java/com/ujaen/tfg/mangaffinity/rest/DTO/DTOBibliotecaPersonal.java
View file @
f116e1bf
package
com
.
ujaen
.
tfg
.
mangaffinity
.
rest
.
DTO
;
import
com.ujaen.tfg.mangaffinity.entidades.BibliotecaPersonal
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
@Getter
@NoArgsConstructor
public
class
DTOBibliotecaPersonal
{
private
Long
id
;
private
Long
usuarioId
;
...
...
src/test/java/com/ujaen/tfg/mangaffinity/rest/TestUsuariosController.java
View file @
f116e1bf
...
...
@@ -4,9 +4,7 @@ import com.ujaen.tfg.mangaffinity.MangAffinityApplication;
import
com.ujaen.tfg.mangaffinity.config.JpaTestConfig
;
import
com.ujaen.tfg.mangaffinity.entidades.BibliotecaPersonal
;
import
com.ujaen.tfg.mangaffinity.entidades.Usuario
;
import
com.ujaen.tfg.mangaffinity.rest.DTO.DTOLoginRespuesta
;
import
com.ujaen.tfg.mangaffinity.rest.DTO.DTOUsuario
;
import
com.ujaen.tfg.mangaffinity.rest.DTO.Mapper
;
import
com.ujaen.tfg.mangaffinity.rest.DTO.*
;
import
org.assertj.core.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,6 +15,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import
org.springframework.boot.test.web.server.LocalServerPort
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.*
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.security.web.SecurityFilterChain
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.ActiveProfiles
;
...
...
@@ -56,6 +55,8 @@ public class TestUsuariosController {
@Autowired
TestRestTemplate
restTemplateUsuarios
;
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@PostConstruct
...
...
@@ -192,7 +193,6 @@ public class TestUsuariosController {
assertThat
(
authResponse
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
String
token
=
"Bearer "
+
authResponse
.
getBody
().
getToken
();
ResponseEntity
<
Long
>
respuestaUsuarioId
=
restTemplate
.
exchange
(
"/usuarios/email/{email}"
,
HttpMethod
.
GET
,
null
,
Long
.
class
,
"usuario@example.com"
);
...
...
@@ -200,21 +200,28 @@ public class TestUsuariosController {
Long
usuarioId
=
respuestaUsuarioId
.
getBody
();
assertThat
(
usuarioId
).
isNotNull
();
// Verifico que la biblioteca personal se creó en la base de datos
boolean
bibliotecaExiste
=
jdbcTemplate
.
queryForObject
(
"SELECT COUNT(*) FROM biblioteca_personal WHERE usuario_id = ?"
,
Integer
.
class
,
usuarioId
)
>
0
;
assertThat
(
bibliotecaExiste
).
isTrue
();
// Obtengo la biblioteca personal del usuario
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
token
);
HttpEntity
<
Void
>
requestEntity
=
new
HttpEntity
<>(
headers
);
ResponseEntity
<
BibliotecaPersonal
>
respuestaBiblioteca
=
restTemplate
.
exchange
(
"/usuarios/{usuarioId}/biblioteca"
,
HttpMethod
.
GET
,
requestEntity
,
BibliotecaPersonal
.
class
,
usuarioId
ResponseEntity
<
DTO
BibliotecaPersonal
>
respuestaBiblioteca
=
restTemplate
.
exchange
(
"/usuarios/{usuarioId}/biblioteca"
,
HttpMethod
.
GET
,
requestEntity
,
DTO
BibliotecaPersonal
.
class
,
usuarioId
);
// Verifico la respuesta
assertThat
(
respuestaBiblioteca
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
respuestaBiblioteca
.
getBody
().
getUsuario
().
getId
()).
isEqualTo
(
usuarioId
);
assertThat
(
respuestaBiblioteca
.
getBody
()).
isNotNull
();
assertThat
(
respuestaBiblioteca
.
getBody
().
getUsuarioId
()).
isEqualTo
(
usuarioId
);
}
}
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