removed all checkstyle errors, updated sprint backlog
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / datahandler / DataHandlerForTestsTest.java
index 94ff551..bb3737c 100644 (file)
@@ -29,11 +29,11 @@ import ch.bfh.ti.srs.dataschema.User;
 /**
  * @author Michael Grossen
  */
-public class DataHandlerForTestsTest{
+public class DataHandlerForTestsTest {
 
        private DateRangeFactory factory;
        private Reservation testReservation;
-       private Reservation testReservation2; //same ID as testReservation
+       private Reservation testReservation2; // same ID as testReservation
        private Reservation testReservation3;
        private Reservation testReservation4;
        private Reservation testReservation5;
@@ -47,7 +47,8 @@ public class DataHandlerForTestsTest{
 
                User testUser = new User("TestUser", "pass");
                Resource testResource = new Resource("TestResource", "TestType");
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),
+                               DateFactory.createDate(2015, 11, 13));
                UUID groupid = UUID.randomUUID();
                testReservation = new Reservation(groupid, testUser, testResource, testDr, "TestReservation");
 
@@ -56,23 +57,25 @@ public class DataHandlerForTestsTest{
 
                User testUser3 = new User("TestUser3", "pass3");
                Resource testResource3 = new Resource("TestResource3", "TestType3");
-               DateRange testDr3 = factory.createDateRange(DateFactory.createDate(2016, 11, 9), DateFactory.createDate(2016, 11, 13));
+               DateRange testDr3 = factory.createDateRange(DateFactory.createDate(2016, 11, 9),
+                               DateFactory.createDate(2016, 11, 13));
                testReservation3 = new Reservation(groupid, testUser3, testResource3, testDr3, "TestReservation3");
 
                User testUser4 = new User("TestUser4", "pass4");
                Resource testResource4 = new Resource("TestResource4", "TestType4");
-               DateRange testDr4 = factory.createDateRange(DateFactory.createDate(2017, 11, 9), DateFactory.createDate(2017, 11, 13));
+               DateRange testDr4 = factory.createDateRange(DateFactory.createDate(2017, 11, 9),
+                               DateFactory.createDate(2017, 11, 13));
                UUID groupid4 = UUID.randomUUID();
                testReservation4 = new Reservation(groupid4, testUser4, testResource4, testDr4, "TestReservation4");
 
-               
-               DateRange testDr5 = factory.createDateRange(DateFactory.createDate(2015, 11, 10), DateFactory.createDate(2015, 11, 14));
+               DateRange testDr5 = factory.createDateRange(DateFactory.createDate(2015, 11, 10),
+                               DateFactory.createDate(2015, 11, 14));
                testReservation5 = new Reservation(groupid, testUser, testResource, testDr5, "TestReservation5");
-               
+
        }
 
        @Test
-       public void addUserTest() throws Exception{
+       public void addUserTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                User testUser = null;
                try {
@@ -83,15 +86,15 @@ public class DataHandlerForTestsTest{
                dh.addUser(testUser);
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void addIllegalUserTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void addIllegalUserTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                User testUser = null;
                dh.addUser(testUser);
        }
 
        @Test
-       public void addSameUserTest() throws Exception{
+       public void addSameUserTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                User testUser = null;
                try {
@@ -104,7 +107,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void findUserTest() throws Exception{
+       public void findUserTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                User addedUser = new User("TestUser", "pass");
                dh.addUser(addedUser);
@@ -113,7 +116,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void findNotAddedUser() throws Exception{
+       public void findNotAddedUser() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                assertEquals(null, dh.findUser("notAddedUser"));
                User addedUser = new User("TestUser", "pass");
@@ -122,7 +125,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void addResourceTest() throws Exception{
+       public void addResourceTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource testResource = null;
                try {
@@ -134,11 +137,12 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void addSameResourceTest() throws Exception{
+       public void addSameResourceTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource testResource = null;
                try {
-                       testResource = new Resource("TestResource", "TestType");;
+                       testResource = new Resource("TestResource", "TestType");
+                       ;
                } catch (Exception e) {
                        fail("Check UserTest (Exception was thrown by Resource Cunstructor)!");
                }
@@ -146,23 +150,24 @@ public class DataHandlerForTestsTest{
                assertEquals(false, dh.addResource(testResource));
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void addIllegalResourceTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void addIllegalResourceTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource testResource = null;
                dh.addResource(testResource);
        }
 
        @Test
-       public void findResourceTest() throws Exception{
+       public void findResourceTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource addedResource = new Resource("TestResource", "TestType");
                dh.addResource(addedResource);
                Resource foundResource = dh.findResource("TestResource");
                assertEquals(addedResource.getName(), foundResource.getName());
        }
+
        @Test
-       public void findNoResourceTest() throws Exception{
+       public void findNoResourceTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource addedResource = new Resource("TestResource", "TestType");
                Resource addedResource2 = new Resource("TestResource2", "TestType2");
@@ -172,7 +177,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void addResourceSameIdTest() throws Exception{
+       public void addResourceSameIdTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                Resource addedResource = new Resource("TestResource", "TestType");
                Resource addedResource2 = addedResource.clone();
@@ -183,13 +188,13 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void addReservationTest() throws Exception{
+       public void addReservationTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
        }
 
        @Test
-       public void findReservationTest() throws Exception{
+       public void findReservationTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                UUID testId = testReservation.getId();
                dh.addReservation(testReservation);
@@ -199,7 +204,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void findReservationFalseIdTest() throws Exception{
+       public void findReservationFalseIdTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
 
@@ -207,7 +212,7 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void editReservationTest() throws Exception{
+       public void editReservationTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
 
@@ -217,39 +222,39 @@ public class DataHandlerForTestsTest{
        }
 
        @Test
-       public void editReservationFalseIdTest() throws Exception{
+       public void editReservationFalseIdTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
 
                assertEquals(false, dh.editReservation(testReservation3));
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void findGroupReservationsNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void findGroupReservationsNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.findGroupReservations(null);
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void userReservationsNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void userReservationsNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.userReservations(null);
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void overlapsNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void overlapsNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.overlaps(null);
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void addReservationNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void addReservationNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(null);
        }
 
        @Test
-       public void addSameReservationTest() throws Exception{
+       public void addSameReservationTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
 
                dh.addReservation(testReservation);
@@ -257,50 +262,50 @@ public class DataHandlerForTestsTest{
                assertEquals(false, dh.addReservation(testReservation2));
 
        }
-       
+
        @Test
-       public void addReservationSameDateTest() throws Exception{
+       public void addReservationSameDateTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
 
                dh.addReservation(testReservation);
                assertEquals(false, dh.addReservation(testReservation5));
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void editReservationNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void editReservationNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.editReservation(null);
        }
 
-       @Test(expected=IllegalArgumentException.class)
-       public void deleteReservationsNullTest() throws Exception{
+       @Test(expected = IllegalArgumentException.class)
+       public void deleteReservationsNullTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.deleteReservation(null);
        }
 
        @Test
-       public void deleteReservationsFailTest() throws Exception{
+       public void deleteReservationsFailTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
                assertEquals(true, dh.deleteReservation(testReservation));
                assertEquals(false, dh.deleteReservation(testReservation2));
        }
 
-       @Test(expected=Exception.class)
-       public void refreshTest() throws Exception{
+       @Test(expected = Exception.class)
+       public void refreshTest() throws Exception {
                DataHandler dh = new DataHandlerForTests();
                dh.refresh(true);
        }
 
        @Test
-       public void findAllReservationsTest() throws Exception{
+       public void findAllReservationsTest() throws Exception {
                List<Reservation> allReservations = new ArrayList<Reservation>();
                DataHandler dh = new DataHandlerForTests();
                dh.addReservation(testReservation);
                dh.addReservation(testReservation3);
                dh.addReservation(testReservation4);
                allReservations = dh.findAllReservations();
-                       
+
                assertEquals(3, allReservations.size());
        }
 }