]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/wot/TestTTP.java
upd: rename package name and all references to it
[gigi.git] / tests / club / wpia / gigi / pages / wot / TestTTP.java
diff --git a/tests/club/wpia/gigi/pages/wot/TestTTP.java b/tests/club/wpia/gigi/pages/wot/TestTTP.java
new file mode 100644 (file)
index 0000000..c0a966f
--- /dev/null
@@ -0,0 +1,43 @@
+package club.wpia.gigi.pages.wot;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import club.wpia.gigi.GigiApiException;
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.dbObjects.ObjectCache;
+import club.wpia.gigi.dbObjects.User;
+import club.wpia.gigi.pages.wot.RequestTTPPage;
+import club.wpia.gigi.testUtils.ClientTest;
+import club.wpia.gigi.testUtils.IOUtils;
+
+public class TestTTP extends ClientTest {
+
+    public TestTTP() throws IOException {}
+
+    @Test
+    public void testTTPApply() throws IOException {
+        String ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
+        assertThat(ttp, containsString("<form"));
+        assertNull(executeBasicWebInteraction(cookie, RequestTTPPage.PATH, "country=0"));
+
+        ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
+        assertThat(ttp, not(containsString("<form")));
+        ObjectCache.clearAllCaches();
+        u = User.getById(u.getId());
+        assertTrue(u.isInGroup(Group.TTP_APPLICANT));
+    }
+
+    @Test
+    public void testTTPEnoughPoints() throws IOException, GigiApiException {
+        User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
+        cookie = login(u.getEmail(), TEST_PASSWORD);
+
+        String ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
+        assertThat(ttp, not(containsString("<form")));
+    }
+}