DataHandler update
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandlerForTests.java
index 916047c..c23c5eb 100644 (file)
@@ -43,12 +43,17 @@ public class DataHandlerForTests implements DataHandler {
         * {@inheritDoc}
         */
        @Override
-       public void addUser(User user) throws Exception {
-               if (user == null)
+       public boolean addUser(User user) throws Exception {
+               if (user == null){
                        throw new IllegalArgumentException("User object must not be null!");
-               if (userList.contains(user))
-                       throw new IllegalArgumentException("User already  exists!");
-               userList.add(user);
+               }
+               else if (userList.contains(user)){
+                       return false;
+               }
+               else{
+                       userList.add(user);
+                       return true;
+               }
        }
 
        /**
@@ -67,12 +72,17 @@ public class DataHandlerForTests implements DataHandler {
         * {@inheritDoc}
         */
        @Override
-       public void addResource(Resource resource) throws Exception {
-               if (resource == null)
+       public boolean addResource(Resource resource) throws Exception {
+               if (resource == null){
                        throw new IllegalArgumentException("Resource object must not be null!");
-               if (resourceList.contains(resource))
-                       throw new IllegalArgumentException("Resource already  exists!");
-               resourceList.add(resource);
+               }
+               else if (resourceList.contains(resource)){
+                       return false;
+               }
+               else{
+                       resourceList.add(resource);
+                       return true;
+               }
        }
 
        /**
@@ -148,12 +158,17 @@ public class DataHandlerForTests implements DataHandler {
         * {@inheritDoc}
         */
        @Override
-       public void addReservation(Reservation reservation) throws Exception {
-               if (reservation == null)
+       public boolean addReservation(Reservation reservation) throws Exception {
+               if (reservation == null){
                        throw new IllegalArgumentException("Reservation object must not be null!");
-               if (resourceList.contains(reservation))
-                       throw new IllegalArgumentException("Reservation already  exists!");
-               reservationList.add(reservation);
+               }
+               else if(resourceList.contains(reservation)) {
+                       return false;
+               }
+               else{
+                       reservationList.add(reservation);
+                       return true;
+               }
        }
 
        /**