|
| 1 | +package me.proxer.library.api.info; |
| 2 | + |
| 3 | +import me.proxer.library.ProxerTest; |
| 4 | +import me.proxer.library.api.ProxerException; |
| 5 | +import me.proxer.library.entity.info.ForumDiscussion; |
| 6 | +import okhttp3.mockwebserver.MockResponse; |
| 7 | +import org.junit.Test; |
| 8 | + |
| 9 | +import java.io.IOException; |
| 10 | +import java.util.Date; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +import static org.assertj.core.api.Assertions.assertThat; |
| 14 | + |
| 15 | +/** |
| 16 | + * @author Ruben Gees |
| 17 | + */ |
| 18 | +public class ForumDiscussionsEndpointTest extends ProxerTest { |
| 19 | + |
| 20 | + @Test |
| 21 | + public void testDefault() throws IOException, ProxerException { |
| 22 | + server.enqueue(new MockResponse().setBody(fromResource("info_forum.json"))); |
| 23 | + |
| 24 | + final List<ForumDiscussion> result = api.info() |
| 25 | + .forumDiscussions("1") |
| 26 | + .build() |
| 27 | + .execute(); |
| 28 | + |
| 29 | + assertThat(result).first().isEqualTo(buildFirstTestForumDiscussion()); |
| 30 | + assertThat(result).last().isEqualTo(buildLastTestForumDiscussion()); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void testPath() throws ProxerException, IOException, InterruptedException { |
| 35 | + server.enqueue(new MockResponse().setBody(fromResource("info_forum.json"))); |
| 36 | + |
| 37 | + api.info().forumDiscussions("3") |
| 38 | + .build() |
| 39 | + .execute(); |
| 40 | + |
| 41 | + assertThat(server.takeRequest().getPath()).isEqualTo("/api/v1/info/forum?id=3"); |
| 42 | + } |
| 43 | + |
| 44 | + private ForumDiscussion buildFirstTestForumDiscussion() { |
| 45 | + return new ForumDiscussion("384098", "281", "Overlord II - Diskussionsthread", |
| 46 | + 15, 749, new Date(1514199320 * 1000L), "351626", "Asuka..", |
| 47 | + new Date(1517246199 * 1000L), "506979", "5devilz"); |
| 48 | + } |
| 49 | + |
| 50 | + private ForumDiscussion buildLastTestForumDiscussion() { |
| 51 | + return new ForumDiscussion("381421", "56", |
| 52 | + "Overlord II – neues Visual, weitere Charaktere und Synchronsprecher enthüllt", |
| 53 | + 35, 32334, new Date(1489228544 * 1000L), "19328", "Moeface", |
| 54 | + new Date(1514078674 * 1000L), "470614", "..Rhyanon."); |
| 55 | + } |
| 56 | +} |
0 commit comments