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
6f45a714
authored
Feb 20, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [TestServicioUsuario]: Test de registro de usuario pasado correctamente
parent
f7a0fe63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
src/main/java/com/ujaen/tfg/mangaffinity/entidades/Usuario.java
src/test/java/com/ujaen/tfg/mangaffinity/servicios/TestServicioUsuarios.java
src/main/java/com/ujaen/tfg/mangaffinity/entidades/Usuario.java
View file @
6f45a714
...
...
@@ -31,7 +31,7 @@ public class Usuario {
private
String
contrasenia
;
@OneToOne
(
mappedBy
=
"usuario"
)
@OneToOne
(
mappedBy
=
"usuario"
,
cascade
=
CascadeType
.
ALL
)
private
Repositorio
repositorio
;
public
Usuario
(
String
email
,
String
nombreUsuario
,
String
contrasenia
)
{
...
...
src/test/java/com/ujaen/tfg/mangaffinity/servicios/TestServicioUsuarios.java
0 → 100644
View file @
6f45a714
package
com
.
ujaen
.
tfg
.
mangaffinity
.
servicios
;
import
com.ujaen.tfg.mangaffinity.MangAffinityApplication
;
import
com.ujaen.tfg.mangaffinity.config.JpaTestConfig
;
import
com.ujaen.tfg.mangaffinity.entidades.Usuario
;
import
com.ujaen.tfg.mangaffinity.excepciones.UsuarioYaRegistrado
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.ActiveProfiles
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatThrownBy
;
@SpringBootTest
(
classes
=
{
MangAffinityApplication
.
class
,
JpaTestConfig
.
class
})
@ActiveProfiles
(
"test"
)
public
class
TestServicioUsuarios
{
@Autowired
ServicioUsuarios
servicioUsuarios
;
@Test
@DirtiesContext
void
testCrearSocio
(){
var
usuario1
=
new
Usuario
(
"pedro@gmail.com"
,
"Pedro"
,
"pedrito"
);
// Comprobamos que no se pueda meter dos socios con el mismo email
servicioUsuarios
.
crearUsuario
(
usuario1
);
assertThatThrownBy
(()
->
servicioUsuarios
.
crearUsuario
(
usuario1
)).
isInstanceOf
(
UsuarioYaRegistrado
.
class
);
}
}
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