diff --git a/src/es/markse/Muelle.java b/src/es/markse/Muelle.java index 2954afc0f90f9c1b5a2dc59729e28be7917a7504..20c01e4ac5229df07d063818d0b68cf6461c7d46 100644 --- a/src/es/markse/Muelle.java +++ b/src/es/markse/Muelle.java @@ -28,16 +28,24 @@ public class Muelle { * @param altura numero maximo de contenedores que se pueden apilar encima de otro */ public Muelle (String identificador, GPSCoordinate cord, boolean operativo, int plazas, int altura) { + comprobarValoresNulos(identificador, cord); comprobarValoresMuelle(identificador, plazas, altura); this.identificador = identificador; - this.cord=cord; - this.operativo=operativo; - this.plazas = new Plaza[plazas]; + this.cord = cord; this.plazasVacias = plazas; + this.plazas = new Plaza[plazas]; + this.operativo = operativo; + //Inicializamos el array de las plazas for (int i = 0; i < plazas; i++) { this.plazas[i] = new Plaza(altura); } + + } + + private void comprobarValoresNulos(String identificador, GPSCoordinate cord) { + if (identificador == null) throw new IllegalArgumentException("Identificador no puede ser nulo"); + if (cord == null) throw new IllegalArgumentException("Identificador no puede ser nulo"); } /** diff --git a/src/es/markse/Plaza.java b/src/es/markse/Plaza.java index 8b27d6525682d45577cbe13c0dbbb25624c33956..a6b478cdbf0b43c1165c7c6207b196c964699e3d 100644 --- a/src/es/markse/Plaza.java +++ b/src/es/markse/Plaza.java @@ -110,5 +110,4 @@ public class Plaza { public int altura() { return this.altura; } - -} +} \ No newline at end of file diff --git a/uses/es/markse/MuelleTest.java b/uses/es/markse/MuelleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d130945f2d9c3d75666d93e795d906f0a1071e25 --- /dev/null +++ b/uses/es/markse/MuelleTest.java @@ -0,0 +1,139 @@ +/** + * Copyrigth Universidad de Valladolid 2024/2025 + */ +package es.markse; +import static org.junit.Assert.*; +import org.junit.Test; + +import es.uva.inf.poo.maps.GPSCoordinate; + +/** + * Realizacion de los Test de la Clase Muelle. Esta clase gestiona la propia clase Plaza, por lo que + * en la realizacion de estos test se probaran los funcionamientos de los metodos de la clase Plaza. + * @author javcalv + * @author victorm + */ + +public class MuelleTest { + + + @Test + public final void testMuelle() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, true, 2,2); + assertEquals("01", m.getIdentificador()); + assertEquals(cord, m.getGPSCoordinate()); + assertTrue(m.estaOperativo()); + assertEquals(2, m.numeroDePlazasTotales()); + } + + @Test(expected = IllegalArgumentException.class) + public final void testMuelleIdentificadorVacio() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + new Muelle(null, cord, true, 2,2); + } + + @Test(expected = IllegalArgumentException.class) + public final void testMuelleGPSVacio() { + new Muelle("04", null, true, 2,2); + } + + @Test(expected = IllegalArgumentException.class) + public final void testMuelleIdentificadorInalido() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + new Muelle("r3", cord, true, 2,2); + } + + @Test(expected = IllegalArgumentException.class) + public final void testMuellePlazasInvalida() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + new Muelle("12", cord, true, -3,2); + } + + @Test(expected = IllegalArgumentException.class) + public final void testMuelleAlturaInvalida() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + new Muelle("12", cord, true, 1,-2); + } + + + @Test + public final void testGetIdentificador() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, true, 2,2); + assertEquals("01", m.getIdentificador()); + } + + + @Test + public final void testEstaOperativo() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m1 = new Muelle("01", cord, true, 2,2); + Muelle m2 = new Muelle("02", cord, false, 2,2); + assertTrue(m1.estaOperativo()); + assertFalse(m2.estaOperativo()); + } + + + @Test + public final void testGetGPSCoordinate() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, true, 2,2); + assertEquals(cord, m.getGPSCoordinate()); + } + + + @Test + public final void testNumeroDePlazasTotales() { + GPSCoordinate cord = new GPSCoordinate(5d, 5d); + Muelle m = new Muelle("01", cord, true, 2,2); + assertEquals(2,m.numeroDePlazasTotales()); + } + + /* + @Test + public final void testPlazasVacias() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testPlazasLlenas() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testPlazasSemillenas() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testPlazaActual() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testNivelEnPlaza() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testColocarContenedorEnPlaza() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testSacarContenedorDePlaza() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testAlternarTechoContenedor() { + fail("Not yet implemented"); // TODO + } + + @Test + public final void testAlternarOperativo() { + fail("Not yet implemented"); // TODO + } + */ +}