implement TournamentTest
This commit is contained in:
parent
40cfd69436
commit
127e152637
|
@ -31,6 +31,6 @@ public class Place implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void change(Place place) {
|
public void change(Place place) {
|
||||||
//TODO: If Place gets more developt in future releases
|
//TODO: If Place gets more developed in future releases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,8 @@ public class Tournament implements Serializable {
|
||||||
* Method to add a new Place, also checks if place does already exist.
|
* Method to add a new Place, also checks if place does already exist.
|
||||||
*
|
*
|
||||||
* @param newPlace to be added in the list of all places
|
* @param newPlace to be added in the list of all places
|
||||||
* @throws PlaceExistsException if the place already exists
|
|
||||||
*/
|
*/
|
||||||
public void addPlace(Place newPlace) {
|
public void savePlace(Place newPlace) {
|
||||||
for (Place place : places) {
|
for (Place place : places) {
|
||||||
if (place.equals(newPlace)) {
|
if (place.equals(newPlace)) {
|
||||||
place.change(newPlace);
|
place.change(newPlace);
|
||||||
|
@ -301,20 +300,6 @@ public class Tournament implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom Exception thrown when a Place does already exist
|
|
||||||
*/
|
|
||||||
public class PlaceExistsException extends Exception {
|
|
||||||
public PlaceExistsException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceExistsException(String errorMessage) {
|
|
||||||
super(errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Exception thrown when a Place does not exist
|
* Custom Exception thrown when a Place does not exist
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class TournamentDecorator implements IsObservable{
|
||||||
|
|
||||||
public void savePlace(String name){
|
public void savePlace(String name){
|
||||||
try {
|
try {
|
||||||
tournament.addPlace(new Place(name));
|
tournament.savePlace(new Place(name));
|
||||||
factoryDecorator.clearMessage(true);
|
factoryDecorator.clearMessage(true);
|
||||||
informListener();
|
informListener();
|
||||||
} catch (InvalidNameException e) {
|
} catch (InvalidNameException e) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung;
|
package ch.zhaw.projekt2.turnierverwaltung;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
|
@ -88,11 +87,11 @@ public class TournamentTest {
|
||||||
when(place.equals(any(Place.class))).thenReturn(false).thenReturn(true);
|
when(place.equals(any(Place.class))).thenReturn(false).thenReturn(true);
|
||||||
|
|
||||||
assertEquals(0, tournament.getPlaces().size());
|
assertEquals(0, tournament.getPlaces().size());
|
||||||
tournament.addPlace(place);
|
tournament.savePlace(place);
|
||||||
assertEquals(1, tournament.getPlaces().size());
|
assertEquals(1, tournament.getPlaces().size());
|
||||||
tournament.addPlace(place);
|
tournament.savePlace(place);
|
||||||
assertEquals(2, tournament.getPlaces().size());
|
assertEquals(2, tournament.getPlaces().size());
|
||||||
tournament.addPlace(place);
|
tournament.savePlace(place);
|
||||||
assertEquals(2, tournament.getPlaces().size());
|
assertEquals(2, tournament.getPlaces().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ public class TournamentTest {
|
||||||
|
|
||||||
assertThrows(Tournament.PlaceNotExistsException.class, () -> tournament.removePlace(place));
|
assertThrows(Tournament.PlaceNotExistsException.class, () -> tournament.removePlace(place));
|
||||||
|
|
||||||
tournament.addPlace(place);
|
tournament.savePlace(place);
|
||||||
assertEquals(1, tournament.getPlaces().size());
|
assertEquals(1, tournament.getPlaces().size());
|
||||||
try {
|
try {
|
||||||
tournament.removePlace(place);
|
tournament.removePlace(place);
|
||||||
|
|
Loading…
Reference in New Issue