Skip to content
This repository has been archived by the owner on Nov 22, 2020. It is now read-only.

Unit tests #15

Merged
merged 26 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3887f17
Update release drafter
GSculerlor May 5, 2020
d0ce25d
Add anime test case
GSculerlor May 5, 2020
3b7559d
Add feature branch Github Action
GSculerlor May 5, 2020
bd3feb4
Fix failed tests and add delay to make sure Jikan not returns 429
GSculerlor May 5, 2020
adbe194
Add anime search testcase
GSculerlor May 6, 2020
332b2c6
Add manga search testcase
GSculerlor May 6, 2020
7033982
Add person test case
GSculerlor May 6, 2020
2481ec2
Add characters test case
GSculerlor May 6, 2020
8cfa866
Set delay time higher
GSculerlor May 6, 2020
dfaf9b4
Add season test case
GSculerlor May 6, 2020
bf7d966
Add schedule test case
GSculerlor May 6, 2020
3fe0e61
Add top test case
GSculerlor May 6, 2020
38d813e
Add genre test case
GSculerlor May 6, 2020
70750a1
Update manga top expected result
GSculerlor May 6, 2020
e3df1b1
Add producer test case
GSculerlor May 6, 2020
fe1a11c
Add magazine test case
GSculerlor May 6, 2020
b336fc4
Add club test case
GSculerlor May 6, 2020
2f7983b
Add missing delay on tests
GSculerlor May 6, 2020
8396b92
Add missing search method tests
GSculerlor May 6, 2020
6b189eb
Add user test case
GSculerlor May 6, 2020
6bef0a0
Revert test top manga
GSculerlor May 6, 2020
d0fa3de
Add stacktrace to action
GSculerlor May 6, 2020
86f72ff
Remove non-consistent test result
GSculerlor May 6, 2020
7a1bb2f
Add stacktrace to pull request action
GSculerlor May 6, 2020
db79e17
Add more delay since Jikan still return 429
GSculerlor May 6, 2020
e060468
Update testcase
GSculerlor May 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name-template: $NEXT_PATCH_VERSION
tag-template: $NEXT_PATCH_VERSION
name-template: $NEXT_MINOR_VERSION
tag-template: $NEXT_MINOR_VERSION
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
categories:
- title: Major Changes
label: "changes: major"
- title: Endpoints Update
labels:
- 'endpoints'

- title: Minor Changes
label: "changes: minor"
- title: Bug Fixing
labels:
- 'fix'
- 'bugfix'
- 'bug'

- title: Patch Changes
label: "changes: patch"
labels:
- 'patch'

template: |
## Non-version Changes
## Changes
$CHANGES
2 changes: 1 addition & 1 deletion .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build --stacktrace --debug

release-notes:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build --stacktrace --debug
24 changes: 12 additions & 12 deletions src/main/kotlin/moe/ganen/jikankt/JikanKt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,16 @@ object JikanKt {

/**
* Function to get anime list by it's season.
* NOTE: If year and/or season is not specified, it'll return current season instead.
* @param year: Year of the season.
* @param season: season type (winter, spring, etc).
* @return List of anime that airing on that season.
*/
suspend fun getSeason(year: Int, season: SeasonType): Season =
gson.deserialize(restClient.request("season/$year/${season.name.toLowerCase()}"), Season::class.java)
suspend fun getSeason(year: Int? = null, season: SeasonType? = null): Season {
val query = if (year != null && season != null && season != SeasonType.All) "$year/${season.name.toLowerCase()}" else ""

return gson.deserialize(restClient.request("season/$query"), Season::class.java)
}

/**
* Function to get archived season on MyAnimeList.
Expand Down Expand Up @@ -221,8 +225,8 @@ object JikanKt {

/**
* Function to get all top anime on MyAnimeList.
* @param page: Optional, default is 1. Index of page, each page contain 50 items.
* @param subtype: Optional, subtype type (upcoming, airing, etc).
* @param page: Optional, default is 1. Index of page, each page contain 50 items.
* @return List of top anime on MyAnimeList.
*/
suspend fun getTopAnime(page: Int? = 1, subtype: TopSubtype? = TopSubtype.NONE): TopAnime =
Expand All @@ -246,24 +250,22 @@ object JikanKt {
/**
* Function to get all top characters on MyAnimeList.
* @param page: Optional, default is 1. Index of page, each page contain 50 items.
* @param subtype: Optional, subtype type (bypopularity, favorite).
* @return List of top characters on MyAnimeList.
*/
suspend fun getTopCharacters(page: Int? = 1, subtype: TopSubtype? = TopSubtype.NONE): TopCharacters =
suspend fun getTopCharacters(page: Int? = 1): TopCharacters =
gson.deserialize(
restClient.request("top/characters/$page/${if (subtype == TopSubtype.NONE) "" else subtype?.name?.toLowerCase()}"),
restClient.request("top/characters/$page"),
TopCharacters::class.java
)

/**
* Function to get all top people on MyAnimeList.
* @param page: Optional, default is 1. Index of page, each page contain 50 items.
* @param subtype: Optional, subtype type (bypopularity, favorite).
* @return List of top people on MyAnimeList.
*/
suspend fun getTopPeople(page: Int? = 1, subtype: TopSubtype? = TopSubtype.NONE): TopPeople =
suspend fun getTopPeople(page: Int? = 1): TopPeople =
gson.deserialize(
restClient.request("top/people/$page/${if (subtype == TopSubtype.NONE) "" else subtype?.name?.toLowerCase()}"),
restClient.request("top/people/$page"),
TopPeople::class.java
)

Expand Down Expand Up @@ -458,7 +460,7 @@ object JikanKt {

//endregion

//region Characters
//region People

/**
* Search results for the query.
Expand All @@ -481,8 +483,6 @@ object JikanKt {

//endregion

//region

//endregion

//region User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ data class AnimeListEntity(
* Current airing status of anime.
*/
@SerializedName("airing_status")
val airingStatus: String? = null,
val airingStatus: Int? = null,

/**
* Current user's watching status of anime.
*/
@SerializedName("watching_status")
val watchingStatus: String? = null
val watchingStatus: Int? = null
) : MalEntity
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class Episode(
* ID associated with the anime.
*/
@SerializedName("episode_id")
val malId: Int? = null,
val episodeId: Int? = null,

/**
* Title of the episode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ data class AnimeSearchQuery(
stringBuilder.append("&end_date=${queryDateFormat.format(endDate)}")

if (excludedGenre)
stringBuilder.append("&genre_exclude=1")
stringBuilder.append("&genre_exclude=0")

if (limit != null)
stringBuilder.append("&limit=${limit}")

if (orderBy != AnimeOrderBy.None)
stringBuilder.append("&order_by=${if (orderBy.queryString.isNullOrEmpty()) orderBy.name else orderBy.queryString}")
stringBuilder.append("&order_by=${if (orderBy.queryString.isNullOrEmpty()) orderBy.name.toLowerCase() else orderBy.queryString}")

if (sort == Sort.Ascending)
stringBuilder.append("&sort=asc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ data class MangaSearchQuery(
val queryDateFormat = SimpleDateFormat("yyyy-MM-dd")

if (type != MangaType.All)
stringBuilder.append("&type=${type.name}")
stringBuilder.append("&type=${if (type.queryString.isNullOrEmpty()) type.name.toLowerCase() else type.queryString}")

if (status != MangaStatus.All)
stringBuilder.append("&status=${status.name}")
stringBuilder.append("&status=${status.name.toLowerCase()}")

if (!genre.isNullOrEmpty())
stringBuilder.append("&genre=${genre.joinToString(separator = ",") { "${it.ordinal}" }}")
Expand All @@ -40,13 +40,13 @@ data class MangaSearchQuery(
stringBuilder.append("&end_date=${queryDateFormat.format(endDate)}")

if (excludedGenre)
stringBuilder.append("&genre_exclude=1")
stringBuilder.append("&genre_exclude=0")

if (limit != null)
stringBuilder.append("&limit=${limit}")

if (orderBy != MangaOrderBy.None)
stringBuilder.append("&order_by=${if (orderBy.queryString.isNullOrEmpty()) orderBy.name else orderBy.queryString}")
stringBuilder.append("&order_by=${if (orderBy.queryString.isNullOrEmpty()) orderBy.name.toLowerCase() else orderBy.queryString}")

if (sort == Sort.Ascending)
stringBuilder.append("&sort=asc")
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/moe/ganen/jikankt/models/search/enums/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ enum class AnimeType {
Music
}

enum class MangaType {
enum class MangaType(val queryString: String? = null) {
All,
Manga,
Novel,
Oneshot,
`One-shot`("oneshot"),
Doujin,
Manhwa,
Manhua
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/moe/ganen/jikankt/models/season/Season.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ data class Season(
* Name of the season.
*/
@SerializedName("season_name")
val seasonName: String,
val seasonName: String? = null,

/**
* Year of the season.
*/
@SerializedName("season_year")
val seasonYear: Int,
val seasonYear: Int? = null,

/**
* List of anime in this season.
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/moe/ganen/jikankt/models/user/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ data class User(
* ID associated with MyAnimeList User.
*/
@SerializedName("user_id")
val userId: Int,
val userId: Int? = null,

/**
* Username associated with MyAnimeList User.
*/
@SerializedName("username")
val username: String,
val username: String? = null,

/**
* User's MyAnimeList link.
Expand Down
Loading