diff --git a/src/es/markse/FlatRack.java b/src/es/markse/FlatRack.java index abc0fb71f8ecf8ee10925085ffacdfb273cee9c0..ed5cd492cf09a7d190142fe53f19a0b5d415f2e6 100644 --- a/src/es/markse/FlatRack.java +++ b/src/es/markse/FlatRack.java @@ -19,11 +19,11 @@ public class FlatRack extends Contenedor{ throw new IllegalArgumentException("No"); } - if (t instanceof TPackCamionBarco) { + if (t instanceof PackCamionBarco) { throw new IllegalArgumentException("No"); } - if (t instanceof TPackCamionTren) { + if (t instanceof PackCamionTren) { throw new IllegalArgumentException("No"); } diff --git a/src/es/markse/TPackCamionBarco.java b/src/es/markse/PackCamionBarco.java similarity index 95% rename from src/es/markse/TPackCamionBarco.java rename to src/es/markse/PackCamionBarco.java index 59691136fa599335d982728015c2951e368deee1..f12e73c403443c6d7d1cbd0c8634a6fd07e9571f 100644 --- a/src/es/markse/TPackCamionBarco.java +++ b/src/es/markse/PackCamionBarco.java @@ -10,7 +10,7 @@ import java.util.ArrayList; * @author javcalv * @author victorm */ -public class TPackCamionBarco extends TCombinado { +public class PackCamionBarco extends TCombinado { //Descuentos que se aplican private final double DESCUENTO = 0.85; @@ -26,7 +26,7 @@ public class TPackCamionBarco extends TCombinado { * @param trayectosCamion arrayList con los trayectos * @param trayectosBarco */ - public TPackCamionBarco(Muelle muelleOrigen, Puerto puertoOrigen, Fecha fechaInicioTrayecto, Muelle muelleDestino, + public PackCamionBarco(Muelle muelleOrigen, Puerto puertoOrigen, Fecha fechaInicioTrayecto, Muelle muelleDestino, Puerto puertoDestino, Fecha fechaFinTrayecto, ArrayList<TSimple> trayectosSimples) { super(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto); diff --git a/src/es/markse/TPackCamionTren.java b/src/es/markse/PackCamionTren.java similarity index 96% rename from src/es/markse/TPackCamionTren.java rename to src/es/markse/PackCamionTren.java index c671c0e4cfb73891db8ce3abedaeefef294aa4a0..c15e7f510b8b0b6250ba5da49d480d0e1d0f7e57 100644 --- a/src/es/markse/TPackCamionTren.java +++ b/src/es/markse/PackCamionTren.java @@ -9,7 +9,7 @@ import java.util.ArrayList; * @author javcalv * @author victorm */ -public class TPackCamionTren extends TCombinado { +public class PackCamionTren extends TCombinado { //Reduccion de los precios private final int RED_COSTE_FIJO = 0; @@ -30,7 +30,7 @@ public class TPackCamionTren extends TCombinado { * @throws IllegalArgumentException Si no se encuentra un solo trayecto de tren en la lista * @throws IllegalArgumentException Si El orden de los trayectos no es correcto */ - public TPackCamionTren(Muelle muelleOrigen, Puerto puertoOrigen, Fecha fechaInicioTrayecto, Muelle muelleDestino, + public PackCamionTren(Muelle muelleOrigen, Puerto puertoOrigen, Fecha fechaInicioTrayecto, Muelle muelleDestino, Puerto puertoDestino, Fecha fechaFinTrayecto, ArrayList<TSimple> trayectosSimples){ super(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto); diff --git a/src/es/markse/Refrigerado.java b/src/es/markse/Refrigerado.java index 4b7ba033aa8d2551b9cb6a0a71abec5f90116fb6..5652b4189ecb8d965a52048ff40cfceafb4b13c3 100644 --- a/src/es/markse/Refrigerado.java +++ b/src/es/markse/Refrigerado.java @@ -18,11 +18,11 @@ public class Refrigerado extends Contenedor{ throw new IllegalArgumentException("No"); } - if (t instanceof TPackCamionBarco) { + if (t instanceof PackCamionBarco) { throw new IllegalArgumentException("No"); } - if (t instanceof TPackCamionTren) { + if (t instanceof PackCamionTren) { throw new IllegalArgumentException("No"); } comprobarDatosContenedor(t); diff --git a/uses/es/markse/ISO6346Test.java b/uses/es/markse/ISO6346Test.java deleted file mode 100644 index db0ee907697b7ed57cae33395f2f5f911e898840..0000000000000000000000000000000000000000 --- a/uses/es/markse/ISO6346Test.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright Universidad de Valladolid 2024/2025 - */ -package es.markse; - -import static org.junit.Assert.*; -import org.junit.Test; - -/** - * Test para la clase ISO6346 - * @author javcalv - * @author victorm - */ -public class ISO6346Test { - - @Test - public final void testISO6346() { - ISO6346 codigo = new ISO6346("RTX", 'J', 893); - assertEquals("RTX", codigo.codigoDuenyo()); - assertEquals('J', codigo.equipamiento()); - assertEquals(893, codigo.numeroSerie()); - assertEquals("RTXJ0008931", codigo.codigoContenedor()); - } - - @Test - public final void testISO6346EquipamientoZ() { - ISO6346 codigo = new ISO6346("RTX", 'Z', 893); - assertEquals('Z', codigo.equipamiento()); - } - - @Test - public final void testISO6346EquipamientoU() { - ISO6346 codigo = new ISO6346("RTX", 'U', 893); - assertEquals('U', codigo.equipamiento()); - } - - @Test (expected = IllegalArgumentException.class) - public final void testISO6346CodigoNulo() { - new ISO6346(null, 'J', 893); - } - - @Test (expected = IllegalArgumentException.class) - public final void testISO6346CodigoInvalido() { - new ISO6346("r4", 'J', 893); - } - - @Test (expected = IllegalArgumentException.class) - public final void testISO6346EquipamientoInvalido() { - new ISO6346("r4", '4', 893); - } - - @Test (expected = IllegalArgumentException.class) - public final void testISO6346NumeroSerieMenor() { - new ISO6346("r4", '4', -405); - } - - @Test (expected = IllegalArgumentException.class) - public final void testISO6346NumeroSerieMayor() { - new ISO6346("r4", '4', 56789012); - } -} diff --git a/uses/es/markse/MuelleTest.java b/uses/es/markse/MuelleTest.java deleted file mode 100644 index 309b22f562068b8d0306fabf4f7bc1c06a016a53..0000000000000000000000000000000000000000 --- a/uses/es/markse/MuelleTest.java +++ /dev/null @@ -1,375 +0,0 @@ -/** - * Copyright UVa 2024/2025 - */ - -package es.markse; -import static org.junit.Assert.*; -import org.junit.Test; -import es.markse.Muelle.estado; -import es.markse.Contenedor.*; -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 - * indirectamente. - * @author javcalv - * @author victorm - */ - -public class MuelleTest { - - @Test - public void testMuelle() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 2); - assertEquals("01", m.getIdentificador()); - assertEquals(cord, m.getGPSCoordinate()); - assertTrue(m.estaOperativo()); - assertEquals(2, m.numeroDePlazasTotales()); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuelleIdentificadorVacio() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - new Muelle(null, cord, estado.OPERATIVO, 2, 2); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuelleGPSVacio() { - new Muelle("01", null, estado.OPERATIVO, 2, 2); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuelleIdentificadorInvalido() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - new Muelle("r3", cord, estado.OPERATIVO, 2, 2); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuelleIdentificadorPatronInvalido() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - new Muelle("r432432", cord, estado.OPERATIVO, 2, 2); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuellePlazasInvalida() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - new Muelle("01", cord, estado.OPERATIVO, -2, 2); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuelleAlturaInvalida() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - new Muelle("01", cord, estado.OPERATIVO, 2, -2); - } - - @Test - public void testGetIdentificador() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 2); - assertEquals("01", m.getIdentificador()); - } - - @Test - public void testEstaOperativo() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m1 = new Muelle("01", cord, estado.OPERATIVO, 2, 2); - Muelle m2 = new Muelle("02", cord, estado.FUERA_DE_SERVICIO, 2, 2); - assertTrue(m1.estaOperativo()); - assertFalse(m2.estaOperativo()); - } - - - @Test - public void testGetGPSCoordinate() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 2); - assertEquals(cord, m.getGPSCoordinate()); - } - - @Test - public void testNumeroDePlazasTotales() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 2); - assertEquals(2,m.numeroDePlazasTotales()); - } - - @Test - public void testPlazasVacias() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 2, 1); - assertEquals(2, m.plazasVacias()); - 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.plazasVacias()); - m.colocarContenedorEnPlaza(c2, 1); - assertEquals(0, m.plazasVacias()); - m.sacarContenedorDePlaza(c2); - assertEquals(1, m.plazasVacias()); - } - - @Test - public void testPlazasLlenas() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); - 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()); - m.colocarContenedorEnPlaza(c2, 0); - assertEquals(1, m.plazasLlenas()); - } - - @Test - public void testPlazasSemillenas() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); - assertEquals(0, m.plazasSemillenas()); - 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()); - c1.alternarTecho(); - assertEquals(0, m.plazasSemillenas()); - c1.alternarTecho(); - m.colocarContenedorEnPlaza(c2, 0); - assertEquals(0, m.plazasSemillenas()); - } - - @Test - public void testPlazaActual() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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())); - } - - @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, 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, estado.OPERATIVO, 10, 2); - m.plazaActual(null); - } - - - @Test - public void testNivelEnPlaza() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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, 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, estado.OPERATIVO, 10, 2); - m.nivelEnPlaza(null); - } - - @Test - public void testColocarContenedorEnPlaza() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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, estado.OPERATIVO, 1, 2); - m.colocarContenedorEnPlaza(null, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void testColocarContenedorEnPlazaFueraRangoArriba() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); - 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 = IllegalStateException.class) - public void testColocarContenedorMuelleFueraServicio() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); - } - - @Test(expected = IllegalStateException.class) - public void testColocarContenedorEnTransito() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 = IllegalStateException.class) - public void testColocarContenedorYaApilado() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); - m.colocarContenedorEnPlaza(c, 1); - } - - @Test(expected = IllegalStateException.class) - public void testColocarContenedorEnPlazaLLena() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 = IllegalStateException.class) - public void testColocarContenedorEncimaDeUnoSinTecho() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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); - 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, estado.OPERATIVO, 1, 2); - m.sacarContenedorDePlaza(null); - } - - @Test(expected = IllegalStateException.class) - public void testSacarContenedorEnTransito() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 = IllegalStateException.class) - public void testSacarContenedorMuelleFueraServicio() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 = IllegalStateException.class) - public void testSacarContenedorDePlazaQueNoEstaApilado() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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 = IllegalStateException.class) - public void testSacarContenedorDePlazaQueNoEstaEnUltimoNivel() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - 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.sacarContenedorDePlaza(c1); - } - - @Test - public void testAlternarOperativo() { - GPSCoordinate cord = new GPSCoordinate(5d, 5d); - Muelle m = new Muelle("01", cord, estado.OPERATIVO, 1, 2); - m.alternarOperativo(); - assertFalse(m.estaOperativo()); - m.alternarOperativo(); - assertTrue(m.estaOperativo()); - } -} \ No newline at end of file diff --git a/uses/es/markse/PuertoTest.java b/uses/es/markse/PuertoTest.java deleted file mode 100644 index b20f2bb7a96a14a3544ecce62480029989416afe..0000000000000000000000000000000000000000 --- a/uses/es/markse/PuertoTest.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - * Copyright UVa 2024/2025 - */ - -package es.markse; -import static org.junit.Assert.*; -import org.junit.Test; -import es.markse.Muelle.estado; -import es.markse.Contenedor.*; -import es.uva.inf.poo.maps.GPSCoordinate; - -/** - * Test realizados para la clase Puerto - * @author javcalv - * @author victorm - */ -public class PuertoTest { - - @Test - public void testPuerto() { - Puerto p = new Puerto("ES","BAR"); - assertEquals("ES", p.paisDelPuerto()); - assertEquals("BAR", p.ciudadDelPuerto()); - assertEquals("ES-BAR", p.identificadorPuerto()); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoPaisNulo() { - new Puerto(null, "BAR"); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoCiudadNulo() { - new Puerto("AG", null); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoNulo() { - new Puerto(null, null); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoCiudadInvalida() { - new Puerto("ES", "455"); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoPaisInvalido() { - new Puerto("R3", "VAL"); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreacionPuertoTodoInvalido() { - new Puerto("4R", "e32"); - } - - @Test - public void testAnyadirMuelle() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord = new GPSCoordinate(5d, 10d); - Muelle m = new Muelle("03", cord, estado.OPERATIVO, 40, 5); - assertTrue(p.anyadirMuelle(m)); - } - - @Test(expected = IllegalArgumentException.class) - public void testAnyadirMuelleNulo() { - Puerto p = new Puerto("ES","BAR"); - p.anyadirMuelle(null); - } - - - @Test - public void testAnyadirMuelleIDRepetido() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(5d, 10d); - GPSCoordinate cord2 = new GPSCoordinate(20d, -10d); - Muelle m = new Muelle("03", cord1, estado.OPERATIVO, 40, 5); - Muelle mismoID = new Muelle("03", cord2, estado.OPERATIVO, 40, 5); - p.anyadirMuelle(m); - assertFalse(p.anyadirMuelle(mismoID)); - } - - @Test - public void testAnyadirMuelleCoordenadaRepetida() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord = new GPSCoordinate(5d, 10d); - Muelle m = new Muelle("03", cord, estado.OPERATIVO, 40, 5); - Muelle mismaCoordenada = new Muelle("05", cord, estado.OPERATIVO, 40, 5); - p.anyadirMuelle(m); - assertFalse(p.anyadirMuelle(mismaCoordenada)); - } - - @Test - public void testEliminarMuelle() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord = new GPSCoordinate(5d, 10d); - Muelle m = new Muelle("03", cord, estado.OPERATIVO, 40, 5); - p.anyadirMuelle(m); - assertTrue(p.eliminarMuelle("03")); - } - - @Test(expected = IllegalArgumentException.class) - public void testEliminarMuelleNulo() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord = new GPSCoordinate(5d, 10d); - Muelle m = new Muelle("03", cord, estado.OPERATIVO, 40, 5); - p.anyadirMuelle(m); - p.eliminarMuelle(null); - } - - @Test(expected = IllegalArgumentException.class) - public void testEliminarMuelleVacio() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord = new GPSCoordinate(5d, 10d); - Muelle m = new Muelle("03", cord, estado.OPERATIVO, 40, 5); - p.anyadirMuelle(m); - p.eliminarMuelle(""); - } - - @Test - public void testEliminarMuelleQueNoEstaEnPuerto() { - Puerto p = new Puerto("ES","BAR"); - assertFalse(p.eliminarMuelle("05")); - } - - @Test - public void testComprobarSiEstaLleno() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(5d, 10d); - GPSCoordinate cord2 = new GPSCoordinate(20d, -10d); - Muelle m1 = new Muelle("01", cord1, estado.OPERATIVO, 1, 1); - p.anyadirMuelle(m1); - Muelle m2 = new Muelle("04", cord2, estado.OPERATIVO, 2, 1); - p.anyadirMuelle(m2); - ISO6346 i1 = new ISO6346("ZRE", 'J' , 56731); - ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); - ISO6346 i3 = new ISO6346("WCD", 'Z', 432012); - Contenedor c11 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - Contenedor c21 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - Contenedor c22 = new Contenedor(i3, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - m1.colocarContenedorEnPlaza(c11, 0); - m2.colocarContenedorEnPlaza(c21, 0); - m2.colocarContenedorEnPlaza(c22, 1); - assertTrue(p.comprobarSiEstaLleno()); - } - - @Test - public void testComprobarSiEstaLlenoEsFalso() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(5d, 10d); - GPSCoordinate cord2 = new GPSCoordinate(20d, -10d); - Muelle m1 = new Muelle("01", cord1, estado.OPERATIVO, 1, 1); - p.anyadirMuelle(m1); - Muelle m2 = new Muelle("04", cord2, estado.OPERATIVO, 2, 1); - p.anyadirMuelle(m2); - ISO6346 i1 = new ISO6346("ZRE", 'J' , 56731); - ISO6346 i2 = new ISO6346("RTZ", 'Z', 569026); - Contenedor c11 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - Contenedor c21 = new Contenedor(i2, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - m1.colocarContenedorEnPlaza(c11, 0); - m2.colocarContenedorEnPlaza(c21, 0); - assertFalse(p.comprobarSiEstaLleno()); - } - - @Test - public void testMuellesOperativos() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(5d, 10d); - GPSCoordinate cord2 = new GPSCoordinate(20d, -10d); - Muelle m1 = new Muelle("01", cord1, estado.OPERATIVO, 1, 1); - p.anyadirMuelle(m1); - Muelle m2 = new Muelle("04", cord2, estado.FUERA_DE_SERVICIO, 2, 1); - p.anyadirMuelle(m2); - Muelle[] muellesEsperados = {m1}; - assertArrayEquals(muellesEsperados, p.muellesOperativos()); - } - - @Test - public void testMuellesConEspacio() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(5d, 10d); - Muelle m1 = new Muelle("01", cord1, estado.OPERATIVO, 1, 1); - p.anyadirMuelle(m1); - Muelle[] muellesEsperados = {m1}; - assertArrayEquals(muellesEsperados, p.muellesConEspacio()); - ISO6346 i1 = new ISO6346("ZRE", 'J' , 56731); - Contenedor c11 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true); - m1.colocarContenedorEnPlaza(c11, 0); - assertEquals(0, p.muellesConEspacio().length); - } - - @Test - public void testMuellesCercanoAPunto() { - Puerto p = new Puerto("ES","BAR"); - GPSCoordinate cord1 = new GPSCoordinate(10d, 10d); - GPSCoordinate cord2 = new GPSCoordinate(-10d, -10d); - Muelle m1 = new Muelle("01", cord1, estado.OPERATIVO, 1, 1); - p.anyadirMuelle(m1); - Muelle m2 = new Muelle("04", cord2, estado.OPERATIVO, 2, 1); - p.anyadirMuelle(m2); - GPSCoordinate puntoDado = new GPSCoordinate(15d , 15d); - Muelle[] muelleCercanos = {m1}; - assertArrayEquals(muelleCercanos, p.muellesCercanoAPunto(puntoDado)); - puntoDado = new GPSCoordinate(0d , 0d); - Muelle[] muellesCercanos = {m1,m2}; - assertArrayEquals(muellesCercanos, p.muellesCercanoAPunto(puntoDado)); - } - - @Test(expected = IllegalArgumentException.class) - public void testMuellesCercanoAPuntoVacio() { - Puerto p = new Puerto("ES","BAR"); - p.muellesCercanoAPunto(null); - } -} \ No newline at end of file