<commit_before>package com.uwetrottmann.thetvdb.services;

import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.TestData;
import com.uwetrottmann.thetvdb.entities.BasicEpisode;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodes;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodesSummary;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodesSummaryWrapper;
import com.uwetrottmann.thetvdb.entities.SeriesImageQueryResults;
import com.uwetrottmann.thetvdb.entities.SeriesImagesQueryParams;
import com.uwetrottmann.thetvdb.entities.SeriesWrapper;
import okhttp3.Headers;
import org.junit.Test;
import retrofit2.Call;

import java.io.IOException;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

public class SeriesServiceTest extends BaseTestCase {

    @Test
    public void test_series() throws IOException {
        Call<SeriesWrapper> call = getTheTvdb().series().series(TestData.SERIES_TVDB_ID, TestData.LANGUAGE_EN);
        SeriesWrapper wrapper = call.execute().body();
        TestData.assertTestSeries(wrapper.data);
    }

    @Test
    public void test_seriesHeader() throws IOException {
        Call<Void> call = getTheTvdb().series().seriesHeader(TestData.SERIES_TVDB_ID, TestData.LANGUAGE_EN);
        Headers headers = call.execute().headers();
        assertThat(headers.get("Last-Modified")).isNotEmpty();
    }

    @Test
    public void test_episodes() throws IOException {
        Call<SeriesEpisodes> call = getTheTvdb().series().episodes(TestData.SERIES_TVDB_ID, 2, TestData.LANGUAGE_EN);
        SeriesEpisodes seriesEpisodes = call.execute().body();
        assertEpisodes(seriesEpisodes.data);
    }

    @Test
    public void test_episodesQuery() throws IOException {
        Call<SeriesEpisodes> call = getTheTvdb().series().episodesQuery(
                TestData.SERIES_TVDB_ID,
                null,
                1, // airedSeason
                null, null, null, null, null,
                TestData.LANGUAGE_EN
        );
        SeriesEpisodes seriesEpisodes = call.execute().body();
        assertEpisodes(seriesEpisodes.data);
    }

    private static void assertEpisodes(List<BasicEpisode> episodes) {
        for (BasicEpisode basicEpisode : episodes) {
            assertThat(basicEpisode.id).isPositive();
            assertThat(basicEpisode.airedEpisodeNumber).isGreaterThanOrEqualTo(0);
            if (basicEpisode.absoluteNumber != null) {
                assertThat(basicEpisode.absoluteNumber).isGreaterThanOrEqualTo(0);
            }
            if (basicEpisode.dvdEpisodeNumber != null) {
                assertThat(basicEpisode.dvdEpisodeNumber).isGreaterThanOrEqualTo(0);
            }
            if (basicEpisode.dvdSeason != null) {<commit_msg>Get all pages for episodes test.<commit_after>package com.uwetrottmann.thetvdb.services;

import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.TestData;
import com.uwetrottmann.thetvdb.entities.BasicEpisode;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodes;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodesSummary;
import com.uwetrottmann.thetvdb.entities.SeriesEpisodesSummaryWrapper;
import com.uwetrottmann.thetvdb.entities.SeriesImageQueryResults;
import com.uwetrottmann.thetvdb.entities.SeriesImagesQueryParams;
import com.uwetrottmann.thetvdb.entities.SeriesWrapper;
import okhttp3.Headers;
import org.junit.Test;
import retrofit2.Call;

import java.io.IOException;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

public class SeriesServiceTest extends BaseTestCase {

    @Test
    public void test_series() throws IOException {
        Call<SeriesWrapper> call = getTheTvdb().series().series(TestData.SERIES_TVDB_ID, TestData.LANGUAGE_EN);
        SeriesWrapper wrapper = call.execute().body();
        TestData.assertTestSeries(wrapper.data);
    }

    @Test
    public void test_seriesHeader() throws IOException {
        Call<Void> call = getTheTvdb().series().seriesHeader(TestData.SERIES_TVDB_ID, TestData.LANGUAGE_EN);
        Headers headers = call.execute().headers();
        assertThat(headers.get("Last-Modified")).isNotEmpty();
    }

    @Test
    public void test_episodes() throws IOException {
        Integer page = 0;
        while (page != null) {
            Call<SeriesEpisodes> call = getTheTvdb().series().episodes(TestData.SERIES_TVDB_ID, page,
                    TestData.LANGUAGE_EN);
            SeriesEpisodes response = call.execute().body();

            assertEpisodes(response.data);

            page = response.links.next;
        }
    }

    @Test
    public void test_episodesQuery() throws IOException {
        Call<SeriesEpisodes> call = getTheTvdb().series().episodesQuery(
                TestData.SERIES_TVDB_ID,
                null,
                1, // airedSeason
                null, null, null, null, null,
                TestData.LANGUAGE_EN
        );
        SeriesEpisodes seriesEpisodes = call.execute().body();
        assertEpisodes(seriesEpisodes.data);
    }

    private static void assertEpisodes(List<BasicEpisode> episodes) {
        for (BasicEpisode basicEpisode : episodes) {
            assertThat(basicEpisode.id).isPositive();
            assertThat(basicEpisode.airedEpisodeNumber).isGreaterThanOrEqualTo(0);
            if (basicEpisode.absoluteNumber != null) {
                assertThat(basicEpisode.absoluteNumber).isGreaterThanOrEqualTo(0);
            }
            if (basicEpisode.dvdEpisodeNumber != null) {
                assertThat(basicEpisode.dvdEpisodeNumber).isGreaterThanOrEqualTo(0);
            }
            if (basicEpisode.dvdSeason != null) {
{'fraction_non_alphanumeric': 0.09847288046340179, 'fraction_numerical': 0.0024574337370545903, 'mean_word_length': 3.2906626506024095, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 54, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1919775', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1734, 'n_words': 265}