Test initial user class.
authorFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:38:55 +0000 (00:38 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:38:55 +0000 (00:38 +0200)
tests/org/cacert/gigi/TestUser.java
tests/org/cacert/gigi/testUtils/ManagedTest.java

index b72363079d594c58f821a1f6e0721a5796b88d24..61fc752990e700dd1920da62c13eb9abf6e5dfa9 100644 (file)
@@ -23,4 +23,34 @@ public class TestUser extends ManagedTest {
                User u2 = new User(id);
                assertEquals(u, u2);
        }
+
+       @Test
+       public void testWebStoreAndLoad() throws SQLException {
+               int id = createVerifiedUser("aä", "b", createUniqueName()
+                               + "a@email.org", "xvXV12°§");
+
+               User u = new User(id);
+               assertEquals("aä", u.getFname());
+               assertEquals("b", u.getLname());
+               assertEquals("", u.getMname());
+       }
+
+       @Test
+       public void testAssurerUtilMethods() throws SQLException {
+               int id = createAssuranceUser("aä", "b", createUniqueName()
+                               + "a@email.org", "xvXV12°§");
+
+               User u = new User(id);
+               assertTrue(u.canAssure());
+               int assurancePoints = u.getAssurancePoints();
+               int expPoints = u.getExperiencePoints();
+               assertEquals(100, assurancePoints);
+               assertEquals(2, expPoints);
+               assertTrue(u.hasPassedCATS());
+               assertEquals(10, u.getMaxAssurePoints());
+
+               assertEquals("aä", u.getFname());
+               assertEquals("b", u.getLname());
+               assertEquals("", u.getMname());
+       }
 }
index 869d417a47b7b932795e3bb6d32e20f075345cb0..9b77f87c1e0ba64445394ce0267e67dd7fdc4252 100644 (file)
@@ -220,6 +220,20 @@ public class ManagedTest {
                        throw new Error(e);
                }
        }
+       /**
+        * Creates a new user with 100 Assurance points given by an (invalid)
+        * assurance.
+        * 
+        * @param firstName
+        *            the first name
+        * @param lastName
+        *            the last name
+        * @param email
+        *            the email
+        * @param password
+        *            the password
+        * @return a new userid.
+        */
        public int createAssuranceUser(String firstName, String lastName,
                        String email, String password) {
                int uid = createVerifiedUser(firstName, lastName, email, password);