diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Place.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Place.java index c09e1bf..3834101 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Place.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Place.java @@ -31,6 +31,6 @@ public class Place implements Serializable { } public void change(Place place) { - //TODO: If Place gets more developt in future releases + //TODO: If Place gets more developed in future releases } } diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java index 3150c95..44b3817 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java @@ -108,9 +108,8 @@ public class Tournament implements Serializable { * Method to add a new Place, also checks if place does already exist. * * @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) { if (place.equals(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 */ diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java index 94655aa..ddc4873 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java @@ -148,7 +148,7 @@ public class TournamentDecorator implements IsObservable{ public void savePlace(String name){ try { - tournament.addPlace(new Place(name)); + tournament.savePlace(new Place(name)); factoryDecorator.clearMessage(true); informListener(); } catch (InvalidNameException e) { diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/TournamentTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/TournamentTest.java index 135d5c5..3acc30c 100644 --- a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/TournamentTest.java +++ b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/TournamentTest.java @@ -1,6 +1,5 @@ package ch.zhaw.projekt2.turnierverwaltung; -import javafx.application.Platform; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -88,11 +87,11 @@ public class TournamentTest { when(place.equals(any(Place.class))).thenReturn(false).thenReturn(true); assertEquals(0, tournament.getPlaces().size()); - tournament.addPlace(place); + tournament.savePlace(place); assertEquals(1, tournament.getPlaces().size()); - tournament.addPlace(place); + tournament.savePlace(place); assertEquals(2, tournament.getPlaces().size()); - tournament.addPlace(place); + tournament.savePlace(place); assertEquals(2, tournament.getPlaces().size()); } @@ -103,7 +102,7 @@ public class TournamentTest { assertThrows(Tournament.PlaceNotExistsException.class, () -> tournament.removePlace(place)); - tournament.addPlace(place); + tournament.savePlace(place); assertEquals(1, tournament.getPlaces().size()); try { tournament.removePlace(place);