Skip to content

Commit

Permalink
Align the build script with the Arc repo
Browse files Browse the repository at this point in the history
- Migrate the tests to JUnit Jupiter
- Fixes #34
  • Loading branch information
kaikreuzer committed Dec 13, 2024
1 parent 733eef4 commit a977c9e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ bin/
### Mac OS ###
.DS_Store
/.idea/
.kotlin
38 changes: 9 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.lang.System.getenv
import java.net.URI

plugins {
kotlin("jvm") version "2.0.21"
kotlin("jvm") version "2.0.21" apply false
kotlin("plugin.serialization") version "1.9.23" apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("org.jetbrains.kotlinx.kover") version "0.8.3"
Expand All @@ -22,9 +22,9 @@ plugins {

val springBootVersion by extra { "3.3.5" }

group = "ai.ancf.lmos"

subprojects {
group = "ai.ancf.lmos"

apply(plugin = "kotlin")
apply(plugin = "kotlinx-serialization")
apply(plugin = "org.cyclonedx.bom")
Expand All @@ -50,29 +50,24 @@ subprojects {
}
}

kotlin {
jvmToolchain(17)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
withSourcesJar()
withJavadocJar()
}

tasks.named<Jar>("javadocJar") {
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

dependencies {
testImplementation(kotlin("test"))
testImplementation("io.mockk:mockk:1.13.13")
"testImplementation"("org.junit.jupiter:junit-jupiter:5.11.3")
"testImplementation"("org.assertj:assertj-core:3.26.3")
"testImplementation"("io.mockk:mockk:1.13.13")
}

tasks.test {
useJUnitPlatform()
tasks.named("dokkaJavadoc") {
mustRunAfter("checksum")
}

tasks.withType<Test> {
Expand Down Expand Up @@ -133,21 +128,6 @@ subprojects {
}
}

dependencies {
testImplementation(kotlin("test"))
}

tasks.named<Jar>("jar") {
enabled = false
}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}

repositories {
mavenLocal()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
package ai.ancf.lmos.router.hybrid.starter

import io.mockk.junit5.MockKExtension
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

@ExtendWith(MockKExtension::class)
class SpringVectorSearchClientPropertiesTest {
Expand Down Expand Up @@ -45,7 +45,7 @@ class SpringVectorSearchClientPropertiesTest {
@Test
fun `should throw an exception for invalid threshold`() {
val exception =
assertFailsWith<IllegalArgumentException> {
assertThrows<IllegalArgumentException> {
SpringVectorSearchClientProperties(threshold = -1.0)
}
assertEquals("threshold must be between 0.0 and 1.0", exception.message)
Expand All @@ -54,7 +54,7 @@ class SpringVectorSearchClientPropertiesTest {
@Test
fun `should throw an exception for invalid topK`() {
val exception =
assertFailsWith<IllegalArgumentException> {
assertThrows<IllegalArgumentException> {
SpringVectorSearchClientProperties(topK = -1)
}
assertEquals("topK must be a positive integer", exception.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import ai.ancf.lmos.router.vector.VectorSearchClientRequest
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class ModelToVectorQueryConverterTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package ai.ancf.lmos.router.hybrid

import ai.ancf.lmos.router.core.Context
import io.mockk.mockk
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class NoOpModelToVectorQueryConverterTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import ai.ancf.lmos.router.llm.LLMAgentRoutingSpecsResolver
import ai.ancf.lmos.router.llm.ModelClient
import ai.ancf.lmos.router.llm.ModelPromptProvider
import io.mockk.mockk
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.ai.chat.model.ChatModel
import kotlin.test.assertEquals

class LLMAgentRoutingSpecsResolverAutoConfigurationTest {
private lateinit var properties: LLMAgentRoutingSpecsResolverProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkConstructor
import io.mockk.verify
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class DefaultModelClientTest {
private lateinit var defaultModelClientProperties: DefaultModelClientProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
package ai.ancf.lmos.router.vector.starter

import io.mockk.junit5.MockKExtension
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

@ExtendWith(MockKExtension::class)
class SpringVectorSearchClientPropertiesTest {
Expand Down Expand Up @@ -45,7 +45,7 @@ class SpringVectorSearchClientPropertiesTest {
@Test
fun `should throw an exception for invalid threshold`() {
val exception =
assertFailsWith<IllegalArgumentException> {
assertThrows<IllegalArgumentException> {
SpringVectorSearchClientProperties(threshold = -1.0)
}
assertEquals("threshold must be between 0.0 and 1.0", exception.message)
Expand All @@ -54,7 +54,7 @@ class SpringVectorSearchClientPropertiesTest {
@Test
fun `should throw an exception for invalid topK`() {
val exception =
assertFailsWith<IllegalArgumentException> {
assertThrows<IllegalArgumentException> {
SpringVectorSearchClientProperties(topK = -1)
}
assertEquals("topK must be a positive integer", exception.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

package ai.ancf.lmos.router.vector

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import kotlin.math.sqrt
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

class CosineSimilarityTest {
@Test
Expand All @@ -18,7 +18,7 @@ class CosineSimilarityTest {

// When & Then
val exception =
assertFailsWith<IllegalArgumentException> {
assertThrows<IllegalArgumentException> {
vectorA.cosineSimilarity(vectorB)
}
assertEquals("Vectors must be of the same length", exception.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.serialization.json.Json
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import kotlin.test.assertFailsWith
import org.junit.jupiter.api.assertThrows

class VectorSearchClientRequestTest {
private lateinit var context: Context
Expand Down Expand Up @@ -74,7 +74,7 @@ class VectorClientExceptionTest {
val message = "An error occurred"

val exception =
assertFailsWith<VectorClientException> {
assertThrows<VectorClientException> {
throw VectorClientException(message)
}

Expand Down

0 comments on commit a977c9e

Please sign in to comment.