-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathTvAssertions.java
More file actions
244 lines (207 loc) · 10.7 KB
/
Copy pathTvAssertions.java
File metadata and controls
244 lines (207 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 Uwe Trottmann
package com.uwetrottmann.tmdb2.assertions;
import static com.uwetrottmann.tmdb2.TestData.testTvEpisode;
import static com.uwetrottmann.tmdb2.TestData.testTvSeason;
import static com.uwetrottmann.tmdb2.TestData.testTvShow;
import static com.uwetrottmann.tmdb2.assertions.CompanyAssertions.assertBaseCompany;
import static com.uwetrottmann.tmdb2.assertions.CreditAssertions.assertCastCredits;
import static com.uwetrottmann.tmdb2.assertions.CreditAssertions.assertCrewCredits;
import static com.uwetrottmann.tmdb2.assertions.GenericAssertions.assertBaseResultsPage;
import static com.uwetrottmann.tmdb2.assertions.GenericAssertions.assertSpokenLanguages;
import static com.uwetrottmann.tmdb2.assertions.GenreAssertions.assertGenre;
import static com.uwetrottmann.tmdb2.assertions.NetworkAssertions.assertNetwork;
import static com.uwetrottmann.tmdb2.assertions.PersonAssertions.assertBasePerson;
import static org.assertj.core.api.Assertions.assertThat;
import com.uwetrottmann.tmdb2.entities.BaseCompany;
import com.uwetrottmann.tmdb2.entities.BasePerson;
import com.uwetrottmann.tmdb2.entities.BaseTvEpisode;
import com.uwetrottmann.tmdb2.entities.BaseTvSeason;
import com.uwetrottmann.tmdb2.entities.BaseTvShow;
import com.uwetrottmann.tmdb2.entities.Genre;
import com.uwetrottmann.tmdb2.entities.Network;
import com.uwetrottmann.tmdb2.entities.TvEpisode;
import com.uwetrottmann.tmdb2.entities.TvEpisodeExternalIds;
import com.uwetrottmann.tmdb2.entities.TvEpisodeResultsPage;
import com.uwetrottmann.tmdb2.entities.TvExternalIds;
import com.uwetrottmann.tmdb2.entities.TvSeason;
import com.uwetrottmann.tmdb2.entities.TvSeasonExternalIds;
import com.uwetrottmann.tmdb2.entities.TvShow;
import com.uwetrottmann.tmdb2.entities.TvShowResultsPage;
import java.util.Date;
public class TvAssertions {
public static void assertBaseTvShow(BaseTvShow tvShow) {
assertThat(tvShow).isNotNull();
assertThat(tvShow.id).isNotNull();
assertThat(tvShow.name).isNotNull();
assertThat(tvShow.origin_country).isNotNull();
assertThat(tvShow.original_language).isNotNull();
assertThat(tvShow.original_name).isNotNull();
assertThat(tvShow.vote_count).isNotNull();
assertThat(tvShow.vote_count).isGreaterThanOrEqualTo(0);
assertThat(tvShow.vote_average).isNotNull();
assertThat(tvShow.vote_average).isGreaterThanOrEqualTo(0);
if (tvShow.popularity != null) {
assertThat(tvShow.popularity).isGreaterThanOrEqualTo(0);
}
try {
TvShow _tvShow = (TvShow) tvShow;
for (Genre genre : _tvShow.genres) {
assertGenre(genre);
}
} catch (Exception exc) {
assertThat(tvShow.genre_ids).isNotNull();
}
}
public static void assertTvShow(TvShow tvShow) {
assertBaseTvShow(tvShow);
assertThat(tvShow.homepage).isNotNull();
assertThat(tvShow.in_production).isNotNull();
assertThat(tvShow.number_of_episodes).isNotNull();
assertThat(tvShow.number_of_episodes).isGreaterThanOrEqualTo(0);
assertThat(tvShow.number_of_seasons).isNotNull();
assertThat(tvShow.number_of_seasons).isGreaterThanOrEqualTo(0);
assertThat(tvShow.created_by).isNotNull();
assertThat(tvShow.created_by).isNotEmpty();
for (BasePerson person : tvShow.created_by) {
assertBasePerson(person, false);
}
assertThat(tvShow.type).isNotNull();
assertThat(tvShow.tagline).isNotNull();
assertThat(tvShow.status).isNotNull();
assertThat(tvShow.networks).isNotNull();
assertThat(tvShow.networks).isNotEmpty();
for (Network network : tvShow.networks) {
assertNetwork(network, true);
}
assertThat(tvShow.episode_run_time).isNotNull();
for (Integer runTime : tvShow.episode_run_time) {
assertThat(runTime).isNotNull();
assertThat(runTime).isGreaterThanOrEqualTo(0);
}
for (String language : tvShow.languages) {
assertThat(language).isNotNull();
}
for (BaseCompany company : tvShow.production_companies) {
assertBaseCompany(company, false);
}
assertThat(tvShow.seasons).isNotNull();
assertThat(tvShow.seasons).isNotEmpty();
assertThat(tvShow.seasons.size()).isGreaterThanOrEqualTo(tvShow.number_of_seasons);
for (BaseTvSeason tvSeason : tvShow.seasons) {
assertBaseTvSeason(tvSeason);
// seasons include episode count ONLY when getting show summary
assertThat(tvSeason.episode_count).isGreaterThanOrEqualTo(0);
}
assertThat(tvShow.spoken_languages).isNotEmpty();
assertSpokenLanguages(tvShow.spoken_languages);
}
public static void assertTvShowDataIntegrity(TvShow tvShow) {
assertTvShow(tvShow);
assertThat(tvShow.name).isEqualTo(testTvShow.name);
assertThat(tvShow.first_air_date).isEqualTo(testTvShow.first_air_date);
assertThat(tvShow.id).isEqualTo(testTvShow.id);
assertThat(tvShow.original_language).isEqualTo(testTvShow.original_language);
assertThat(tvShow.original_name).isEqualTo(testTvShow.original_name);
assertThat(tvShow.type).isEqualTo(testTvShow.type);
}
public static void assertTvShowResultsPage(TvShowResultsPage tvShowResultsPage) {
assertBaseResultsPage(tvShowResultsPage);
for (BaseTvShow baseTvShow : tvShowResultsPage.results) {
assertBaseTvShow(baseTvShow);
}
}
public static void assertBaseTvSeason(BaseTvSeason tvSeason) {
assertThat(tvSeason).isNotNull();
if (tvSeason.air_date != null) {
assertThat(tvSeason.air_date).isNotEqualTo(new Date());
}
assertThat(tvSeason.id).isNotNull();
assertThat(tvSeason.season_number).isNotNull();
assertThat(tvSeason.season_number).isGreaterThanOrEqualTo(0);
}
public static void assertTvSeason(TvSeason tvSeason) {
assertBaseTvSeason(tvSeason);
assertThat(tvSeason._id).isNotNull();
assertThat(tvSeason.name).isNotNull();
assertThat(tvSeason.overview).isNotNull();
assertThat(tvSeason.episodes).isNotNull();
assertThat(tvSeason.episodes).isNotEmpty();
for (TvEpisode tvEpisode : tvSeason.episodes) {
assertTvEpisode(tvEpisode);
assertThat(tvEpisode.episode_type).isNotNull();
}
}
public static void assertTvSeasonDataIntegrity(TvSeason tvSeason) {
assertTvSeason(tvSeason);
assertThat(tvSeason.name).isEqualTo(testTvSeason.name);
assertThat(tvSeason.air_date).isEqualTo(testTvSeason.air_date);
assertThat(tvSeason.season_number).isEqualTo(testTvSeason.season_number);
assertThat(tvSeason.id).isEqualTo(testTvSeason.id);
assertThat(tvSeason._id).isEqualTo(testTvSeason._id);
assertThat(tvSeason.episodes.size()).isEqualTo(testTvSeason.episodes.size());
assertThat(tvSeason.poster_path).isNotEmpty();
}
public static void assertBaseTvEpisode(BaseTvEpisode tvEpisode) {
assertThat(tvEpisode).isNotNull();
assertThat(tvEpisode.id).isNotNull();
assertThat(tvEpisode.episode_number).isNotNull();
assertThat(tvEpisode.episode_number).isGreaterThanOrEqualTo(0);
assertThat(tvEpisode.name).isNotNull();
assertThat(tvEpisode.season_number).isNotNull();
assertThat(tvEpisode.season_number).isGreaterThanOrEqualTo(0);
assertThat(tvEpisode.vote_average).isNotNull();
assertThat(tvEpisode.vote_count).isNotNull();
if (tvEpisode.runtime != null) {
assertThat(tvEpisode.runtime).isPositive();
}
}
public static void assertTvEpisode(TvEpisode tvEpisode) {
assertBaseTvEpisode(tvEpisode);
assertThat(tvEpisode.overview).isNotNull();
assertCrewCredits(tvEpisode.crew);
if (tvEpisode.guest_stars == null)
return;
assertCastCredits(tvEpisode.guest_stars);
}
public static void assertTvEpisodeDataIntegrity(TvEpisode tvEpisode) {
assertTvEpisode(tvEpisode);
assertThat(tvEpisode.name).isEqualTo(testTvEpisode.name);
assertThat(tvEpisode.id).isEqualTo(testTvEpisode.id);
assertThat(tvEpisode.season_number).isEqualTo(testTvEpisode.season_number);
assertThat(tvEpisode.episode_number).isEqualTo(testTvEpisode.episode_number);
assertThat(tvEpisode.air_date).isEqualTo(testTvEpisode.air_date);
}
public static void assertTvEpisodeResultsPage(TvEpisodeResultsPage tvEpisodeResultsPage) {
assertBaseResultsPage(tvEpisodeResultsPage);
for (BaseTvEpisode tvEpisode : tvEpisodeResultsPage.results) {
assertBaseTvEpisode(tvEpisode);
}
}
public static void assertTvShowExternalIdsMatch(TvExternalIds actual) {
assertThat(actual.imdb_id).isEqualTo(testTvShow.external_ids.imdb_id);
assertThat(actual.tvdb_id).isEqualTo(testTvShow.external_ids.tvdb_id);
assertThat(actual.facebook_id).isEqualTo(testTvShow.external_ids.facebook_id);
assertThat(actual.freebase_id).isEqualTo(testTvShow.external_ids.freebase_id);
assertThat(actual.freebase_mid).isEqualTo(testTvShow.external_ids.freebase_mid);
assertThat(actual.instagram_id).isEqualTo(testTvShow.external_ids.instagram_id);
assertThat(actual.tvrage_id).isEqualTo(testTvShow.external_ids.tvrage_id);
assertThat(actual.twitter_id).isEqualTo(testTvShow.external_ids.twitter_id);
assertThat(actual.wikidata_id).isEqualTo(testTvShow.external_ids.wikidata_id);
}
public static void assertTvEpisodeExternalIdsMatch(TvEpisodeExternalIds actual) {
assertThat(actual.imdb_id).isEqualTo(testTvEpisode.external_ids.imdb_id);
assertThat(actual.tvdb_id).isEqualTo(testTvEpisode.external_ids.tvdb_id);
assertThat(actual.freebase_id).isEqualTo(testTvEpisode.external_ids.freebase_id);
assertThat(actual.freebase_mid).isEqualTo(testTvEpisode.external_ids.freebase_mid);
assertThat(actual.tvrage_id).isEqualTo(testTvEpisode.external_ids.tvrage_id);
assertThat(actual.wikidata_id).isEqualTo(testTvEpisode.external_ids.wikidata_id);
}
public static void assertTvSeasonExternalIdsMatch(TvSeasonExternalIds actual) {
assertThat(actual.tvdb_id).isEqualTo(testTvSeason.external_ids.tvdb_id);
assertThat(actual.freebase_id).isEqualTo(testTvSeason.external_ids.freebase_id);
assertThat(actual.freebase_mid).isEqualTo(testTvSeason.external_ids.freebase_mid);
assertThat(actual.tvrage_id).isEqualTo(testTvSeason.external_ids.tvrage_id);
assertThat(actual.wikidata_id).isEqualTo(testTvSeason.external_ids.wikidata_id);
}
}