Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#33 Translate Java sources to Kotlin #36

Merged
merged 6 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup up JDK 21
- name: Setup up JDK 20
Kimiega marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-java@v3
with:
java-version: '21'
java-version: '20'
distribution: 'temurin'
cache: gradle

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build
run: gradle build
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
plugins {
kotlin("jvm") version "1.9.24"
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
val kotlinVersion = kotlin.coreLibrariesVersion
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
23 changes: 0 additions & 23 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts

This file was deleted.

This file was deleted.

20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/buildlogic.kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
kotlin("jvm")
}

group = "ru.ifmo.se.dating"
version = "1.0.0"

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(20)
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(20)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins {
id("buildlogic.kotlin-conventions")
`java-library`
}
3 changes: 1 addition & 2 deletions common/testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
id("buildlogic.java-library-conventions")
id("buildlogic.kotlin-library-conventions")
}

dependencies {
api(libs.org.testcontainers.postgresql)
api(libs.junit.junit)
compileOnly(libs.org.projectlombok.lombok)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ru.ifmo.se.dating.container

import org.testcontainers.containers.PostgreSQLContainer

class Postgres private constructor() : AutoCloseable {
private val container = PostgreSQLContainer(DOCKER_IMAGE_NAME)

fun jdbcUrl(): String {
return container.jdbcUrl
}

fun username(): String {
return container.username
}

fun password(): String {
return container.password
}

override fun close() {
container.stop()
container.close()
}

companion object {
private const val DOCKER_IMAGE_NAME = "postgres"

fun start(): Postgres {
val postgres = Postgres()
postgres.container.start()
return postgres
}
}
}
2 changes: 1 addition & 1 deletion matchmaker/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugins {
id("buildlogic.java-library-conventions")
id("buildlogic.kotlin-library-conventions")
}
7 changes: 1 addition & 6 deletions matchmaker/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id("buildlogic.java-conventions")
id("buildlogic.kotlin-conventions")
id("org.springframework.boot") version "3.0.0"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
java
application
}

Expand All @@ -13,10 +12,6 @@ dependencies {
implementation(libs.org.springdoc.springdoc.openapi.starter.webmvc.ui)
testImplementation(project(":common-testing"))
testImplementation(libs.org.springframework.boot.spring.boot.starter.test)
compileOnly(libs.org.projectlombok.lombok)
annotationProcessor(libs.org.projectlombok.lombok)
testCompileOnly(libs.org.projectlombok.lombok)
testAnnotationProcessor(libs.org.projectlombok.lombok)
}

application {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.ifmo.se.dating.matchmaker

import org.springframework.boot.test.util.TestPropertyValues
import org.springframework.context.ApplicationContextInitializer
import org.springframework.context.ConfigurableApplicationContext
import ru.ifmo.se.dating.container.Postgres

class DatabaseInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> {
private val postgres: Postgres = Postgres.start()

override fun initialize(applicationContext: ConfigurableApplicationContext) {
TestPropertyValues.of(
"spring.datasource.url=${postgres.jdbcUrl()}",
"spring.datasource.username=${postgres.username()}",
"spring.datasource.password=${postgres.password()}",
).applyTo(applicationContext.environment)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ru.ifmo.se.dating.matchmaker

import org.junit.Test

class MatchmakerStartupTest : MatchmakerTestSuite() {
@Test
fun contextLoads() {
// Okay
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ru.ifmo.se.dating.matchmaker

import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@ActiveProfiles(profiles = ["test"])
@SpringBootTest(
classes = [OpenApiGeneratorApplication::class],
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
useMainMethod = SpringBootTest.UseMainMethod.ALWAYS,
)
@ContextConfiguration(
initializers = [
DatabaseInitializer::class,
],
)
abstract class MatchmakerTestSuite
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.ifmo.se.dating.matchmaker.api

import org.junit.Assert
import org.junit.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.web.client.TestRestTemplate
import ru.ifmo.se.dating.matchmaker.MatchmakerTestSuite

class HttpMonitoringApiTest : MatchmakerTestSuite() {
@Autowired
private lateinit var rest: TestRestTemplate

@Test
fun healthcheck() {
Assert.assertEquals(getHealthcheck(), "public")
}

private fun getHealthcheck(): String {
val url = "http://localhost:8080/api/v1/monitoring/healthcheck"
val response = rest.getForEntity(url, String::class.java)
return response.body!!
}
}
2 changes: 1 addition & 1 deletion matchmaker/database/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buildlogic.java-library-conventions")
id("buildlogic.kotlin-library-conventions")
}

dependencies {
Expand Down
Loading
Loading