]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/dbObjects/TestUser.java
add: handling of RA Agent Contract
[gigi.git] / tests / club / wpia / gigi / dbObjects / TestUser.java
index ed3f1c951b3df52d3dd31ad693df7227e7a4b83d..e7aa70cff60c09cf2660f03222424b0c527c8542 100644 (file)
@@ -6,11 +6,13 @@ import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.sql.Date;
 
+import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.dbObjects.CATS.CATSType;
 import club.wpia.gigi.dbObjects.NamePart.NamePartType;
+import club.wpia.gigi.testUtils.ArrayContains;
 import club.wpia.gigi.testUtils.ClientBusinessTest;
 
 public class TestUser extends ClientBusinessTest {
@@ -105,4 +107,31 @@ public class TestUser extends ClientBusinessTest {
         assertTrue(u.hasValidTTPAgentChallenge());
     }
 
+    @Test
+    public void testHasContract() throws GigiApiException {
+        assertEquals(false, Contract.hasSignedContract(u, Contract.ContractType.RA_AGENT_CONTRACT));
+
+        Contract c = new Contract(u, Contract.ContractType.RA_AGENT_CONTRACT);
+        getMailReceiver().receive(u.getEmail());
+        assertEquals(true, Contract.hasSignedContract(u, Contract.ContractType.RA_AGENT_CONTRACT));
+
+        c.revokeContract();
+        getMailReceiver().receive(u.getEmail());
+        assertEquals(false, Contract.hasSignedContract(u, Contract.ContractType.RA_AGENT_CONTRACT));
+    }
+
+    @Test
+    public void testWriteUserLog() throws GigiApiException {
+        String type = "Log test";
+        u.writeUserLog(u, type);
+        String[] result = u.getAdminLog();
+        assertThat(result, ArrayContains.contains(CoreMatchers.equalTo(type)));
+
+        String type1 = "Log test1";
+        u.writeUserLog(u, type1);
+        result = u.getAdminLog();
+        assertThat(result, ArrayContains.contains(CoreMatchers.equalTo(type1)));
+        assertThat(result, ArrayContains.contains(CoreMatchers.equalTo(type)));
+    }
+
 }