Merge remote-tracking branch 'origin/development'
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandlerForTests.java
index 18229b5..39d8897 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,10 +227,56 @@ public class DataHandlerForTests implements DataHandler {
                }
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
        public Set<Resource> getAllResources() {
 
                return resourceList;
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean editResource(Resource resource) {
+               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) {
+               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.getUserName()) != null) {
+                       userList.remove(findUser(user.getUserName()));
+                       userList.add(user);
+                       return true;
+               }
+               return false;
+       }
 }