]> WPIA git - gigi.git/blob - tests/club/wpia/gigi/pages/wot/TestTTP.java
upd: terminology in code
[gigi.git] / tests / club / wpia / gigi / pages / wot / TestTTP.java
1 package club.wpia.gigi.pages.wot;
2
3 import static org.hamcrest.CoreMatchers.*;
4 import static org.junit.Assert.*;
5
6 import java.io.IOException;
7
8 import org.junit.Test;
9
10 import club.wpia.gigi.GigiApiException;
11 import club.wpia.gigi.dbObjects.Group;
12 import club.wpia.gigi.dbObjects.ObjectCache;
13 import club.wpia.gigi.dbObjects.User;
14 import club.wpia.gigi.pages.wot.RequestTTPPage;
15 import club.wpia.gigi.testUtils.ClientTest;
16 import club.wpia.gigi.testUtils.IOUtils;
17
18 public class TestTTP extends ClientTest {
19
20     public TestTTP() throws IOException {}
21
22     @Test
23     public void testTTPApply() throws IOException {
24         String ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
25         assertThat(ttp, containsString("<form"));
26         assertNull(executeBasicWebInteraction(cookie, RequestTTPPage.PATH, "country=0"));
27
28         ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
29         assertThat(ttp, not(containsString("<form")));
30         ObjectCache.clearAllCaches();
31         u = User.getById(u.getId());
32         assertTrue(u.isInGroup(Group.TTP_APPLICANT));
33     }
34
35     @Test
36     public void testTTPEnoughPoints() throws IOException, GigiApiException {
37         User u = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
38         cookie = login(u.getEmail(), TEST_PASSWORD);
39
40         String ttp = IOUtils.readURL(get(RequestTTPPage.PATH));
41         assertThat(ttp, not(containsString("<form")));
42     }
43 }