Skip to content

Commit

Permalink
Merge pull request #27 from noahkohrs/league-issue-fixing
Browse files Browse the repository at this point in the history
Addressing Early Season League Issue
  • Loading branch information
noahkohrs authored Sep 27, 2024
2 parents 7c27cc4 + d4c881e commit 1362ed2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: CI/CD Process
on:
pull_request:
workflow_dispatch:
# Schedule the workflow to run every 6 hours
schedule:
- cron: "0 */6 * * *"

jobs:
basic-checks:
Expand Down
6 changes: 3 additions & 3 deletions riot-api/src/main/kotlin/com.noahkohrs.riot.api/dtos/Dtos.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ queue string
*/
internal data class LeagueListDto(
@Json(name = "leagueId")
val leagueId: String,
val leagueId: String? = null,
@Json(name = "entries")
val entries: List<LeagueItemDto> = emptyList(),
@Json(name = "tier")
val tier: String,
@Json(name = "name")
val name: String,
val name: String? = null,
@Json(name = "queue")
val queue: String,
val queue: String? = null,
)

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public class LeagueEntryResponse private constructor(
}

public class LeagueListResponse private constructor(
@JvmField public val leagueId: String,
@JvmField public val leagueId: String?,
@JvmField public val leaguePlayers: List<LeagueItemResponse>,
@JvmField public val tier: LoLTier,
@JvmField public val leagueName: String,
@JvmField public val queue: LoLQueue,
@JvmField public val leagueName: String?,
@JvmField public val queue: LoLQueue?,
) {
internal companion object {
fun fromDto(dto: LeagueListDto): LeagueListResponse {
Expand All @@ -56,7 +56,7 @@ public class LeagueListResponse private constructor(
leaguePlayers = dto.entries.map { LeagueItemResponse.fromDto(it) },
tier = LoLTier.fromValue(dto.tier),
leagueName = dto.name,
queue = LoLQueue.fromValue(dto.queue),
queue = dto.queue?.let { LoLQueue.fromValue(it) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.noahkohrs.riot.api.values.Platform
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.DynamicContainer
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.DynamicTest.dynamicTest
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestFactory
Expand Down Expand Up @@ -69,6 +70,7 @@ class LeagueApiTest {
) {
val summonerId = leagueEntry.summonerId ?: "Unknown Summoner"

// Note: Most of theses checks are useless and should be replaced by a proper test
assertNotNull(leagueEntry, "League entry should not be null for summoner $summonerId")
assertNotNull(leagueEntry.leagueId, "League ID should not be null for summoner $summonerId")
assertNotNull(leagueEntry.leaguePoints, "League points should not be null for summoner $summonerId")
Expand All @@ -85,10 +87,15 @@ class LeagueApiTest {
assertNotNull(leagueEntry.veteran, "Veteran status should not be null for summoner $summonerId")
}

@Test
fun getLeague() {
val challengeLeagueId = riotApi.lol.league.getChallengerLeague(LoLRankedQueue.RankedSoloQueue).leagueId
riotApi.lol.league.getLeague(challengeLeagueId)
@TestFactory
fun getLeague(): List<DynamicTest> {
val entries = riotApi.lol.league.getLeagueEntries(LoLRankedQueue.RankedSoloQueue, LoLTier.EMERALD, LoLDivision.I)
return entries.map { entry ->
dynamicTest(entry.leagueId) {
val league = entry.leagueId?.let { riotApi.lol.league.getLeague(it) }
assertNotNull(league)
}
}
}

@Test
Expand Down

0 comments on commit 1362ed2

Please sign in to comment.