Skip to content

Commit 0856aea

Browse files
committed
Fix rankings data conversion
1 parent 00086d4 commit 0856aea

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/api/WorldRugbyResponses.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ data class Team(
1010
val id: String,
1111
val name: String,
1212
val abbreviation: String?,
13+
val countryCode: String,
1314
)
1415

15-
val tbc = Team(id = "TBC", name = "TBC", abbreviation = "TBC")
16+
val tbc = Team(id = "TBC", name = "TBC", abbreviation = "TBC", countryCode = "TBC")
1617

1718
data class Entry(
1819
val pos: Int,

Diff for: ranking/src/main/kotlin/dev/ricknout/rugbyranker/ranking/data/RankingDataConverter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object RankingDataConverter {
1111
Ranking(
1212
teamId = entry.team.id,
1313
teamName = entry.team.name,
14-
teamAbbreviation = entry.team.abbreviation!!,
14+
teamAbbreviation = entry.team.abbreviation ?: entry.team.countryCode,
1515
position = entry.pos,
1616
previousPosition = entry.previousPos,
1717
points = entry.pts,

Diff for: ranking/src/test/kotlin/dev/ricknout/rugbyranker/ranking/data/RankingDataConverterTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class RankingDataConverterTest {
1616
@Before
1717
fun setup() {
1818
val effective = Effective(label = "2018-10-29", millis = 1540771200000L, gmtOffset = 0f)
19-
val team1 = Team(id = "100", name = "Team 1", abbreviation = "T1")
19+
val team1 = Team(id = "100", name = "Team 1", abbreviation = "T1", countryCode = "T1")
2020
val entry1 = Entry(pos = 1, previousPos = 2, pts = 100f, previousPts = 90f, matches = 10, team = team1)
21-
val team2 = Team(id = "200", name = "Team 2", abbreviation = "T2")
21+
val team2 = Team(id = "200", name = "Team 2", abbreviation = null, countryCode = "T2")
2222
val entry2 = Entry(pos = 2, previousPos = 3, pts = 90f, previousPts = 80f, matches = 10, team = team2)
2323
worldRugbyRankingsResponse = WorldRugbyRankingsResponse(
2424
effective = effective,
@@ -35,7 +35,7 @@ class RankingDataConverterTest {
3535
val entry = worldRugbyRankingsResponse.entries[index]
3636
assertEquals(mensWorldRugbyRanking.teamId, entry.team.id)
3737
assertEquals(mensWorldRugbyRanking.teamName, entry.team.name)
38-
assertEquals(mensWorldRugbyRanking.teamAbbreviation, entry.team.abbreviation)
38+
assertEquals(mensWorldRugbyRanking.teamAbbreviation, entry.team.abbreviation ?: entry.team.countryCode)
3939
assertEquals(mensWorldRugbyRanking.position, entry.pos)
4040
assertEquals(mensWorldRugbyRanking.previousPosition, entry.previousPos)
4141
assertEquals(mensWorldRugbyRanking.points, entry.pts)
@@ -53,7 +53,7 @@ class RankingDataConverterTest {
5353
val entry = worldRugbyRankingsResponse.entries[index]
5454
assertEquals(womensWorldRugbyRanking.teamId, entry.team.id)
5555
assertEquals(womensWorldRugbyRanking.teamName, entry.team.name)
56-
assertEquals(womensWorldRugbyRanking.teamAbbreviation, entry.team.abbreviation)
56+
assertEquals(womensWorldRugbyRanking.teamAbbreviation, entry.team.abbreviation ?: entry.team.countryCode)
5757
assertEquals(womensWorldRugbyRanking.position, entry.pos)
5858
assertEquals(womensWorldRugbyRanking.previousPosition, entry.previousPos)
5959
assertEquals(womensWorldRugbyRanking.points, entry.pts)

0 commit comments

Comments
 (0)