Skip to content

Commit

Permalink
Fix scoreboard schema for Brilliance data, and add tests to catch thi…
Browse files Browse the repository at this point in the history
…s earlier next time
  • Loading branch information
4Ply committed Jan 5, 2025
1 parent 385f1da commit 09194a0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ dependencies {

// Fabric permissions
include(modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))

// Add JUnit dependencies for testing
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")

testImplementation 'com.google.guava:guava:32.1.2-jre'
}

def brillianceDataDir = "data/brilliance-data"
Expand Down Expand Up @@ -91,6 +97,20 @@ processResources {
}
}

processTestResources {
from(scoreboardsJsonPath) {
into(brillianceDataDir)
}
from(cardsJsonPath) {
rename { "cards.json" }
into(brillianceDataDir)
}
from(artifactsJsonPath) {
rename { "artifacts.json" }
into(brillianceDataDir)
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}
Expand Down Expand Up @@ -133,3 +153,7 @@ publishing {
// retrieving dependencies.
}
}

test {
useJUnitPlatform()
}
8 changes: 7 additions & 1 deletion src/main/kotlin/org/trackedout/data/BrillianceScoreboards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ data class BrillianceScoreboardDescription(
val displayText: String? = null,
val description: String,
val canEditForRunTypes: List<String>? = null,
val values: Map<String, String>? = mapOf(),
val values: Map<String, ScoreboardValue>? = mapOf(),
)

@Serializable
data class ScoreboardValue(
val title: String? = null,
val description: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.trackedout.listeners

import org.junit.jupiter.api.Test
import org.trackedout.data.BrillianceCard
import org.trackedout.data.BrillianceScoreboardDescription

class BrillianceDataParserTest {
val scoreboardsJsonPath = "data/brilliance-data/scoreboards.json"
val cardsJsonPath = "data/brilliance-data/cards.json"

@Test
fun `scoreboards data parsing`() {
val scoreboardData = this::class.java.classLoader.getResourceAsStream(scoreboardsJsonPath)!!.bufferedReader().use { it.readText() }
json.decodeFromString<Map<String, BrillianceScoreboardDescription>>(scoreboardData)
println("Successfully parsed scoreboards.json")
}

@Test
fun `cards data parsing`() {
val cardsData = this::class.java.classLoader.getResourceAsStream(cardsJsonPath)!!.bufferedReader().use { it.readText() }
json.decodeFromString<Map<String, BrillianceCard>>(cardsData)
println("Successfully parsed cards.json")
}
}

0 comments on commit 09194a0

Please sign in to comment.