Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Andrés Rojas Ortega
/
PR5_DS
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
9f39bbee
authored
Dec 21, 2022
by
Andrés Rojas Ortega
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Tests funcion altausuario terminados
parent
e596f57b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
35 deletions
prueba/pom.xml
prueba/src/main/java/com/mycompany/Modelo/GestorUsuarios.java
prueba/src/main/java/com/mycompany/Modelo/Lector.java
prueba/src/main/java/com/mycompany/Modelo/Usuario.java
prueba/src/test/java/com/mycompany/Modelo/GestorUsuariosTest.java
prueba/pom.xml
View file @
9f39bbee
...
@@ -5,6 +5,29 @@
...
@@ -5,6 +5,29 @@
<artifactId>
prueba
</artifactId>
<artifactId>
prueba
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-api
</artifactId>
<version>
5.8.2
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.assertj
</groupId>
<artifactId>
assertj-core
</artifactId>
<version>
3.22.0
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
</dependencies>
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
18
</maven.compiler.source>
<maven.compiler.source>
18
</maven.compiler.source>
...
...
prueba/src/main/java/com/mycompany/Modelo/GestorUsuarios.java
View file @
9f39bbee
...
@@ -5,38 +5,47 @@ import java.util.Date;
...
@@ -5,38 +5,47 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
public
class
GestorUsuarios
{
public
class
GestorUsuarios
{
public
Vector
<
Usuario
>
_gestiona
=
new
Vector
<
Usuario
>();
public
GestorBiblioteca
_unnamed_GestorBiblioteca_66
;
public
List
<
Usuario
>
listar
()
{
public
Vector
<
Usuario
>
_gestiona
=
new
Vector
<
Usuario
>();
throw
new
UnsupportedOperationException
();
public
GestorBiblioteca
_unnamed_GestorBiblioteca_66
;
}
public
GestorUsuarios
()
{
public
Usuario
consultar
(
String
aIdUsuario
)
{
}
throw
new
UnsupportedOperationException
();
}
public
List
<
Usuario
>
listar
()
{
throw
new
UnsupportedOperationException
();
public
String
baja
(
String
aIdUsuario
)
{
}
throw
new
UnsupportedOperationException
();
}
public
Usuario
consultar
(
String
aIdUsuario
)
{
throw
new
UnsupportedOperationException
();
public
String
alta
(
Usuario
aUsuario
)
{
}
throw
new
UnsupportedOperationException
();
}
public
String
baja
(
String
aIdUsuario
)
{
throw
new
UnsupportedOperationException
();
public
String
modificarUsuario
(
String
aIdUsuario
,
Usuario
aUsuario
)
{
}
throw
new
UnsupportedOperationException
();
}
public
String
alta
(
Usuario
aUsuario
)
{
if
(
_gestiona
.
contains
(
aUsuario
))
{
public
String
notificarMulta
(
String
aIdUsuario
)
{
return
"Registro incorrecto, usuario duplicado"
;
throw
new
UnsupportedOperationException
();
}
else
{
}
_gestiona
.
add
(
aUsuario
);
return
"Registro con éxito"
;
public
String
penalizarLector
(
String
aIdUsuario
,
Date
aFechaPenalizacion
)
{
}
throw
new
UnsupportedOperationException
();
}
}
public
String
modificarUsuario
(
String
aIdUsuario
,
Usuario
aUsuario
)
{
public
List
<
Usuario
>
consultarUsuarios
()
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
}
public
String
notificarMulta
(
String
aIdUsuario
)
{
\ No newline at end of file
throw
new
UnsupportedOperationException
();
}
public
String
penalizarLector
(
String
aIdUsuario
,
Date
aFechaPenalizacion
)
{
throw
new
UnsupportedOperationException
();
}
public
List
<
Usuario
>
consultarUsuarios
()
{
throw
new
UnsupportedOperationException
();
}
}
prueba/src/main/java/com/mycompany/Modelo/Lector.java
View file @
9f39bbee
...
@@ -13,6 +13,10 @@ public class Lector extends Usuario {
...
@@ -13,6 +13,10 @@ public class Lector extends Usuario {
public
Vector
<
Prestamo
>
_pr
é
stamos
=
new
Vector
<
Prestamo
>();
public
Vector
<
Prestamo
>
_pr
é
stamos
=
new
Vector
<
Prestamo
>();
public
Reserva
_unnamed_Reserva_53
;
public
Reserva
_unnamed_Reserva_53
;
public
Lector
(
String
_nombre
,
String
_email
,
String
_contrase
ñ
a
,
String
_tipoUsuario
)
{
super
(
_nombre
,
_email
,
_contrase
ñ
a
,
_tipoUsuario
);
}
public
Usuario
get
(
String
aIdUsuario
)
{
public
Usuario
get
(
String
aIdUsuario
)
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
...
prueba/src/main/java/com/mycompany/Modelo/Usuario.java
View file @
9f39bbee
...
@@ -4,6 +4,7 @@ import com.mycompany.Subject2;
...
@@ -4,6 +4,7 @@ import com.mycompany.Subject2;
import
com.mycompany.persistencia.UsuarioDAO
;
import
com.mycompany.persistencia.UsuarioDAO
;
public
class
Usuario
implements
Subject2
{
public
class
Usuario
implements
Subject2
{
private
static
int
idGen
=
0
;
private
String
_nombre
;
private
String
_nombre
;
private
String
_email
;
private
String
_email
;
private
int
_idUsuario
;
private
int
_idUsuario
;
...
@@ -12,6 +13,15 @@ public class Usuario implements Subject2 {
...
@@ -12,6 +13,15 @@ public class Usuario implements Subject2 {
public
GestorUsuarios
_gestiona
;
public
GestorUsuarios
_gestiona
;
public
UsuarioDAO
_unnamed_UsuarioDAO_
;
public
UsuarioDAO
_unnamed_UsuarioDAO_
;
public
Usuario
(
String
_nombre
,
String
_email
,
String
_contrase
ñ
a
,
String
_tipoUsuario
)
{
this
.
_idUsuario
=
idGen
++;
this
.
_nombre
=
_nombre
;
this
.
_email
=
_email
;
this
.
_idUsuario
=
_idUsuario
;
this
.
_contrase
ñ
a
=
_contrase
ñ
a
;
this
.
_tipoUsuario
=
_tipoUsuario
;
}
public
void
a
ñ
adir
(
Usuario
aUsuario
)
{
public
void
a
ñ
adir
(
Usuario
aUsuario
)
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
...
prueba/src/test/java/com/mycompany/Modelo/GestorUsuariosTest.java
0 → 100644
View file @
9f39bbee
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package
com
.
mycompany
.
Modelo
;
import
org.assertj.core.api.Assertions
;
import
org.junit.Test
;
/**
*
* @author andresro
*/
public
class
GestorUsuariosTest
{
@Test
public
void
testAltaUsuario
(){
GestorUsuarios
gestorUsuarios
=
new
GestorUsuarios
();
Usuario
usuario
=
new
Usuario
(
"Andrés"
,
"aro00015@red.ujaen.es"
,
"1234"
,
"Alumno"
);
String
mensajeConfirmacion
=
gestorUsuarios
.
alta
(
usuario
);
Assertions
.
assertThat
(
mensajeConfirmacion
).
isEqualTo
(
"Registro con éxito"
);
}
@Test
public
void
testAltausuarioYaRegistrado
(){
GestorUsuarios
gestorUsuarios
=
new
GestorUsuarios
();
Usuario
usuario1
=
new
Usuario
(
"Andrés "
,
"aro00015@red.ujaen.es"
,
"12334"
,
"Alumno"
);
gestorUsuarios
.
alta
(
usuario1
);
String
mensajeConfirmacion
=
gestorUsuarios
.
alta
(
usuario1
);
Assertions
.
assertThat
(
mensajeConfirmacion
).
isEqualTo
(
"Registro incorrecto, usuario duplicado"
);
}
}
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