UserTest updated
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / dataschema / UserTest.java
index 51696d3..13715cf 100644 (file)
@@ -11,9 +11,10 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;\r
 import static org.junit.Assert.assertTrue;\r
 \r
+import java.util.Set;\r
+\r
 import org.junit.Test;\r
 \r
-import ch.bfh.ti.srs.dataschema.User;\r
 import ch.bfh.ti.srs.extern.Password;\r
 \r
 /**\r
@@ -160,4 +161,38 @@ public class UserTest {
                testUser.setLastname(null);\r
                assertEquals(null, testUser.getLastname());\r
        }\r
+       \r
+       @Test\r
+       public void RoleTest() throws Exception{\r
+               User testUser = new User("TestUser", "pass");\r
+               Set<Role> roles = testUser.getRoles();\r
+               assertTrue(roles.contains(Role.User));\r
+               assertFalse(roles.contains(Role.ResourceManager));\r
+               assertFalse(roles.contains(Role.Admin));\r
+               \r
+               testUser.addRole(Role.ResourceManager);\r
+               roles = testUser.getRoles();\r
+               assertTrue(roles.contains(Role.User));\r
+               assertTrue(roles.contains(Role.ResourceManager));\r
+               assertFalse(roles.contains(Role.Admin));\r
+               \r
+               testUser.removeRole(Role.User);\r
+               roles = testUser.getRoles();\r
+               assertFalse(roles.contains(Role.User));\r
+               assertTrue(roles.contains(Role.ResourceManager));\r
+               assertFalse(roles.contains(Role.Admin));\r
+               \r
+               testUser.removeRole(Role.Admin);\r
+               roles = testUser.getRoles();\r
+               assertFalse(roles.contains(Role.User));\r
+               assertTrue(roles.contains(Role.ResourceManager));\r
+               assertFalse(roles.contains(Role.Admin));\r
+       }\r
+       \r
+       @Test\r
+       public void cloneTest() throws Exception{\r
+               User testUser = new User("TestUser", "pass");\r
+               User clonedUser = testUser.clone();\r
+               assertEquals(testUser.getUserName(), clonedUser.getUserName());\r
+       }\r
 }\r