Skip to content
Snippets Groups Projects
Commit 7d5d5494 authored by Javier Calvo's avatar Javier Calvo
Browse files

Transformacion completa

parent f47adcae
No related branches found
No related tags found
No related merge requests found
......@@ -44,11 +44,14 @@ public class Contenedor {
* @param techo indica si tiene techo (true) o no (false)
*/
public Contenedor(ISO6346 codigo, float pesoTara, float maximaCargaUtil, float volumen, estados estadoActual, pesos pesoSeleccionado, volumenes volumenSeleccionado, boolean techo) {
if (pesoTara<0 || maximaCargaUtil <0 || volumen<0)
if (pesoTara<=0 || maximaCargaUtil <=0 || volumen<=0)
throw new IllegalArgumentException("Los pesos no puedne ser menores a 0");
this.codigo = codigo;
this.pesoTara = pesoTara;
this.maximaCargaUtil = maximaCargaUtil;
this.volumen = volumen;
this.estadoActual = estadoActual;
this.pesoSeleccionado = pesoSeleccionado;
this.volumenSeleccionado = volumenSeleccionado;
......@@ -132,25 +135,25 @@ public class Contenedor {
* Metodo que sirve para anyadir un trayecto al contenedor
* @param t El trayecto que se añade al contenedor
* @throws IllegalArgumentException si es trayecto es nulo,
* @throws IllegalArgumentException si la fecha fin del ultimo trayecto es superior a la de inicio del nuevo trayecto
* @throws IllegalArgumentException si el puerto/muelle destinos del ultimo trayecto no son los de origen del nuevo.
* @throws IllegalStateException si la fecha fin del ultimo trayecto es superior a la de inicio del nuevo trayecto
* @throws IllegalStateException si el puerto/muelle destinos del ultimo trayecto no son los de origen del nuevo.
*/
public void anyadirTrayecto(Trayecto t) {
if (t == null)
throw new IllegalArgumentException("El trayecto no puede ser nulo");
if (this.trayectos.size() == 0)
if (this.trayectos.isEmpty())
this.trayectos.add(t);
else {
Trayecto ultimoT = this.trayectos.get(this.trayectos.size() -1);
//Si la fecha fin es mayor a la de inicio del nuevo
if (ultimoT.getFechaFinTrayecto().getDiasDesdeEpoch() > t.getFechaInicioTrayecto().getDiasDesdeEpoch())
throw new IllegalArgumentException("La fecha fin del ultimo trayecto no puede ser mayor la fecha de inicio del siguiente");
throw new IllegalStateException("La fecha fin del ultimo trayecto no puede ser mayor la fecha de inicio del siguiente");
//Si el puerto destino no es el origen del nuevo
if (!ultimoT.getPuertoDestino().identificadorPuerto().equals(t.getPuertoOrigen().identificadorPuerto()))
throw new IllegalArgumentException("El puerto de origen debe ser el mismo que el de destino del ultimo trayecto");
throw new IllegalStateException("El puerto de origen debe ser el mismo que el de destino del ultimo trayecto");
//Si el muelle de destino no es el de origen del nuevo
if (!ultimoT.getMuelleDestino().getIdentificador().equals(t.getMuelleOrigen().getIdentificador()))
throw new IllegalArgumentException("El Muelle de origen debe de ser igual al de destino de su ultimo trayecto");
throw new IllegalStateException("El Muelle de origen debe de ser igual al de destino de su ultimo trayecto");
this.trayectos.add(t);
}
}
......@@ -167,9 +170,18 @@ public class Contenedor {
* Metodo que devuelve la maxima carga util de un contenedor
* @return La maxima carga util de un contenedor
*/
public float cargaUtilContenedor() {
return this.maximaCargaUtil;
public float cargaUtilContenedorKilos() {
return (this.pesoSeleccionado == pesos.KILOS ) ? this.maximaCargaUtil : this.maximaCargaUtil *this.LIBRAS_A_KILOS;
}
/**
* Metodo que devuelve la maxima carga util de un contenedor
* @return La maxima carga util de un contenedor
*/
public float cargaUtilContenedorLibras() {
return (this.pesoSeleccionado == pesos.LIBRAS ) ? this.maximaCargaUtil : this.maximaCargaUtil *this.KILOS_A_LIBRAS;
}
/**
* Metodo que sirve para devolver el codigo del contenedor
* @return el codigo del contenedor (compelto)
......
......
File changed. Contains only whitespace changes. Show whitespace changes.
......@@ -36,7 +36,7 @@ public class Trayecto {
throw new IllegalArgumentException("Las fechas no pueden ser nulas");
//Comprobamos si los muelles estan operativos
if (!muelleOrigen.estaOperativo() || !muelleDestino.estaOperativo())
if (!muelleOrigen.estaOperativo())
throw new IllegalStateException("El muelle de origen esta fuera de servicio");
if (!muelleDestino.estaOperativo())
throw new IllegalStateException("El muelle de destino esta fuera de servicio");
......@@ -48,8 +48,8 @@ public class Trayecto {
throw new MuelleNoPerteneceAlPuertoException("El muelle no pertenece al puerto");
if (!comprobacionMuellesDistintos(muelleOrigen, muelleDestino, puertoOrigen, puertoDestino))
throw new IllegalStateException("El muelle de origen no puede ser igual al de destino");
if(comprobacionOrdenFechas(fechaInicioTrayecto,fechaFinTrayecto))
throw new IllegalArgumentException("El muelle de origen no puede ser igual al de destino");
if(fechaInicioTrayecto.getDiasDesdeEpoch()>fechaFinTrayecto.getDiasDesdeEpoch())
throw new IllegalArgumentException ("La Fecha del Inicio del Trayecto no puede ser posterior a la fecha del Fin del Trayecto");
this.muelleOrigen=muelleOrigen;
......@@ -67,21 +67,8 @@ public class Trayecto {
* @return true si los muelles son distintos o false si son los mismos
*/
private boolean comprobacionMuellesDistintos(Muelle muelleOrigen, Muelle muelleDestino, Puerto puertoOrigen, Puerto puertoDestino) {
if (muelleOrigen.getIdentificador() == muelleDestino.getIdentificador() && puertoOrigen.identificadorPuerto().equals(puertoDestino.identificadorPuerto())) {
return false;
}
return true;
}
/**
* Método que Comprueba si el Orden de las Fechas de Inicio y del Final del Trayecto es el adecuado.
* @throws IllegalArgumentException Si la Fecha del Inicio del Trayecto es Posterior a la Fecha del Fin del Trayecto, lo cual es Imposible.
*/
private boolean comprobacionOrdenFechas(Fecha fechaInicioTrayecto, Fecha fechaFinTrayecto) {
if (fechaInicioTrayecto.getDiasDesdeEpoch()>fechaFinTrayecto.getDiasDesdeEpoch()){
return false;
}
return true;
return (muelleOrigen.getIdentificador() == muelleDestino.getIdentificador() &&
puertoOrigen.identificadorPuerto().equals(puertoDestino.identificadorPuerto())) ? false : true;
}
/*********************************************
......@@ -94,7 +81,8 @@ public class Trayecto {
* @return True si la Fecha de Fin de Trayecto es Superior, y False si la Fecha de Fin de Trayecto no es Superior
*/
public boolean FechaFinTrayectoSuperior(Fecha fechaDada) {
if (fechaDada == null) throw new IllegalArgumentException("Fecha no puede ser nula");
if (fechaDada == null)
throw new IllegalArgumentException("Fecha no puede ser nula");
if (fechaFinTrayecto.getDiasDesdeEpoch()>fechaDada.getDiasDesdeEpoch()) {
return false;
}
......@@ -151,7 +139,7 @@ public class Trayecto {
/**
* Metodo que devuelve el numero de dias de un trayecto
*/
public int numeroDeDiasDeTrayceto(){
private int numeroDeDiasDeTrayceto(){
return (this.fechaFinTrayecto.getDiasDesdeEpoch()- this.fechaInicioTrayecto.getDiasDesdeEpoch()) +1;
}
......
......
......@@ -5,6 +5,10 @@ package es.markse;
import static org.junit.Assert.*;
import org.junit.Test;
import es.markse.Contenedor.estados;
import es.markse.Contenedor.pesos;
import es.markse.Contenedor.volumenes;
import es.markse.Muelle.estado;
import es.uva.inf.poo.maps.GPSCoordinate;
/**
......@@ -16,232 +20,230 @@ public class ContenedorTest {
@Test
public void testContenedor() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
assertEquals("RTFZ0654328", c.getCodigo());
assertEquals(100.0f, c.obtenerPesoKilos(), 0.001f);
Contenedor c2 = new Contenedor("ABC", 'U', "123456", 200, 500, 1000, true, true);
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);
ISO6346 i1 = new ISO6346("ZRE", 'J', 56731);
Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
assertEquals("ZREJ0567310", c1.getCodigo());
assertEquals(100.0f, c1.obtenerPesoKilos(), 0.001f);
assertEquals(400.0f, c1.cargaUtilContenedorKilos(), 0.001f);
assertEquals(500.0f, c1.volumenEnMetrosCubicos(), 0.001f);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorCodigoDuenoNulo(){
new Contenedor(null, 'U', "123456", 200, 500, 1000, true, true);
public void testContenedorTaraInvalida(){
ISO6346 i1 = new ISO6346("ZRE", 'J', 56731);
new Contenedor(i1, -0.54f, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorCodigoDuenoInvalido(){
new Contenedor("e34", 'J', "123456", 200, 500, 1000, true, true);
public void testContenedorCargaInvalida(){
ISO6346 i1 = new ISO6346("ZRE", 'J', 56731);
new Contenedor(i1, 100, 0, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorCodigoDuenoTamanyoInvalido(){
new Contenedor("e34433", 'Z', "123456", 200, 500, 1000, true, true);
public void testContenedorVolumenInvalida(){
ISO6346 i1 = new ISO6346("ZRE", 'J', 56731);
new Contenedor(i1, 100, 400, -0.45f, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorEquipamientoInvalido(){
new Contenedor("e34433", 'R', "123456", 200, 500, 1000, true, true);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorEquipamientoInvalido_R(){
new Contenedor("ABC", 'R', "123456", 200, 500, 1000, true, true);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorEquipamientoInvalido_X(){
new Contenedor("DEF", 'X', "654321", 300, 600, 1200, false, false);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorNumeroSerieNulo(){
new Contenedor("DEF", 'J', null, 300, 600, 1200, false, false);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorNumeroSerieLetras(){
new Contenedor("DEF", 'J', "R450T0", 300, 600, 1200, false, false);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorNumeroSerieInvalido(){
new Contenedor("DEF", 'J', "59392020", 300, 600, 1200, false, false);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorTaraMenorA1(){
new Contenedor("DEF", 'J', "134567", 0, 600, 1200, false, false);
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorCargaMenorA1(){
new Contenedor("DEF", 'J', "134567", 100, -4, 1200, false, false);
@Test
public final void testCambiarEstadoARecogida() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, true);
assertFalse(c.contenedorEnRecogida());
c.cambiarEstadoARecogida();
assertTrue(c.contenedorEnRecogida());
}
@Test(expected = IllegalArgumentException.class)
public void testContenedorVolumenMenorA1(){
new Contenedor("DEF", 'J', "134567", 100, 600, 0.5f, false, false);
@Test
public final void testCambiarEstadoATransito() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
assertFalse(c.contenedorEnTransito());
c.cambiarEstadoATransito();
assertTrue(c.contenedorEnTransito());
}
@Test
public final void testTieneTecho() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
Contenedor c2 = new Contenedor("ACC", 'Z', "493212", 100, 400, 1000, false, false);
public final void testAlternarTecho() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false);
assertFalse(c.tieneTecho());
c.alternarTecho();
assertTrue(c.tieneTecho());
assertFalse(c2.tieneTecho());
c.alternarTecho();
assertFalse(c.tieneTecho());
}
@Test
public final void testCambiarEstadoARecogida() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, true, true);
c.cambiarEstadoARecogida();
assertTrue(c.estadoRecogida());
assertFalse(c.estadoTransito());
Contenedor c2 = new Contenedor("RTT", 'Z', "555432", 100, 400, 1000, false, true);
GPSCoordinate cord = new GPSCoordinate(5d, 5d);
Muelle m = new Muelle("01", cord, true, 2,2);
m.colocarContenedorEnPlaza(c2, 0);
assertFalse(c2.estadoRecogida());
public void testVolumenEnMetrosCubicos() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false);
assertEquals(500f, c.volumenEnMetrosCubicos(), 0.01f);
ISO6346 i2 = new ISO6346("DRT", 'U', 56731);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.PIES, false);
assertEquals(500 * 0.0283168f, c2.volumenEnMetrosCubicos(), 0.01f);
}
@Test(expected = IllegalArgumentException.class)
public final void testCambiarEstadoARecogidaContenedorApilado() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
GPSCoordinate cord = new GPSCoordinate(5d, 5d);
Muelle m = new Muelle("01", cord, true, 2,2);
m.colocarContenedorEnPlaza(c, 0);
c.cambiarEstadoARecogida();
@Test
public void testVolumenEnPiesCubicos() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false);
assertEquals(500f * 35.3147f, c.volumenEnPiesCubicos(), 0.01f);
ISO6346 i2 = new ISO6346("DRT", 'U', 56731);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.PIES, false);
assertEquals(500f, c2.volumenEnPiesCubicos(), 0.001f);
}
@Test
public final void testCambiarEstadoATransito() {
Contenedor c = new Contenedor("RTT", 'Z', "555432", 100, 400, 1000, false, true);
assertFalse(c.estadoTransito());
c.cambiarEstadoATransito();
assertTrue(c.estadoTransito());
public void testObtenerPesoKilos() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false);
assertEquals(100f, c.obtenerPesoKilos(), 0.01f);
ISO6346 i2 = new ISO6346("DFT", 'J', 589012);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
assertEquals(100f *0.453592, c2.obtenerPesoKilos(), 0.01f);
}
@Test (expected = IllegalArgumentException.class)
public final void testCambiarEstadoATransitoContenedorApilado() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
GPSCoordinate cord = new GPSCoordinate(5d, 5d);
Muelle m = new Muelle("01", cord, true, 2,2);
assertFalse(c.estadoTransito());
m.colocarContenedorEnPlaza(c, 1);
assertFalse(c.estadoTransito());
c.cambiarEstadoATransito();
@Test
public void testObtenerPesoLibras() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
assertEquals(100f, c.obtenerPesoLibras(), 0.01f);
ISO6346 i2 = new ISO6346("DRT", 'U', 56731);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.PIES, false);
assertEquals(100f * 2.20462, c2.obtenerPesoLibras(), 0.01f);
}
@Test
public void testVolumenEnPiesCubicos() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
assertEquals(1000*35.3147f, c.volumenEnPiesCubicos(), 0.001f);
public void testCargaUtilContenedorKilos() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.METROS, false);
assertEquals(400f, c.cargaUtilContenedorKilos(), 0.01f);
ISO6346 i2 = new ISO6346("DRT", 'U', 56731);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.PIES, false);
assertEquals(400f *0.453592, c2.cargaUtilContenedorKilos(), 0.01f);
}
@Test
public void testObtenerPesoLibras() {
Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
assertEquals(100*2.20462f, c.obtenerPesoLibras(), 0.001f);
public void testCargaUtilContenedorLibras() {
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
assertEquals(400f, c.cargaUtilContenedorLibras(), 0.01f);
ISO6346 i2 = new ISO6346("DRT", 'U', 56731);
Contenedor c2 = new Contenedor(i2, 100, 400, 500, estados.TRANSITO, pesos.KILOS, volumenes.PIES, false);
assertEquals(400f * 2.20462, c2.cargaUtilContenedorLibras(), 0.01f);
}
@Test
public void testAnyadirTrayecto() {
Contenedor c = new Contenedor("RTS", 'U', "056413", 100, 200, 1000, false, true);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
Muelle m1 = new Muelle("01", new GPSCoordinate(5d,5d), true, 1, 1);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), true, 1, 1);
Puerto origen = new Puerto("ES" , "BAR");
Puerto destino = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("01", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
origen.anyadirMuelle(m1);
destino.anyadirMuelle(m2);
assertTrue(origen.comprobarMuelleEnPuerto(m1));
assertTrue(destino.comprobarMuelleEnPuerto(m2));
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
Trayecto t1 = new Trayecto(m1,origen,fInicio,m2,destino,fFin);
c.anyadirTrayecto(t1);
Muelle m3= new Muelle("02", new GPSCoordinate(10d,10d), true, 1, 1);
Muelle m3 = new Muelle("02", new GPSCoordinate(13d,11d), estado.OPERATIVO, 2, 2);
destino.anyadirMuelle(m3);
Fecha fFinal = new Fecha(1,12,2024);
Trayecto t2 = new Trayecto(m2,destino,fFin,m3,destino,fFinal);
Trayecto t2 = new Trayecto(m2,destino,fFin,m3,destino,fFin);
c.anyadirTrayecto(t2);
}
@Test (expected = IllegalArgumentException.class)
public void testAnyadirTrayectoNulo() {
Contenedor c = new Contenedor("RTS", 'U', "056413", 100, 200, 1000, false, true);
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
c.anyadirTrayecto(null);
}
@Test(expected = IllegalArgumentException.class)
public void testAnyadirTrayectoFechaOrigenAntesQueFinalDeUltimoTrayecto() {
Contenedor c = new Contenedor("RTS", 'U', "056413", 100, 200, 1000, false, true);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
Muelle m1 = new Muelle("01", new GPSCoordinate(5d,5d), true, 1, 1);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), true, 1, 1);
@Test (expected = IllegalStateException.class)
public void testAnyadirTrayectoFechaInicialAnteriorALaFinalDelUltimo() {
Puerto origen = new Puerto("ES" , "BAR");
Puerto destino = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("01", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
origen.anyadirMuelle(m1);
destino.anyadirMuelle(m2);
assertTrue(origen.comprobarMuelleEnPuerto(m1));
assertTrue(destino.comprobarMuelleEnPuerto(m2));
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
Trayecto t1 = new Trayecto(m1,origen,fInicio,m2,destino,fFin);
c.anyadirTrayecto(t1);
Muelle m3= new Muelle("02", new GPSCoordinate(10d,10d), true, 1, 1);
Muelle m3 = new Muelle("02", new GPSCoordinate(13d,11d), estado.OPERATIVO, 2, 2);
destino.anyadirMuelle(m3);
Fecha fOrigen = new Fecha(29,11,2024);
Fecha fFinal = new Fecha(1,12,2024);
Trayecto t2 = new Trayecto(m2,destino,fOrigen,m3,destino,fFinal);
Fecha fInicioT2 = new Fecha(29,11,2024);
Trayecto t2 = new Trayecto(m2,destino,fInicioT2,m3,destino,fFin);
c.anyadirTrayecto(t2);
}
@Test(expected = IllegalArgumentException.class)
public void testAnyadirTrayectoPuertoOrigenDistintoAlPuertoDestinoAnteriro() {
Contenedor c = new Contenedor("RTS", 'U', "056413", 100, 200, 1000, false, true);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
Muelle m1 = new Muelle("01", new GPSCoordinate(5d,5d), true, 1, 1);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), true, 1, 1);
@Test (expected = IllegalStateException.class)
public void testAnyadirTrayectoPuertosDistintos() {
Puerto origen = new Puerto("ES" , "BAR");
Puerto destino = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("01", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
origen.anyadirMuelle(m1);
destino.anyadirMuelle(m2);
assertTrue(origen.comprobarMuelleEnPuerto(m1));
assertTrue(destino.comprobarMuelleEnPuerto(m2));
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
Trayecto t1 = new Trayecto(m1,origen,fInicio,m2,destino,fFin);
c.anyadirTrayecto(t1);
Muelle m3= new Muelle("02", new GPSCoordinate(10d,10d), true, 1, 1);
Muelle m3 = new Muelle("02", new GPSCoordinate(13d,11d), estado.OPERATIVO, 2, 2);
destino.anyadirMuelle(m3);
Fecha fFin2 = new Fecha(4,12,2024);
Trayecto t2 = new Trayecto(m2,origen,fFin,m3,destino,fFin2);
Trayecto t2 = new Trayecto(m2,origen,fFin,m3,destino,fFin);
c.anyadirTrayecto(t2);
}
@Test(expected = IllegalArgumentException.class)
public void testAnyadirTrayectoMuelleOrigenDistintoAlMuelleDestinoAnteriro() {
Contenedor c = new Contenedor("RTS", 'U', "056413", 100, 200, 1000, false, true);
@Test (expected = IllegalStateException.class)
public void testAnyadirTrayectoMuellesDistintos() {
Puerto origen = new Puerto("ES" , "BAR");
Puerto destino = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("01", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
Muelle m1 = new Muelle("01", new GPSCoordinate(5d,5d), true, 1, 1);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), true, 1, 1);
origen.anyadirMuelle(m1);
destino.anyadirMuelle(m2);
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
Trayecto t1 = new Trayecto(m1,origen,fInicio,m2,destino,fFin);
c.anyadirTrayecto(t1);
Muelle m3 = new Muelle("42", new GPSCoordinate(15d,15d), estado.OPERATIVO, 2, 2);
destino.anyadirMuelle(m3);
Trayecto t2 = new Trayecto(m3,destino,fFin,m2,destino,fFin);
c.anyadirTrayecto(t2);
}
@Test
public void testPrecioTransporteTotalContenedor() {
Puerto origen = new Puerto("ES" , "BAR");
Puerto destino = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("01", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("01", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha fInicio = new Fecha (25,11,2024);
Fecha fFin = new Fecha(30,11,2024);
origen.anyadirMuelle(m1);
destino.anyadirMuelle(m2);
assertTrue(origen.comprobarMuelleEnPuerto(m1));
assertTrue(destino.comprobarMuelleEnPuerto(m2));
ISO6346 i = new ISO6346("ZRE", 'J', 56731);
Contenedor c = new Contenedor(i, 100, 400, 500, estados.TRANSITO, pesos.LIBRAS, volumenes.METROS, false);
assertEquals(0.0f, c.precioTransporteTotalContenedor(50f, 0.5f),0.01f);
Trayecto t1 = new Trayecto(m1,origen,fInicio,m2,destino,fFin);
c.anyadirTrayecto(t1);
Muelle m3= new Muelle("02", new GPSCoordinate(11d,11d), true, 1, 1);
Muelle m3 = new Muelle("02", new GPSCoordinate(13d,11d), estado.OPERATIVO, 2, 2);
destino.anyadirMuelle(m3);
Muelle mNuevo= new Muelle("03", new GPSCoordinate(12d,12d), true, 1, 1);
destino.anyadirMuelle(mNuevo);
Fecha fFin2 = new Fecha(4,12,2024);
Trayecto t2 = new Trayecto(m3,destino,fFin,mNuevo,destino,fFin2);
Trayecto t2 = new Trayecto(m2,destino,fFin,m3,destino,fFin);
c.anyadirTrayecto(t2);
assertEquals(1432.395f, c.precioTransporteTotalContenedor(50f, 0.5f), 0.01f);
}
}
\ No newline at end of file
package es.markse;
import static org.junit.Assert.*;
import org.junit.Test;
import es.markse.Muelle.estado;
import es.markse.Trayecto.MuelleNoPerteneceAlPuertoException;
import es.uva.inf.poo.maps.GPSCoordinate;
public class TrayectoTest {
@Test
public void testTrayecto() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(m1,t.getMuelleOrigen());
assertEquals(p1,t.getPuertoOrigen());
......@@ -28,301 +27,246 @@ public class TrayectoTest {
}
@Test (expected = IllegalArgumentException.class)
public void testTrayectoFechaNull() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
public void testTrayectoMuelleOrigenNulo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p2.anyadirMuelle(m2);
Fecha f2 = new Fecha(11,11,2024);
new Trayecto(m1,p1,null,m2,p2,f2);
new Trayecto(null,p1,f1,m2,p2,f2);
}
@Test (expected = IllegalArgumentException.class)
public void testTrayectoMuelleNoPertenecePuerto() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
public void testTrayectoMuelleDestinoNulo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
new Trayecto(m1,p1,f1,null,p2,f2);
}
@Test (expected = IllegalArgumentException.class)
public void testTrayectoPuertoOrigenNulo() {
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
new Trayecto(m1,null,f1,m2,p2,f2);
}
@Test (expected = IllegalArgumentException.class)
public void testTrayectoFechaInicioPosteriorAFin() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
public void testTrayectoPuertoDestinoNulo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f2,m2,p2,f1);
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
new Trayecto(m1,p1,f1,m2,null,f2);
}
@Test
public void testGetMuelleOrigen() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(m1,t.getMuelleOrigen());
@Test (expected = IllegalArgumentException.class)
public void testTrayectoFechaOrigenNulo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f2 = new Fecha(30,11,2024);
new Trayecto(m1,p1,null,m2,p2,f2);
}
@Test
public void testGetMuelleDestino() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(m2,t.getMuelleDestino());
@Test (expected = IllegalArgumentException.class)
public void testTrayectoFechaFinNulo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
new Trayecto(m1,p1,f1,m2,p2,null);
}
@Test
public void testGetPuertoOrigen() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(p1,t.getPuertoOrigen());
@Test (expected = IllegalStateException.class)
public void testTrayectoMuelleOrigenFueraDeServicio() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.FUERA_DE_SERVICIO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
new Trayecto(m1,p1,f1,m2,p2,f2);
}
@Test
public void testGetPuertoDestino() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(p2,t.getPuertoDestino());
@Test (expected = IllegalStateException.class)
public void testTrayectoMuelleDestinoFueraDeServicio() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.FUERA_DE_SERVICIO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
new Trayecto(m1,p1,f1,m2,p2,f2);
}
@Test
public void testGetFechaInicioTrayecto() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
p1.anyadirMuelle(m1);
@Test (expected = MuelleNoPerteneceAlPuertoException.class)
public void testTrayectoMuelleOrigenNoEstaEnPuerto() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(f1,t.getFechaInicioTrayecto());
new Trayecto(m1,p1,f1,m2,p2,f2);
}
@Test
public void testGetFechaFinTrayecto() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("AR","BUE");
@Test (expected = MuelleNoPerteneceAlPuertoException.class)
public void testTrayectoMuelleDestinoNoEstaEnPuerto() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertEquals(f2,t.getFechaFinTrayecto());
new Trayecto(m1,p1,f1,m2,p2,f2);
}
@Test (expected = IllegalArgumentException.class)
public void testcomprobacionMuellesDistintos() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("ES","PAL");
public void testTrayectoMuellesIguales() {
Puerto p1 = new Puerto("ES" , "BAR");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
new Trayecto(m1,p1,f1,m1,p1,f2);
}
@Test(expected = IllegalArgumentException.class)
public void testcomprobacionFecha() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,false,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("ES","VAL");
@Test
public void testTrayectoMuellesIgualesPeroPuertosNo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("12", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(5,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
new Trayecto(m1,p1,f1,m2,p2,f2);
}
@Test (expected = IllegalArgumentException.class)
public void testcomprobacionFechaNula() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("02",c2,false,2,2);
Puerto p1 = new Puerto ("ES","PAL");
Puerto p2 = new Puerto ("ES","VAL");
public void testFechaInicioPosteriorAFin() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = null;
new Trayecto(m1,p1,f1,m2,p2,f2);
new Trayecto(m1,p1,f2,m2,p2,f1);
}
@Test
public void testFechaFinTrayectoSuperior() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
public void testFechaFinTrayectoSuperiorTrue() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
assertFalse(t.FechaFinTrayectoSuperior(f1));
Fecha f3 = new Fecha(13,11,2024);
assertTrue(t.FechaFinTrayectoSuperior(f3));
Fecha fecha = new Fecha(03,12,2024);
assertTrue(t.FechaFinTrayectoSuperior(fecha));
}
@Test(expected = IllegalArgumentException.class)
public void testFechaFinTrayectoSuperiorNula() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(5d,5d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c1,true,2,2);
@Test
public void testFechaFinTrayectoSuperiorFalse() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
t.FechaFinTrayectoSuperior(null);
assertFalse(t.FechaFinTrayectoSuperior(f1));
}
@Test
public void testDistanciaMillasMarinas() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c2,true,2,2);
@Test (expected = IllegalArgumentException.class)
public void testFechaFinTrayectoSuperiorNula() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(-3d, 20d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
double v = 781.1062793857914;
assertEquals(v, t.distanciaMillasMarinas(), 0.001);
assertFalse(t.FechaFinTrayectoSuperior(null));
}
@Test
public void testprecioTrayectoEurosBien() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c2,true,2,2);
public void testPrecioTransporeEuros() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(0d, 0d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
t.precioTrayectoEnEuros(5,5);
assertEquals(1865.1090f, t.precioTrayectoEnEuros(50f, 1f), 0.01f);
}
@Test (expected = IllegalArgumentException.class)
public void testprecioTrayectoEurosMalPrimero() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c2,true,2,2);
public void testPrecioTransporeEurosCosteDiarioNegativo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(0d, 0d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
t.precioTrayectoEnEuros(0,5);
t.precioTrayectoEnEuros(-5f, 1f);
}
@Test (expected = IllegalArgumentException.class)
public void testprecioTrayectoEurosMalSegundo() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c2,true,2,2);
public void testPrecioTransporeEurosCosteMillaNegativo() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(0d, 0d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
t.precioTrayectoEnEuros(5,0);
t.precioTrayectoEnEuros(50f, -1f);
}
@Test
public void testinforTrayecto() {
GPSCoordinate c1 = new GPSCoordinate(5d,5d);
GPSCoordinate c2 = new GPSCoordinate(10d,10d);
Muelle m1 = new Muelle ("01",c1,true,2,2);
Muelle m2 = new Muelle ("01",c2,true,2,2);
public void testInforTrayceto() {
Puerto p1 = new Puerto("ES" , "BAR");
Puerto p2 = new Puerto ("AR","BUE");
Puerto p2 = new Puerto("IT" , "NAP");
Muelle m1 = new Muelle("12", new GPSCoordinate(0d, 0d), estado.OPERATIVO, 2, 2);
Muelle m2 = new Muelle("34", new GPSCoordinate(10d,10d), estado.OPERATIVO, 2, 2);
Fecha f1 = new Fecha (25,11,2024);
Fecha f2 = new Fecha(30,11,2024);
p1.anyadirMuelle(m1);
p2.anyadirMuelle(m2);
Fecha f1 = new Fecha (9,11,2024);
Fecha f2 = new Fecha(11,11,2024);
Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
t.inforTrayecto();
String str = t.inforTrayecto();
assertEquals(str, t.inforTrayecto());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment