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

MuelleTest haciendolo

parent e3f2e1ea
Branches
No related tags found
No related merge requests found
......@@ -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.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");
}
/**
......
......@@ -110,5 +110,4 @@ public class Plaza {
public int altura() {
return this.altura;
}
}
\ No newline at end of file
/**
* 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
}
*/
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment