diff --git a/.classpath b/.classpath index 657b730178357daeb1d137b073f249338da50581..cf449d5e424e039ea6447c90d0aa329946df3d0f 100644 --- a/.classpath +++ b/.classpath @@ -2,12 +2,12 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="uses"/> - <classpathentry exported="true" kind="lib" path="clases"/> - <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> + <classpathentry kind="lib" path="clases"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <attributes> <attribute name="module" value="true"/> </attributes> </classpathentry> - <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="bin"/> -</classpath> +</classpath> \ No newline at end of file diff --git a/src/es/markse/Muelle.java b/src/es/markse/Muelle.java index b89a44ad63977c07d709ec34d86613b5b115da22..eb4a0ebd25d029b7f01aca1c2e780c9980c20fea 100644 --- a/src/es/markse/Muelle.java +++ b/src/es/markse/Muelle.java @@ -41,7 +41,7 @@ public class Muelle { * @return true si esta vacia o false si no lo esta */ public boolean plazaVacia() { - return (this.contenedores.size() == 0) ? true : false; + return this.contenedores.isEmpty(); } /** @@ -49,8 +49,8 @@ public class Muelle { * @return true si la plaza esta llena o si no lo esta */ public boolean plazaLlena() { - return (this.contenedores.size() == this.altura || - (!this.contenedores.isEmpty() && this.ultimoContenedor().tieneTecho())) ? true : false; + return (this.contenedores.size() == this.altura + || (!this.contenedores.isEmpty() && !this.ultimoContenedor().tieneTecho())) ? true : false; } /** @@ -77,7 +77,7 @@ public class Muelle { * @throws IllegalArgumentException si el contenedor es nulo */ public void colocarContenedor(Contenedor contenedor) { - //Encapsulamos errores aunque para evitarlos en un futuro (si hay cambios) + //Encapsulamos errores para evitarlos en un futuro (si hay cambios) if (contenedor == null) throw new IllegalArgumentException("El contenedor no puede ser nulo"); @@ -284,6 +284,7 @@ public class Muelle { * @param plaza La plaza del contenedor * @throws IllegalArgumentException si el contenedor es nulo * @throws IllegalArgumentException si la plaza esta fuera de rango, + * @throws IllegalStateException si el muelle no esta operativo * @throws IllegalStateException si ese contenedor ya esta apilado * @throws IllegalStateException si ese contenedor esta en transito, * @throws IllegalStateException si el contenedor donde se coloca encima no tiene techo @@ -296,6 +297,10 @@ public class Muelle { if (plaza < 0 || plaza > this.numeroDePlazasTotales()) throw new IllegalArgumentException("La plaza debe de estar entre 0-"+ (this.plazas.length -1)); + //Comprobamos si esta operativo o no + if(!this.estaOperativo()) + throw new IllegalStateException("El muelle no esta operativo"); + //Si esta entransito if (contenedor.contenedorEnTransito()){ throw new IllegalStateException("El Contenedor esta en transito, no se puede colocar"); @@ -312,7 +317,7 @@ public class Muelle { throw new IllegalStateException("La plaza está llena"); //Verificamos si el ultimo contenedor tiene techo - if(p.contenedores.size() > 0 && p.ultimoContenedor() != null && !p.ultimoContenedor().tieneTecho()) + if(p.contenedores.size() > 0 && !p.ultimoContenedor().tieneTecho()) throw new IllegalStateException("El contenedor no tiene techo"); else{ this.plazas[plaza].colocarContenedor(contenedor); @@ -333,6 +338,9 @@ public class Muelle { throw new IllegalArgumentException("El Contenedor no puede ser nulo"); if (contenedor.contenedorEnTransito()) throw new IllegalStateException("El Contenedor se encuentra en transito"); + //Comprobar si se encuentra en funcionamiento + if(!this.estaOperativo()) + throw new IllegalStateException("El muelle se encuentra fuera de servicio"); String c = contenedor.getCodigo(); //Buscamos que el contenedor este en el muelle @@ -341,12 +349,10 @@ public class Muelle { //Buscamos el contenedor y desapilamos el contenedor si se encuentra en el ultimo nivel for (Plaza plaza : this.plazas) { if (plaza.contieneContenedor(c)) { - if (plaza.estaEnUltimoNivel(c)) { + if (plaza.estaEnUltimoNivel(c)) plaza.desapilarContenedor(); - } - else { + else throw new IllegalStateException("El Contenedor no esta en el ultimo nivel, no se puede desapilar"); - } } } } @@ -386,9 +392,17 @@ public class Muelle { /** * Metodo que devuelve el punto de coordenadas del muelle * Este punto pertenece a la clase GPSCoordinate - * @return coordenadas del muelle; + * @return coordinates del muelle; */ public GPSCoordinate getGPSCoordinate() { return this.cord; } + + /** + * Metodo que devuelve la lista de las plazas + * @return Lista de las plazas + */ + public Plaza[] plazas() { + return this.plazas.clone(); + } } \ No newline at end of file diff --git a/uses/es/markse/ContenedorTest.java b/uses/es/markse/ContenedorTest.java index 9ab41213935213e8b18df8b9d07d5b747103e614..b4ae52b2ea13523527b9860f1ddeb256ebe75130 100644 --- a/uses/es/markse/ContenedorTest.java +++ b/uses/es/markse/ContenedorTest.java @@ -23,7 +23,6 @@ public class ContenedorTest { assertEquals(500.0f, c2.cargaUtilContenedor(), 0.001f); Contenedor c3 = new Contenedor("TOO", 'J', "123459", 200, 500, 1000, true, true); assertEquals(1000f, c3.volumenEnMetrosCubicos(), 0.001f); - } @Test(expected = IllegalArgumentException.class) diff --git a/uses/es/markse/MuelleTest.java b/uses/es/markse/MuelleTest.java index deb5210a49784bab171e6fac2f0bfd4c21faf048..afeb2b6ded16d35db1a2871274c03316862a9af1 100644 --- a/uses/es/markse/MuelleTest.java +++ b/uses/es/markse/MuelleTest.java @@ -103,42 +103,44 @@ public class MuelleTest { ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - /*Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c1, 0); assertEquals(1, m.plazasVacias()); m.colocarContenedorEnPlaza(c2, 1); assertEquals(0, m.plazasVacias()); m.sacarContenedorDePlaza(c2); - assertEquals(1, m.plazasVacias()); */ + assertEquals(1, m.plazasVacias()); } @Test public void testPlazasLlenas() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); - System.out.println(m.plazasLlenas()); assertEquals(0, m.plazasLlenas()); ISO6346 i = new ISO6346("ZRE", 'J' , 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); Contenedor c = new Contenedor(i, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 0); assertEquals(0, m.plazasLlenas()); - c.alternarTecho(); - assertEquals(1, m.plazasLlenas()); + m.colocarContenedorEnPlaza(c2, 0); + assertEquals(1, m.plazasLlenas()); } @Test public void testPlazasSemillenas() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); assertEquals(0, m.plazasSemillenas()); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Contenedor c2 = new Contenedor("TRR", 'J', "056731", 100, 400, 500, false, true); - m.colocarContenedorEnPlaza(c, 0); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + m.colocarContenedorEnPlaza(c1, 0); assertEquals(1, m.plazasSemillenas()); - m.alternarTechoContenedor(c); + c1.alternarTecho(); assertEquals(0, m.plazasSemillenas()); - m.alternarTechoContenedor(c); - assertEquals(1, m.plazasSemillenas()); + c1.alternarTecho(); m.colocarContenedorEnPlaza(c2, 0); assertEquals(0, m.plazasSemillenas()); } @@ -146,24 +148,31 @@ public class MuelleTest { @Test public void testPlazaActual() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); + ISO6346 i = new ISO6346("ZRE", 'J' , 56731); + Contenedor c = new Contenedor(i, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 4); assertEquals(4, m.plazaActual(c.getCodigo())); - assertEquals(-1, m.plazaActual("RUTJ0438521")); + } + + @Test + public void testPlazaActualCodigoNoEstaEnMuelle() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); + assertEquals(-1, m.plazaActual("RTTU8989890")); } @Test(expected = IllegalArgumentException.class) public void testPlazaActualCodigoInvalido() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); m.plazaActual("HOLA"); } @Test(expected = IllegalArgumentException.class) public void testPlazaActualCodigoNulo() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); m.plazaActual(null); } @@ -171,223 +180,196 @@ public class MuelleTest { @Test public void testNivelEnPlaza() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Contenedor c2 = new Contenedor("ZEX", 'Z', "666731", 100, 400, 500, false, true); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 4); m.colocarContenedorEnPlaza(c2, 4); assertEquals(1, m.nivelEnPlaza(c.getCodigo())); assertEquals(2, m.nivelEnPlaza(c2.getCodigo())); + } + + @Test + public void testNivelEnPlazaContenedorNoPerteneceA() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); assertEquals(-1, m.nivelEnPlaza("RUTJ0438521")); } + @Test(expected = IllegalArgumentException.class) public void testNivelEnPlazaCodigoInvalido() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); m.nivelEnPlaza("HOLA"); } @Test(expected = IllegalArgumentException.class) public void testNivelEnPlazaCodigoNulo() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 10,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); m.nivelEnPlaza(null); } @Test public void testColocarContenedorEnPlaza() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 10, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + m.colocarContenedorEnPlaza(c1, 0); m.colocarContenedorEnPlaza(c2, 1); } @Test(expected = IllegalArgumentException.class) public void testColocarContenedorEnPlazaContenedorVacio() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 2,1); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); m.colocarContenedorEnPlaza(null, 0); } @Test(expected = IllegalArgumentException.class) - public void testColocarContenedorEnPlazaFueraRango() { + public void testColocarContenedorEnPlazaFueraRangoArriba() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Muelle m = new Muelle("01", cord, true, 2,1); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 13); } @Test(expected = IllegalArgumentException.class) public void testColocarContenedorEnPlazaFueraRangoAbajo() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Muelle m = new Muelle("01", cord, true, 2,1); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, -2); } - @Test(expected = IllegalArgumentException.class) - public void testColocarContenedorYaApilado() { + @Test(expected = IllegalStateException.class) + public void testColocarContenedorMuelleFueraServicio() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Muelle m = new Muelle("01", cord, true, 2,1); + Muelle m = new Muelle("01", cord, estado.FUERA_DE_SERVICIO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 0); - m.colocarContenedorEnPlaza(c, 1); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = IllegalStateException.class) public void testColocarContenedorEnTransito() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - Muelle m = new Muelle("01", cord, true, 2,1); - c.cambiarEstadoATransito(); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 0); } - @Test(expected = IllegalArgumentException.class) - public void testColocarContenedorEncimaDeUnoSinTecho() { + @Test(expected = IllegalStateException.class) + public void testColocarContenedorYaApilado() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, false); - Muelle m = new Muelle("01", cord, true, 1,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); m.colocarContenedorEnPlaza(c, 0); - Contenedor c2 = new Contenedor("ZTG", 'J', "582940", 100, 400, 500, false, false); - m.colocarContenedorEnPlaza(c2, 0); + m.colocarContenedorEnPlaza(c, 1); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = IllegalStateException.class) public void testColocarContenedorEnPlazaLLena() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 1); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + m.colocarContenedorEnPlaza(c1, 0); m.colocarContenedorEnPlaza(c2, 0); } - @Test(expected = IllegalArgumentException.class) - public void testColocarContenedorEnDosMuelles() { + @Test(expected = IllegalStateException.class) + public void testColocarContenedorEncimaDeUnoSinTecho() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, false); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + m.colocarContenedorEnPlaza(c1, 0); + m.colocarContenedorEnPlaza(c2, 0); } - + @Test public void testSacarContenedorDePlaza() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, false); + m.colocarContenedorEnPlaza(c1, 0); + assertEquals(1, m.plazasLlenas()); + m.sacarContenedorDePlaza(c1); + assertEquals(0, m.plazasLlenas()); } @Test(expected = IllegalArgumentException.class) public void testSacarContenedorDePlazaContenedorVacio() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,1); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); m.sacarContenedorDePlaza(null); } - @Test(expected = IllegalArgumentException.class) - public void testSacarContenedorDePlazaQueNoEstaApilado() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 - public void testAlternarTechoContenedor() { + @Test(expected = IllegalStateException.class) + public void testSacarContenedorEnTransito() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false); + m.sacarContenedorDePlaza(c1); } - @Test(expected = IllegalArgumentException.class) - public void testAlternarTechoContenedorVacio() { + @Test(expected = IllegalStateException.class) + public void testSacarContenedorMuelleFueraServicio() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,2); - m.alternarTechoContenedor(null); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, false); + m.colocarContenedorEnPlaza(c1, 0); + m.alternarOperativo(); + m.sacarContenedorDePlaza(c1); } - @Test(expected = IllegalArgumentException.class) - public void testAlternarTechoContenedorQueNoEsta() { + @Test(expected = IllegalStateException.class) + public void testSacarContenedorDePlazaQueNoEstaApilado() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,2); - Contenedor c = new Contenedor("ZRE", 'J', "056731", 100, 400, 500, false, true); - m.alternarTechoContenedor(c); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, false); + m.sacarContenedorDePlaza(c1); } - @Test(expected = IllegalArgumentException.class) - public void testAlternarTechoContenedorQueNoEstaEnUltimaPlaza() { + @Test(expected = IllegalStateException.class) + public void testSacarContenedorDePlazaQueNoEstaEnUltimoNivel() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); + ISO6346 i1 = new ISO6346("ZRE", 'J', 56731); + ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); + Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); + m.colocarContenedorEnPlaza(c1, 0); m.colocarContenedorEnPlaza(c2, 0); - m.alternarTechoContenedor(c); + m.sacarContenedorDePlaza(c1); } @Test public void testAlternarOperativo() { GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,2); + Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); m.alternarOperativo(); assertFalse(m.estaOperativo()); m.alternarOperativo(); assertTrue(m.estaOperativo()); } - - @Test - public void testGestionPlazasGeneral() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, true, 1,3); - Muelle m2 = new Muelle("01", cord, true, 1,2); - 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); - } - } \ No newline at end of file