DataHandler updated
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandlerForTests.java
index 55a142c..7c76508 100644 (file)
@@ -196,6 +196,9 @@ public class DataHandlerForTests implements DataHandler {
                        throw new Exception("No implementation on DataHandlerForTests possible");
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public boolean editReservation(Reservation reservation) {
                if (reservation == null) {
@@ -209,6 +212,9 @@ public class DataHandlerForTests implements DataHandler {
                return false;
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public boolean deleteReservation(Reservation reservation) {
                if (reservation == null) {
@@ -221,22 +227,56 @@ public class DataHandlerForTests implements DataHandler {
                }
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public Set<Resource> getAllResources() {
 
                return resourceList;
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public boolean editResource(Resource resource) {
-               // TODO Auto-generated method stub
+               if (resource == null) {
+                       throw new IllegalArgumentException("Resource object must not be null!");
+               }
+               if (findResource(resource.getName()) != null) {
+                       resourceList.remove(findResource(resource.getName()));
+                       resourceList.add(resource);
+                       return true;
+               }
                return false;
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public boolean deleteResource(Resource resource) {
-               // TODO Auto-generated method stub
-               return false;
+               if (resource == null) {
+                       throw new IllegalArgumentException("Resource object must not be null!");
+               } else if (resourceList.contains(resource)) {
+                       resourceList.remove(resource);
+                       return true;
+               } else {
+                       return false;
+               }
        }
 
+       @Override
+       public boolean editUser(User user) {
+               if (user == null) {
+                       throw new IllegalArgumentException("User object must not be null!");
+               }
+               if (findUser(user.getName()) != null) {
+                       userList.remove(findUser(user.getName()));
+                       userList.add(user);
+                       return true;
+               }
+               return false;
+       }
 }