diff --git a/src/es/markse/Combinado.java b/src/es/markse/Combinado.java index cc461bc3c11494336d9bdc5575380c5c518fd965..0265dc172d3cfe7ce47557280623f6eeb9ad0548 100644 --- a/src/es/markse/Combinado.java +++ b/src/es/markse/Combinado.java @@ -59,9 +59,6 @@ public abstract class Combinado extends Trayecto { for (int i = 0; i<(ts.size() - 1); i++) { Simple t1 = ts.get(i); Simple t2 = ts.get(i + 1); - if (t1 == null || t2 == null) { - throw new IllegalArgumentException("Hay trayectos nulos en la lista"); - } if (!comprobarDestinoOrigenIguales(t1, t2)) return false; } diff --git a/uses/es/markse/CombinadoTest.java b/uses/es/markse/CombinadoTest.java index 5bfc7c4c90cd5e1dce94d2ad99cc8f96747fdd38..9b2eea773f2df1865a3bb8ccef14979c0fa49335 100644 --- a/uses/es/markse/CombinadoTest.java +++ b/uses/es/markse/CombinadoTest.java @@ -29,6 +29,7 @@ public class CombinadoTest{ trayectosSimples.add(tb); new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); } + @Test(expected=IllegalArgumentException.class) public void testEstanVacios() { Muelle muelleOrigen = new Muelle("01", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); @@ -43,12 +44,7 @@ public class CombinadoTest{ Muelle muelleConexion = new Muelle("01", new GPSCoordinate(10.0, -15.0), estado.OPERATIVO, 10, 3, true, false); Puerto puertoConexion = new Puerto("IT", "NAP"); puertoConexion.anyadirMuelle(muelleConexion); - Fecha fechaConexion = new Fecha(25,10,2015); - TCamion tc = new TCamion(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleConexion, puertoConexion, fechaConexion); - TTren tt = new TTren(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); - //trayectosSimples.add(tc); - //trayectosSimples.add(tt); - PackCamionTren pct = new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); + new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); } @Test(expected = IllegalArgumentException.class) @@ -92,7 +88,7 @@ public class CombinadoTest{ TTren tt = new TTren(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); trayectosSimples.add(tc); trayectosSimples.add(tt); - PackCamionTren pct = new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); + new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); } @@ -116,12 +112,12 @@ public class CombinadoTest{ TCamion tt = new TCamion(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); trayectosSimples.add(tc); trayectosSimples.add(tt); - PackCamionTren pct = new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); + new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); } - @Test(expected = IllegalArgumentException.class) - public void testFechasImposibles() { - Muelle muelleOrigen = new Muelle("02", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); + @Test + public void testCosteTrayecto() { + Muelle muelleOrigen = new Muelle("01", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); Muelle muelleDestino = new Muelle("02", new GPSCoordinate(15.0, -15.0), estado.OPERATIVO, 10, 3, true, false); Puerto puertoOrigen = new Puerto("ES", "BAR"); Puerto puertoDestino = new Puerto("ES", "VAL"); @@ -139,10 +135,11 @@ public class CombinadoTest{ trayectosSimples.add(tc); trayectosSimples.add(tb); PackCamionTren pct = new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); + assertEquals(pct.precioTrayectoEnEuros(), 71138.12, 0.01f); } - - @Test() - public void testCosteTrayecto() { + + @Test (expected = IllegalArgumentException.class) + public void testPackCamionTrenOrdenTrayectosInvalido() { Muelle muelleOrigen = new Muelle("01", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); Muelle muelleDestino = new Muelle("02", new GPSCoordinate(15.0, -15.0), estado.OPERATIVO, 10, 3, true, false); Puerto puertoOrigen = new Puerto("ES", "BAR"); @@ -154,18 +151,59 @@ public class CombinadoTest{ ArrayList<Simple> trayectosSimples = new ArrayList<>(); Muelle muelleConexion = new Muelle("01", new GPSCoordinate(10.0, -15.0), estado.OPERATIVO, 10, 3, true, false); Puerto puertoConexion = new Puerto("IT", "NAP"); - puertoConexion.anyadirMuelle(muelleConexion); Fecha fechaConexion = new Fecha(25,10,2015); TCamion tc = new TCamion(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleConexion, puertoConexion, fechaConexion); - TTren tb = new TTren(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); + TTren tb = new TTren(muelleDestino,puertoDestino, fechaConexion, muelleConexion, puertoConexion, fechaFinTrayecto); trayectosSimples.add(tc); trayectosSimples.add(tb); - PackCamionTren pct = new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); - double x =pct.precioTrayectoEnEuros(); + new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); } - - -} - - + + @Test (expected = IllegalArgumentException.class) + public void testPackCamionTrayectosOrigenInvalidos() { + Muelle muelleOrigen = new Muelle("01", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); + Muelle muelleDestino = new Muelle("02", new GPSCoordinate(15.0, -15.0), estado.OPERATIVO, 10, 3, true, false); + Puerto puertoOrigen = new Puerto("ES", "BAR"); + Puerto puertoDestino = new Puerto("ES", "VAL"); + puertoOrigen.anyadirMuelle(muelleOrigen); + puertoDestino.anyadirMuelle(muelleDestino); + Fecha fechaInicioTrayecto = new Fecha(20, 10, 2015); + Fecha fechaFinTrayecto = new Fecha(30, 10, 2015); + ArrayList<Simple> trayectosSimples = new ArrayList<>(); + Muelle muelleConexion = new Muelle("01", new GPSCoordinate(10.0, -15.0), estado.OPERATIVO, 10, 3, true, false); + Puerto puertoConexion = new Puerto("IT", "NAP"); + puertoConexion.anyadirMuelle(muelleConexion); + Fecha fechaConexion = new Fecha(25,10,2015); + TCamion tc = new TCamion(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleConexion, puertoConexion, fechaConexion); + TTren tt = new TTren(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); + trayectosSimples.add(tc); + trayectosSimples.add(tt); + new PackCamionTren(muelleDestino, puertoDestino, fechaInicioTrayecto, muelleDestino, puertoDestino, fechaFinTrayecto, trayectosSimples); + } + + @Test (expected = IllegalArgumentException.class) + public void testPackCamionTrayectosDestinoInvalidos() { + Muelle muelleOrigen = new Muelle("01", new GPSCoordinate(10.0, 15.0), estado.OPERATIVO, 10, 3, true, false); + Muelle muelleDestino = new Muelle("02", new GPSCoordinate(15.0, -15.0), estado.OPERATIVO, 10, 3, true, false); + Puerto puertoOrigen = new Puerto("ES", "BAR"); + Puerto puertoDestino = new Puerto("ES", "VAL"); + puertoOrigen.anyadirMuelle(muelleOrigen); + puertoDestino.anyadirMuelle(muelleDestino); + Fecha fechaInicioTrayecto = new Fecha(20, 10, 2015); + Fecha fechaFinTrayecto = new Fecha(30, 10, 2015); + ArrayList<Simple> trayectosSimples = new ArrayList<>(); + Muelle muelleConexion = new Muelle("01", new GPSCoordinate(10.0, -15.0), estado.OPERATIVO, 10, 3, true, false); + Puerto puertoConexion = new Puerto("IT", "NAP"); + puertoConexion.anyadirMuelle(muelleConexion); + Fecha fechaConexion = new Fecha(25,10,2015); + TCamion tc = new TCamion(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleConexion, puertoConexion, fechaConexion); + TTren tt = new TTren(muelleConexion,puertoConexion, fechaConexion, muelleDestino, puertoDestino, fechaFinTrayecto); + trayectosSimples.add(tc); + trayectosSimples.add(tt); + new PackCamionTren(muelleOrigen, puertoOrigen, fechaInicioTrayecto, muelleOrigen, puertoOrigen, fechaInicioTrayecto, trayectosSimples); + } + + + +} \ No newline at end of file