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

Commit

Permalink
Merge pull request #15 from GSculerlor/feat-unit-test
Browse files Browse the repository at this point in the history
Unit tests
  • Loading branch information
GSculerlor authored May 11, 2020
2 parents 51e50c7 + e060468 commit 0212d17
Show file tree
Hide file tree
Showing 24 changed files with 2,003 additions and 41 deletions.
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

0 comments on commit 0212d17

Please sign in to comment.