Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Entrega_javcalv_victorm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
javcalv
Entrega_javcalv_victorm
Commits
ff67a649
Commit
ff67a649
authored
6 months ago
by
Javier Calvo
Browse files
Options
Downloads
Patches
Plain Diff
TestMuelle 100%
parent
5709e541
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/es/markse/Contenedor.java
+40
-8
40 additions, 8 deletions
src/es/markse/Contenedor.java
src/es/markse/Muelle.java
+45
-20
45 additions, 20 deletions
src/es/markse/Muelle.java
uses/es/markse/MuelleTest.java
+211
-39
211 additions, 39 deletions
uses/es/markse/MuelleTest.java
with
296 additions
and
67 deletions
src/es/markse/Contenedor.java
+
40
−
8
View file @
ff67a649
...
@@ -18,8 +18,9 @@ public class Contenedor {
...
@@ -18,8 +18,9 @@ public class Contenedor {
private
float
volumen
;
private
float
volumen
;
private
boolean
techo
;
private
boolean
techo
;
private
List
<
Trayecto
>
trayectos
=
new
ArrayList
<>();
private
List
<
Trayecto
>
trayectos
=
new
ArrayList
<>();
private
boolean
recogida
=
false
;
private
boolean
recogida
;
private
boolean
transito
=
false
;
private
boolean
transito
;
private
boolean
apilado
=
false
;
/**
/**
* Constructor del Objeto Contenedor
* Constructor del Objeto Contenedor
...
@@ -36,14 +37,13 @@ public class Contenedor {
...
@@ -36,14 +37,13 @@ public class Contenedor {
validarCodigoDueno
(
codigoDueno
.
toUpperCase
());
validarCodigoDueno
(
codigoDueno
.
toUpperCase
());
validarEquipamiento
(
equipamiento
);
validarEquipamiento
(
equipamiento
);
validarNumeroSerie
(
numeroSerie
);
validarNumeroSerie
(
numeroSerie
);
this
.
pesoTara
=
pesoContenedor
;
this
.
pesoTara
=
pesoContenedor
;
this
.
maximaCargaUtil
=
maximaCargaUtil
;
this
.
maximaCargaUtil
=
maximaCargaUtil
;
this
.
volumen
=
volumen
;
this
.
volumen
=
volumen
;
this
.
transito
=
transito
;
this
.
transito
=
transito
;
this
.
recogida
=
!
transito
;
this
.
techo
=
techo
;
this
.
techo
=
techo
;
String
digitoControl
=
String
.
valueOf
(
calcularDigitoControl
(
codigoDueno
,
equipamiento
,
numeroSerie
));
String
digitoControl
=
String
.
valueOf
(
calcularDigitoControl
(
codigoDueno
,
equipamiento
,
numeroSerie
));
this
.
codigo
=
codigoDueno
+
equipamiento
+
numeroSerie
+
digitoControl
;
this
.
codigo
=
codigoDueno
+
equipamiento
+
numeroSerie
+
digitoControl
;
}
}
...
@@ -53,7 +53,7 @@ public class Contenedor {
...
@@ -53,7 +53,7 @@ public class Contenedor {
* @throws Devuelve una excepcion si no coincide con el patron
* @throws Devuelve una excepcion si no coincide con el patron
*/
*/
private
void
validarCodigoDueno
(
String
codigoDueno
)
{
private
void
validarCodigoDueno
(
String
codigoDueno
)
{
if
(
codigoDueno
.
length
()
!=
3
||
!
codigoDueno
.
matches
(
"[A-Z]{3}"
))
{
if
(
codigoDueno
.
length
()
!=
3
||
!
codigoDueno
.
matches
(
"[A-Z
a-z
]{3}"
))
{
throw
new
IllegalArgumentException
(
"El código del dueño debe tener 3 letras mayúsculas."
);
throw
new
IllegalArgumentException
(
"El código del dueño debe tener 3 letras mayúsculas."
);
}
}
}
}
...
@@ -118,19 +118,43 @@ public class Contenedor {
...
@@ -118,19 +118,43 @@ public class Contenedor {
/**
/**
* 1.1.13 Metodo que sirve para cambiar el estado a recogida de un contenedor
* 1.1.13 Metodo que sirve para cambiar el estado a recogida de un contenedor
* Si esta apilado no puede estar en recogida
*/
*/
public
void
cambiarEstadoARecogida
()
{
public
void
cambiarEstadoARecogida
()
{
if
(!
this
.
estadoApilado
())
{
this
.
recogida
=
true
;
this
.
recogida
=
true
;
this
.
transito
=
false
;
this
.
transito
=
false
;
}
}
}
/**
/**
* 1.1.14 metodo que sirve para cambiar un contenedor a estado de transito
* 1.1.14 metodo que sirve para cambiar un contenedor a estado de transito
* Si esta apilado no puede estar en transito
*/
*/
public
void
cambiarEstadoATransito
()
{
public
void
cambiarEstadoATransito
()
{
if
(!
this
.
estadoApilado
())
{
this
.
transito
=
true
;
this
.
transito
=
true
;
this
.
recogida
=
false
;
this
.
recogida
=
false
;
}
}
}
/**
* Metodo para cambiar estado a apilado
*/
public
void
cambiarEstadoApilado
()
{
this
.
apilado
=
true
;
this
.
transito
=
false
;
this
.
recogida
=
false
;
}
/**
* Metodo para cmabiar el estado de apilado --> recogida
*/
public
void
cambiarEstadoDesapilado
()
{
this
.
apilado
=
false
;
this
.
recogida
=
true
;
}
/**
/**
* 1.1.15 Metodo que cambia un contenedor que no tenga techo a que lo tenga, y al contrario
* 1.1.15 Metodo que cambia un contenedor que no tenga techo a que lo tenga, y al contrario
...
@@ -204,5 +228,13 @@ public class Contenedor {
...
@@ -204,5 +228,13 @@ public class Contenedor {
return
this
.
transito
;
return
this
.
transito
;
}
}
/**
* Metodo que devuelve el estado de apilamiento de un contenedor
* @return estado de apilamiento de un contenedor
*/
public
boolean
estadoApilado
()
{
return
this
.
apilado
;
}
//REALIZAR EL METODO PARA CALCULAR LOS TRAYECTOS
//REALIZAR EL METODO PARA CALCULAR LOS TRAYECTOS
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/es/markse/Muelle.java
+
45
−
20
View file @
ff67a649
...
@@ -70,8 +70,7 @@ public class Muelle {
...
@@ -70,8 +70,7 @@ public class Muelle {
return
false
;
return
false
;
}
}
if
(
this
.
contenedores
.
isEmpty
()
||
this
.
ultimoContenedor
().
tieneTecho
())
{
if
(
this
.
contenedores
.
isEmpty
()
||
this
.
ultimoContenedor
().
tieneTecho
())
{
this
.
contenedores
.
add
(
contenedor
);
return
this
.
contenedores
.
add
(
contenedor
);
return
true
;
}
}
return
false
;
return
false
;
}
}
...
@@ -83,7 +82,7 @@ public class Muelle {
...
@@ -83,7 +82,7 @@ public class Muelle {
* @return true si es el ultimo o false si no lo es.
* @return true si es el ultimo o false si no lo es.
*/
*/
public
boolean
estaEnUltimoNivel
(
String
codigoContenedor
)
{
public
boolean
estaEnUltimoNivel
(
String
codigoContenedor
)
{
return
!
this
.
contenedores
.
isEmpty
()
&&
this
.
ultimoContenedor
().
getCodigo
().
equals
(
codigoContenedor
);
return
this
.
ultimoContenedor
().
getCodigo
().
equals
(
codigoContenedor
);
}
}
/**
/**
...
@@ -279,11 +278,20 @@ public class Muelle {
...
@@ -279,11 +278,20 @@ public class Muelle {
if
(
contenedor
==
null
)
throw
new
IllegalArgumentException
(
"El Ccontenedor no puede ser nulo"
);
if
(
contenedor
==
null
)
throw
new
IllegalArgumentException
(
"El Ccontenedor no puede ser nulo"
);
if
(
plaza
<
0
||
plaza
>
this
.
numeroDePlazasTotales
())
throw
new
if
(
plaza
<
0
||
plaza
>
this
.
numeroDePlazasTotales
())
throw
new
IllegalArgumentException
(
"La plaza debe de estar entre 0-"
+
(
this
.
plazas
.
length
-
1
));
IllegalArgumentException
(
"La plaza debe de estar entre 0-"
+
(
this
.
plazas
.
length
-
1
));
//Si ya esta apilado
if
(
contenedor
.
estadoApilado
())
{
throw
new
IllegalArgumentException
(
"El Contenedor ya esta apilado"
);
}
//Si esta entransito
if
(
contenedor
.
estadoTransito
())
{
throw
new
IllegalArgumentException
(
"El Contenedor esta en transito, no se puede colocar"
);
}
Contenedor
ultimo
=
this
.
plazas
[
plaza
].
ultimoContenedor
();
Contenedor
ultimo
=
this
.
plazas
[
plaza
].
ultimoContenedor
();
// Verificar si hay un último contenedor y si tiene techo
// Verificar si hay un último contenedor y si tiene techo
boolean
teniaTecho
=
(
ultimo
!=
null
&&
ultimo
.
tieneTecho
());
boolean
teniaTecho
=
(
ultimo
!=
null
&&
ultimo
.
tieneTecho
());
if
(
this
.
plazas
[
plaza
].
colocarContenedor
(
contenedor
))
{
if
(
this
.
plazas
[
plaza
].
colocarContenedor
(
contenedor
))
{
contenedor
.
cambiarEstadoApilado
();
int
plazasDespues
=
this
.
plazas
[
plaza
].
numeroContenedores
();
int
plazasDespues
=
this
.
plazas
[
plaza
].
numeroContenedores
();
int
plazasAntes
=
plazasDespues
-
1
;
int
plazasAntes
=
plazasDespues
-
1
;
this
.
actualizarPlazas
(
plazasAntes
,
plazasDespues
,
this
.
plazas
[
plaza
],
teniaTecho
);
this
.
actualizarPlazas
(
plazasAntes
,
plazasDespues
,
this
.
plazas
[
plaza
],
teniaTecho
);
...
@@ -304,14 +312,22 @@ public class Muelle {
...
@@ -304,14 +312,22 @@ public class Muelle {
public
void
sacarContenedorDePlaza
(
Contenedor
contenedor
)
{
public
void
sacarContenedorDePlaza
(
Contenedor
contenedor
)
{
if
(
contenedor
==
null
)
throw
new
IllegalArgumentException
(
"El Ccontenedor no puede ser nulo"
);
if
(
contenedor
==
null
)
throw
new
IllegalArgumentException
(
"El Ccontenedor no puede ser nulo"
);
if
(!
contenedor
.
estadoApilado
())
throw
new
IllegalArgumentException
(
"El Contenedor no esta en ninguna plaza. Se encuentra en transito o en recogida"
);
for
(
Plaza
plaza
:
this
.
plazas
)
{
for
(
Plaza
plaza
:
this
.
plazas
)
{
if
(
plaza
.
numeroContenedores
()
!=
0
&&
plaza
.
estaEnUltimoNivel
(
contenedor
.
getCodigo
()))
{
if
(
plaza
.
contieneContenedor
(
contenedor
.
getCodigo
()))
{
if
(
plaza
.
estaEnUltimoNivel
(
contenedor
.
getCodigo
()))
{
int
plazasAntes
=
plaza
.
numeroContenedores
();
int
plazasAntes
=
plaza
.
numeroContenedores
();
boolean
teniaTecho
=
plaza
.
ultimoContenedor
().
tieneTecho
();
//Ver si el contenedor que quitamos tenia techo o no
boolean
teniaTecho
=
plaza
.
ultimoContenedor
().
tieneTecho
();
plaza
.
desapilarContenedor
();
plaza
.
desapilarContenedor
();
contenedor
.
cambiarEstadoDesapilado
();
int
plazasDespues
=
plaza
.
numeroContenedores
();
int
plazasDespues
=
plaza
.
numeroContenedores
();
this
.
actualizarPlazas
(
plazasAntes
,
plazasDespues
,
plaza
,
teniaTecho
);
this
.
actualizarPlazas
(
plazasAntes
,
plazasDespues
,
plaza
,
teniaTecho
);
}
}
else
{
throw
new
IllegalArgumentException
(
"El Contenedor No esta en el ultimo nivel"
);
}
}
}
}
}
}
...
@@ -339,7 +355,8 @@ public class Muelle {
...
@@ -339,7 +355,8 @@ public class Muelle {
}
}
//Si ahora no lo tiene, las llenas son una mas y semillenas uno menos
//Si ahora no lo tiene, las llenas son una mas y semillenas uno menos
else
{
else
{
this
.
plazasLlenas
++;
this
.
plazasSemillenas
--;
this
.
plazasLlenas
++;
this
.
plazasSemillenas
--;
}
}
}
}
}
}
...
@@ -377,19 +394,27 @@ public class Muelle {
...
@@ -377,19 +394,27 @@ public class Muelle {
//Plaza queda vacia
//Plaza queda vacia
if
(
esVacio
)
{
if
(
esVacio
)
{
if
(
alturaMaxima
==
1
||
!
teniaTecho
)
{
if
(
alturaMaxima
==
1
||
!
teniaTecho
)
{
plazasLlenas
--;
this
.
plazasLlenas
--;
plazasVacias
++;
this
.
plazasVacias
++;
}
}
else
{
else
{
plazasSemillenas
--;
this
.
plazasSemillenas
--;
plazasVacias
++;
this
.
plazasVacias
++;
}
}
}
}
//Se queda con el penultimo contenedor
else
if
(
esPenultimoContenedor
)
{
this
.
plazasLlenas
--;
this
.
plazasSemillenas
++;
}
//Se queda con el penultimo contenedor o con otro cuando el anterior no tenia techo
//Se elimina un contenedor que no sea ni el primero ni el ultimo
else
if
(
esPenultimoContenedor
||
(!
teniaTecho
&&
plazasDespues
<
alturaMaxima
))
{
else
{
plazasLlenas
--;
//Si el contenedor eliminado tenia no techo Llenas a Semillenas
plazasSemillenas
++;
if
(!
teniaTecho
)
{
this
.
plazasLlenas
--;
this
.
plazasSemillenas
++;
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
uses/es/markse/MuelleTest.java
+
211
−
39
View file @
ff67a649
...
@@ -18,7 +18,7 @@ import es.uva.inf.poo.maps.GPSCoordinate;
...
@@ -18,7 +18,7 @@ import es.uva.inf.poo.maps.GPSCoordinate;
public
class
MuelleTest
{
public
class
MuelleTest
{
@Test
@Test
public
final
void
testMuelle
()
{
public
void
testMuelle
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
assertEquals
(
"01"
,
m
.
getIdentificador
());
assertEquals
(
"01"
,
m
.
getIdentificador
());
...
@@ -28,37 +28,43 @@ public class MuelleTest {
...
@@ -28,37 +28,43 @@ public class MuelleTest {
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testMuelleIdentificadorVacio
()
{
public
void
testMuelleIdentificadorVacio
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
new
Muelle
(
null
,
cord
,
true
,
2
,
2
);
new
Muelle
(
null
,
cord
,
true
,
2
,
2
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testMuelleGPSVacio
()
{
public
void
testMuelleGPSVacio
()
{
new
Muelle
(
"04"
,
null
,
true
,
2
,
2
);
new
Muelle
(
"04"
,
null
,
true
,
2
,
2
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testMuelleIdentificadorInalido
()
{
public
void
testMuelleIdentificadorIn
v
alido
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
new
Muelle
(
"r3"
,
cord
,
true
,
2
,
2
);
new
Muelle
(
"r3"
,
cord
,
true
,
2
,
2
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testMuellePlazasInvalida
()
{
public
void
testMuelleIdentificadorInvalidoTamanyo
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
new
Muelle
(
"r432432"
,
cord
,
true
,
2
,
2
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testMuellePlazasInvalida
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
new
Muelle
(
"12"
,
cord
,
true
,
-
3
,
2
);
new
Muelle
(
"12"
,
cord
,
true
,
-
3
,
2
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testMuelleAlturaInvalida
()
{
public
void
testMuelleAlturaInvalida
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
new
Muelle
(
"12"
,
cord
,
true
,
1
,-
2
);
new
Muelle
(
"12"
,
cord
,
true
,
1
,-
2
);
}
}
@Test
@Test
public
final
void
testGetIdentificador
()
{
public
void
testGetIdentificador
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
assertEquals
(
"01"
,
m
.
getIdentificador
());
assertEquals
(
"01"
,
m
.
getIdentificador
());
...
@@ -66,7 +72,7 @@ public class MuelleTest {
...
@@ -66,7 +72,7 @@ public class MuelleTest {
@Test
@Test
public
final
void
testEstaOperativo
()
{
public
void
testEstaOperativo
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m1
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m1
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m2
=
new
Muelle
(
"02"
,
cord
,
false
,
2
,
2
);
Muelle
m2
=
new
Muelle
(
"02"
,
cord
,
false
,
2
,
2
);
...
@@ -76,7 +82,7 @@ public class MuelleTest {
...
@@ -76,7 +82,7 @@ public class MuelleTest {
@Test
@Test
public
final
void
testGetGPSCoordinate
()
{
public
void
testGetGPSCoordinate
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
assertEquals
(
cord
,
m
.
getGPSCoordinate
());
assertEquals
(
cord
,
m
.
getGPSCoordinate
());
...
@@ -84,7 +90,7 @@ public class MuelleTest {
...
@@ -84,7 +90,7 @@ public class MuelleTest {
@Test
@Test
public
final
void
testNumeroDePlazasTotales
()
{
public
void
testNumeroDePlazasTotales
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
assertEquals
(
2
,
m
.
numeroDePlazasTotales
());
assertEquals
(
2
,
m
.
numeroDePlazasTotales
());
...
@@ -92,11 +98,9 @@ public class MuelleTest {
...
@@ -92,11 +98,9 @@ public class MuelleTest {
@Test
@Test
public
final
void
testPlazasVacias
()
{
public
void
testPlazasVacias
()
{
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
p
.
anyadirMuelle
(
m
);
assertEquals
(
2
,
m
.
plazasVacias
());
assertEquals
(
2
,
m
.
plazasVacias
());
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"TRR"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"TRR"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
...
@@ -109,7 +113,7 @@ public class MuelleTest {
...
@@ -109,7 +113,7 @@ public class MuelleTest {
}
}
@Test
@Test
public
final
void
testPlazasLlenas
()
{
public
void
testPlazasLlenas
()
{
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
...
@@ -123,11 +127,9 @@ public class MuelleTest {
...
@@ -123,11 +127,9 @@ public class MuelleTest {
}
}
@Test
@Test
public
final
void
testPlazasSemillenas
()
{
public
void
testPlazasSemillenas
()
{
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
p
.
anyadirMuelle
(
m
);
assertEquals
(
0
,
m
.
plazasSemillenas
());
assertEquals
(
0
,
m
.
plazasSemillenas
());
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"TRR"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"TRR"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
...
@@ -142,11 +144,9 @@ public class MuelleTest {
...
@@ -142,11 +144,9 @@ public class MuelleTest {
}
}
@Test
@Test
public
final
void
testPlazaActual
()
{
public
void
testPlazaActual
()
{
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
p
.
anyadirMuelle
(
m
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c
,
4
);
m
.
colocarContenedorEnPlaza
(
c
,
4
);
assertEquals
(
4
,
m
.
plazaActual
(
c
.
getCodigo
()));
assertEquals
(
4
,
m
.
plazaActual
(
c
.
getCodigo
()));
...
@@ -154,14 +154,14 @@ public class MuelleTest {
...
@@ -154,14 +154,14 @@ public class MuelleTest {
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testPlazaActualCodigoInvalido
()
{
public
void
testPlazaActualCodigoInvalido
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
m
.
plazaActual
(
"HOLA"
);
m
.
plazaActual
(
"HOLA"
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testPlazaActualCodigoNulo
()
{
public
void
testPlazaActualCodigoNulo
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
m
.
plazaActual
(
null
);
m
.
plazaActual
(
null
);
...
@@ -169,11 +169,9 @@ public class MuelleTest {
...
@@ -169,11 +169,9 @@ public class MuelleTest {
@Test
@Test
public
final
void
testNivelEnPlaza
()
{
public
void
testNivelEnPlaza
()
{
Puerto
p
=
new
Puerto
(
"ES"
,
"BAR"
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
p
.
anyadirMuelle
(
m
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"ZEX"
,
'Z'
,
"666731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"ZEX"
,
'Z'
,
"666731"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c
,
4
);
m
.
colocarContenedorEnPlaza
(
c
,
4
);
...
@@ -184,38 +182,212 @@ public class MuelleTest {
...
@@ -184,38 +182,212 @@ public class MuelleTest {
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testNivelEnPlazaCodigoInvalido
()
{
public
void
testNivelEnPlazaCodigoInvalido
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
m
.
nivelEnPlaza
(
"HOLA"
);
m
.
nivelEnPlaza
(
"HOLA"
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
final
void
testNivelEnPlazaCodigoNulo
()
{
public
void
testNivelEnPlazaCodigoNulo
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
10
,
2
);
m
.
nivelEnPlaza
(
null
);
m
.
nivelEnPlaza
(
null
);
}
}
/*
@Test
@Test
public final void testColocarContenedorEnPlaza() {
public
void
testColocarContenedorEnPlaza
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"ZEX"
,
'Z'
,
"666731"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
colocarContenedorEnPlaza
(
c2
,
1
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnPlazaContenedorVacio
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
m
.
colocarContenedorEnPlaza
(
null
,
0
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnPlazaFueraRango
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
13
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnPlazaFueraRangoAbajo
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
-
2
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorYaApilado
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
colocarContenedorEnPlaza
(
c
,
1
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnTransito
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
1
);
c
.
cambiarEstadoATransito
();
m
.
colocarContenedorEnPlaza
(
c
,
0
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEncimaDeUnoSinTecho
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
false
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
Contenedor
c2
=
new
Contenedor
(
"ZTG"
,
'J'
,
"582940"
,
100
,
400
,
500
,
false
,
false
);
m
.
colocarContenedorEnPlaza
(
c2
,
0
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnPlazaLLena
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
Contenedor
c2
=
new
Contenedor
(
"ZTG"
,
'J'
,
"582940"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c2
,
0
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testColocarContenedorEnDosMuelles
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
Muelle
m2
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m2
.
colocarContenedorEnPlaza
(
c
,
0
);
}
@Test
public
void
testSacarContenedorDePlaza
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
sacarContenedorDePlaza
(
c
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSacarContenedorDePlazaQueNoEstaEnUltimoNivel
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"RJF"
,
'Z'
,
"401932"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
colocarContenedorEnPlaza
(
c2
,
0
);
m
.
sacarContenedorDePlaza
(
c
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSacarContenedorDePlazaContenedorVacio
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
m
.
sacarContenedorDePlaza
(
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testSacarContenedorDePlazaQueNoEstaApilado
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
m
.
sacarContenedorDePlaza
(
c
);
}
@Test
@Test
public final void testSacarContenedorDePlaza() {
public
void
testAlternarTechoContenedor
()
{
fail("Not yet implemented"); // TODO
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
2
,
2
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
alternarTechoContenedor
(
c
);
Contenedor
c2
=
new
Contenedor
(
"XCD"
,
'J'
,
"401941"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c3
=
new
Contenedor
(
"RTR"
,
'J'
,
"405012"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c2
,
1
);
m
.
colocarContenedorEnPlaza
(
c3
,
1
);
m
.
alternarTechoContenedor
(
c3
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testAlternarTechoContenedorVacio
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
m
.
alternarTechoContenedor
(
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testAlternarTechoContenedorQueNoEsta
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
m
.
alternarTechoContenedor
(
c
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testAlternarTechoContenedorQueNoEstaEnUltimaPlaza
()
{
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
Contenedor
c
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c2
=
new
Contenedor
(
"EWE"
,
'J'
,
"456321"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
m
.
colocarContenedorEnPlaza
(
c2
,
0
);
m
.
alternarTechoContenedor
(
c
);
}
}
@Test
@Test
public final void testAlternarTechoContenedor() {
public
void
testAlternarOperativo
()
{
fail("Not yet implemented"); // TODO
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
m
.
alternarOperativo
();
assertFalse
(
m
.
estaOperativo
());
m
.
alternarOperativo
();
assertTrue
(
m
.
estaOperativo
());
}
}
@Test
@Test
public final void testAlternarOperativo() {
public
void
testGestionPlazasGeneral
()
{
fail("Not yet implemented"); // TODO
GPSCoordinate
cord
=
new
GPSCoordinate
(
5
d
,
5
d
);
Muelle
m
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
3
);
Muelle
m2
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
2
);
Muelle
m3
=
new
Muelle
(
"01"
,
cord
,
true
,
1
,
1
);
Contenedor
c
=
new
Contenedor
(
"DFR"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
false
);
Contenedor
c2
=
new
Contenedor
(
"ZZE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
true
);
Contenedor
c3
=
new
Contenedor
(
"ZRE"
,
'J'
,
"056731"
,
100
,
400
,
500
,
false
,
false
);
Contenedor
c4
=
new
Contenedor
(
"ZRR"
,
'J'
,
"432422"
,
100
,
400
,
500
,
false
,
true
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
assertEquals
(
0
,
m
.
plazasVacias
(),
m
.
plazasSemillenas
());
m
.
sacarContenedorDePlaza
(
c
);
assertEquals
(
1
,
m
.
plazasVacias
());
assertEquals
(
0
,
m
.
plazasSemillenas
());
m2
.
colocarContenedorEnPlaza
(
c2
,
0
);
m2
.
colocarContenedorEnPlaza
(
c3
,
0
);
m2
.
sacarContenedorDePlaza
(
c3
);
assertEquals
(
1
,
m2
.
plazasSemillenas
());
m2
.
sacarContenedorDePlaza
(
c2
);
assertEquals
(
0
,
m2
.
plazasSemillenas
(),
m2
.
plazasLlenas
());
m
.
colocarContenedorEnPlaza
(
c2
,
0
);
m
.
colocarContenedorEnPlaza
(
c
,
0
);
assertEquals
(
0
,
m
.
plazasVacias
(),
m
.
plazasSemillenas
());
m
.
sacarContenedorDePlaza
(
c
);
m
.
colocarContenedorEnPlaza
(
c4
,
0
);
assertEquals
(
1
,
m
.
plazasSemillenas
());
m
.
sacarContenedorDePlaza
(
c4
);
}
}
*/
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment