]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/util/TestNotary.java
fix: counting of nucleus verifications
[gigi.git] / tests / org / cacert / gigi / util / TestNotary.java
index fd3e62ef6e073855fcf2353c4a18aabd93ad952c..e8f709daf40db9ef0c55e3f3fdd86a671d042999 100644 (file)
@@ -2,6 +2,7 @@ package org.cacert.gigi.util;
 
 import static org.junit.Assert.*;
 
+import java.io.IOException;
 import java.sql.SQLException;
 import java.util.Date;
 
@@ -10,6 +11,10 @@ import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
 import org.cacert.gigi.dbObjects.Country;
 import org.cacert.gigi.dbObjects.Country.CountryCodeType;
+import org.cacert.gigi.dbObjects.Group;
+import org.cacert.gigi.dbObjects.Name;
+import org.cacert.gigi.dbObjects.NamePart;
+import org.cacert.gigi.dbObjects.NamePart.NamePartType;
 import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.DateSelector;
@@ -123,4 +128,26 @@ public class TestNotary extends BusinessTest {
         assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", validVerificationDateString());
 
     }
+
+    @Test
+    public void testNucleus() throws SQLException, GigiApiException, IOException {
+        User assuranceUser = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
+        assuranceUser.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER);
+        User assuree = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
+        Name n1 = assuree.getPreferredName();
+        Name n2 = new Name(assuree, new NamePart(NamePartType.FIRST_NAME, "F2"), new NamePart(NamePartType.LAST_NAME, "L2"));
+
+        assertEquals(0, assuree.getExperiencePoints());
+        assertEquals(User.EXPERIENCE_POINTS, assuranceUser.getExperiencePoints());
+        assertEquals(0, assuree.getAssurancePoints());
+        assertEquals(0, n2.getAssurancePoints());
+        Notary.assureAll(assuranceUser, assuree, assuree.getDoB(), 50, "notary-junit-test", validVerificationDateString(), AssuranceType.NUCLEUS, new Name[] {
+                n1, n2
+        }, DE);
+        assertEquals(0, assuree.getExperiencePoints());
+        assertEquals(2 * User.EXPERIENCE_POINTS, assuranceUser.getExperiencePoints());
+        assertEquals(50, assuree.getAssurancePoints());
+        assertEquals(50, n1.getAssurancePoints());
+        assertEquals(50, n2.getAssurancePoints());
+    }
 }