Skip to content

Commit

Permalink
Bump spring boot to 3.4.0 and update other dependencies to latest com…
Browse files Browse the repository at this point in the history
…patible version
  • Loading branch information
chrissearle committed Dec 12, 2024
1 parent 618e330 commit 82c390c
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 64 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ tasks.jacocoTestReport {
tasks.named("check") {
dependsOn(tasks.jacocoTestReport)
}

22 changes: 11 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
detekt_version = "1.23.6"
kotest_version = "5.9.0"
kotlin_version = "1.9.23"
kotlin_allopen_version = "1.9.23"
kotlin_jpa_version = "1.9.23"
kotlinter_version = "4.3.0"
kotlinx_version = "1.8.1"
mockk_version = "1.13.10"
spring_boot_version = "3.2.5"
spring_refs_version = "1.1.5"
flyway_version = "10.13.0"
detekt_version = "1.23.7"
flyway_version = "11.0.1"
kotest_version = "5.9.1"
kotlin_allopen_version = "2.0.10"
kotlin_jpa_version = "2.0.10"
kotlin_version = "2.0.10"
kotlinter_version = "5.0.0"
kotlinx_version = "1.9.0"
mockk_version = "1.13.13"
spring_boot_version = "3.4.0"
spring_refs_version = "1.1.6"

[libraries]
spring_boot_starter = { group = "org.springframework.boot", name = "spring-boot-starter" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/kotlinData")
class DataKotlinController(val service: DataKotlinService) {
class DataKotlinController(
val service: DataKotlinService,
) {
@RequestMapping("/")
fun getAll() = service.getAll()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/kotlin")
class DummyKotlinController(val service: DummyKotlinService) {
class DummyKotlinController(
val service: DummyKotlinService,
) {
@RequestMapping("/")
fun healthCheck() =
if (service.backendCheck()) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/itera/test/service/DataKotlinService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.itera.test.unwrap
import org.springframework.stereotype.Service

@Service
class DataKotlinService(val repository: DataKotlinRepository) {
class DataKotlinService(
val repository: DataKotlinRepository,
) {
fun getAll() = repository.findAll().toList()

fun getData(id: Long) = repository.findById(id).unwrap() ?: throw DataNotFoundException()
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/itera/test/service/DummyKotlinService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.itera.test.repository.DummyKotlinRepository
import org.springframework.stereotype.Service

@Service
class DummyKotlinService(val repository: DummyKotlinRepository) {
class DummyKotlinService(
val repository: DummyKotlinRepository,
) {
fun backendCheck() = repository.isUp()
}
57 changes: 29 additions & 28 deletions src/test/kotlin/com/itera/test/DataKotlinServiceMockkFunSpecTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,47 @@ import io.mockk.slot
import io.mockk.verify
import java.util.Optional

class DataKotlinServiceMockkFunSpecTest : FunSpec({
val repository = mockk<DataKotlinRepository>()
class DataKotlinServiceMockkFunSpecTest :
FunSpec({
val repository = mockk<DataKotlinRepository>()

afterTest {
clearMocks(repository)
}
afterTest {
clearMocks(repository)
}

test("get all") {
every { repository.findAll() } returns listOf()
test("get all") {
every { repository.findAll() } returns listOf()

val service = DataKotlinService(repository)
val service = DataKotlinService(repository)

service.getAll() shouldBe listOf<DataKotlin>()
service.getAll() shouldBe listOf<DataKotlin>()

verify(exactly = 1) { repository.findAll() }
}
verify(exactly = 1) { repository.findAll() }
}

test("get single") {
val slot = slot<Long>()
test("get single") {
val slot = slot<Long>()

every { repository.findById(capture(slot)) } returns Optional.of(DataKotlin(1, ""))
every { repository.findById(capture(slot)) } returns Optional.of(DataKotlin(1, ""))

val service = DataKotlinService(repository)
val service = DataKotlinService(repository)

service.getData(1) shouldBe DataKotlin(1, "")
service.getData(1) shouldBe DataKotlin(1, "")

verify(exactly = 1) { repository.findById(any()) }
verify(exactly = 1) { repository.findById(any()) }

slot.captured shouldBe 1
}
slot.captured shouldBe 1
}

test("get single no hit") {
every { repository.findById(any()) } returns Optional.empty()
test("get single no hit") {
every { repository.findById(any()) } returns Optional.empty()

val service = DataKotlinService(repository)
val service = DataKotlinService(repository)

shouldThrow<DataNotFoundException> {
service.getData(1)
}
shouldThrow<DataNotFoundException> {
service.getData(1)
}

verify(exactly = 1) { repository.findById(any()) }
}
})
verify(exactly = 1) { repository.findById(any()) }
}
})
37 changes: 19 additions & 18 deletions src/test/kotlin/com/itera/test/DummyJavaServiceMockkFunSpecTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,31 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.verify

class DummyJavaServiceMockkFunSpecTest : FunSpec({
val repository = mockk<DummyRepository>()
class DummyJavaServiceMockkFunSpecTest :
FunSpec({
val repository = mockk<DummyRepository>()

afterTest {
clearMocks(repository)
}
afterTest {
clearMocks(repository)
}

test("status check") {
every { repository.isUp } returns true
test("status check") {
every { repository.isUp } returns true

val service = DummyJavaService(repository)
val service = DummyJavaService(repository)

service.backendCheck() shouldBe true
service.backendCheck() shouldBe true

verify(exactly = 1) { repository.isUp }
}
verify(exactly = 1) { repository.isUp }
}

test("status check fails") {
every { repository.isUp } returns false
test("status check fails") {
every { repository.isUp } returns false

val service = DummyJavaService(repository)
val service = DummyJavaService(repository)

service.backendCheck() shouldBe false
service.backendCheck() shouldBe false

verify(exactly = 1) { repository.isUp }
}
})
verify(exactly = 1) { repository.isUp }
}
})

0 comments on commit 82c390c

Please sign in to comment.