diff --git a/app-server/build.gradle.kts b/app-server/build.gradle.kts index 0aab59ee..d7bccba3 100644 --- a/app-server/build.gradle.kts +++ b/app-server/build.gradle.kts @@ -1,30 +1,7 @@ import com.github.gradle.node.npm.task.NpmTask -import kotlinx.kover.gradle.plugin.dsl.AggregationType -import kotlinx.kover.gradle.plugin.dsl.MetricType -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -val springBootVersion = "3.1.2" -val springAzureVersion = "5.3.0" - -val flywayVersion = "9.21.0" -val mysqlConnectorVersion = "8.3.0" -val sqlserverConnectorVersion = "12.6.1.jre11" - -val kotlinLoggingVersion = "6.0.9" - -val junitSuiteApi = "1.10.2" -val greenmailVersion = "2.0.1" -var awaitilityVersion = "4.2.1" plugins { - java - id("jvm-test-suite") - id("org.jetbrains.kotlin.jvm") version "1.8.22" - id("org.jetbrains.kotlin.plugin.spring") version "1.8.22" - id("org.springframework.boot") version "3.1.2" - id("io.spring.dependency-management") version "1.1.2" id("com.microsoft.azure.azurewebapp") version "1.7.1" - id("org.jetbrains.kotlinx.kover") version "0.7.6" id("org.jetbrains.dokka") version "1.9.20" id("com.github.gmazzo.buildconfig") version "5.3.5" id("com.github.node-gradle.node") version "7.0.2" @@ -32,101 +9,41 @@ plugins { dependencyManagement { imports { - mavenBom("com.azure.spring:spring-cloud-azure-dependencies:$springAzureVersion") - mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion") + mavenBom(libs.spring.boot.bom.get().toString()) + mavenBom(libs.azure.spring.bom.get().toString()) } } -java { - sourceCompatibility = JavaVersion.VERSION_17 -} - -val deployVersion = if (project.hasProperty("deployVersion")) { - project.property("deployVersion") as String -} else { - "Aardvark-v0.1" -} - -buildConfig { - packageName("org.hkurh.doky") - documentation.set("Generated by BuildConfig plugin") - buildConfigField("DEPLOY_VERSION", provider { deployVersion }) -} - -tasks.withType { - kotlinOptions { - jvmTarget = "17" - } -} - -repositories { - mavenLocal() - mavenCentral() -} - dependencies { - annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") - - implementation("org.jetbrains.kotlin:kotlin-reflect") - - implementation("jakarta.validation:jakarta.validation-api:3.0.2") - - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-security") - implementation("org.springframework.boot:spring-boot-starter-validation") - implementation("org.springframework.boot:spring-boot-configuration-processor") - implementation("org.springframework.boot:spring-boot-starter-actuator") - - implementation("com.azure.spring:spring-cloud-azure-appconfiguration-config-web") - implementation("com.azure.spring:spring-cloud-azure-starter-keyvault") + implementation(project(":persistence")) - implementation("org.flywaydb:flyway-core:$flywayVersion") - implementation("org.flywaydb:flyway-sqlserver:$flywayVersion") - implementation("org.flywaydb:flyway-mysql:$flywayVersion") - implementation("com.microsoft.sqlserver:mssql-jdbc:$sqlserverConnectorVersion") - implementation("com.mysql:mysql-connector-j:$mysqlConnectorVersion") + implementation(libs.bundles.spring.starter.web) + implementation(libs.spring.boot.starter.data.jpa) + implementation(libs.spring.boot.starter.security) + implementation(libs.bundles.jwt) + implementation(libs.kotlin.reflect) + implementation(libs.bundles.validation) + implementation(libs.bundles.azure.keyvault) + implementation(libs.openapi.starter) + implementation(libs.bundles.json) + implementation(libs.commons.io) + implementation(libs.azure.blob) + implementation(libs.bundles.kafka) + developmentOnly(libs.spring.boot.devtools) - implementation("io.jsonwebtoken:jjwt-api:0.11.2") - implementation("io.jsonwebtoken:jjwt-impl:0.11.2") - implementation("io.jsonwebtoken:jjwt-jackson:0.11.2") + annotationProcessor(libs.spring.boot.config.processor) - implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0") + testImplementation(libs.bundles.testing.integration) + testImplementation(libs.bundles.testing.web) + testImplementation(libs.spring.kafka.test) - implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.13.1") - implementation("commons-io:commons-io:2.11.0") - implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion") - - implementation("com.azure:azure-storage-blob:12.25.3") - - implementation("org.apache.kafka:kafka-clients") - implementation("org.springframework.kafka:spring-kafka") - - implementation("net.logstash.logback:logstash-logback-encoder:7.4") - - runtimeOnly("org.springframework.boot:spring-boot-devtools") - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.apache.httpcomponents:httpclient:4.5.13") - testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") - testImplementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi") - testImplementation("org.mockito:mockito-junit-jupiter:4.0.0") - testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0") - - testImplementation("org.awaitility:awaitility:$awaitilityVersion") - testImplementation("org.springframework.kafka:spring-kafka-test") - testImplementation("io.rest-assured:rest-assured:5.3.0") + testRuntimeOnly(libs.junit.platform.launcher) } -tasks.withType().configureEach { - options.encoding = "UTF-8" -} - -tasks.withType().configureEach { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - jvmTarget = "17" +kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") } } @@ -134,47 +51,53 @@ testing { suites { val test by getting(JvmTestSuite::class) { useJUnitJupiter() + dependencies { + implementation(project(":persistence")) + implementation(libs.spring.boot.starter.data.jpa.get().toString()) + } } register("integrationTest") { + testType = TestSuiteType.INTEGRATION_TEST dependencies { implementation(project()) + implementation(project(":persistence")) - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-test") + implementation(libs.spring.boot.starter.test.get().toString()) + implementation(libs.awaitility.get().toString()) - implementation("org.springframework.boot:spring-boot-starter-security") - implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion") + implementation(libs.httpclient.get().toString()) + implementation(libs.rest.assured.get().toString()) - implementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi") + implementation(libs.spring.kafka.test.get().toString()) + implementation(libs.spring.kafka.production.get().toString()) + implementation(libs.kafka.clients.get().toString()) - implementation("com.icegreen:greenmail:$greenmailVersion") - implementation("org.awaitility:awaitility:$awaitilityVersion") + implementation(libs.greenmail.get().toString()) - implementation("org.springframework.kafka:spring-kafka-test") - implementation("org.apache.kafka:kafka-clients") - implementation("org.springframework.kafka:spring-kafka") + implementation(libs.spring.boot.starter.jdbc.get().toString()) + implementation(libs.spring.boot.starter.security.get().toString()) + + implementation(libs.kotlin.logging.get().toString()) } } register("apiTest") { + testType = TestSuiteType.FUNCTIONAL_TEST dependencies { implementation(project()) + implementation(project(":persistence")) + + implementation(libs.spring.boot.starter.test.get().toString()) + implementation(libs.junit4.get().toString()) - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-test") + implementation(libs.httpclient.get().toString()) + implementation(libs.rest.assured.get().toString()) - implementation("org.springframework:spring-mock:2.0.8") - implementation("org.apache.httpcomponents:httpclient:4.5.13") - implementation("org.junit.jupiter:junit-jupiter:5.8.2") - implementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi") - implementation("org.mockito:mockito-junit-jupiter:4.0.0") - implementation("org.mockito.kotlin:mockito-kotlin:5.0.0") - implementation("io.rest-assured:rest-assured:5.3.0") + implementation(libs.spring.kafka.test.get().toString()) + implementation(libs.spring.kafka.production.get().toString()) + implementation(libs.kafka.clients.get().toString()) - implementation("org.springframework.kafka:spring-kafka-test") - implementation("org.apache.kafka:kafka-clients") - implementation("org.springframework.kafka:spring-kafka") + implementation(libs.spring.boot.starter.data.jpa.get().toString()) + implementation(libs.spring.boot.starter.web.get().toString()) } } } @@ -182,7 +105,6 @@ testing { tasks.test { useJUnitPlatform() - maxHeapSize = "1G" testLogging { showStandardStreams = true events("PASSED", "SKIPPED", "FAILED") @@ -203,30 +125,16 @@ tasks.named("integrationTest") { } } -kover { - excludeSourceSets { - names("integrationTest") - names("apiTest") - } +val deployVersion = if (project.hasProperty("deployVersion")) { + project.property("deployVersion") as String +} else { + "Aardvark-v0.1" } -koverReport { - defaults { - filters { - includes { - classes("org.hkurh.*") - } - } - verify { - rule { - bound { - minValue = 33 - metric = MetricType.LINE - aggregation = AggregationType.COVERED_PERCENTAGE - } - } - } - } +buildConfig { + packageName("org.hkurh.doky") + documentation.set("Generated by BuildConfig plugin") + buildConfigField("DEPLOY_VERSION", provider { deployVersion }) } node { diff --git a/app-server/gradle/wrapper/gradle-wrapper.jar b/app-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 033e24c4..00000000 Binary files a/app-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/app-server/gradle/wrapper/gradle-wrapper.properties b/app-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index df97d72b..00000000 --- a/app-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/app-server/gradlew b/app-server/gradlew deleted file mode 100755 index fcb6fca1..00000000 --- a/app-server/gradlew +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# 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 -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/app-server/gradlew.bat b/app-server/gradlew.bat deleted file mode 100644 index 93e3f59f..00000000 --- a/app-server/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/app-server/src/apiTest/kotlin/org/hkurh/doky/RestSpec.kt b/app-server/src/apiTest/kotlin/org/hkurh/doky/RestSpec.kt index 762d77ab..4fd01ba1 100644 --- a/app-server/src/apiTest/kotlin/org/hkurh/doky/RestSpec.kt +++ b/app-server/src/apiTest/kotlin/org/hkurh/doky/RestSpec.kt @@ -4,9 +4,6 @@ import io.restassured.RestAssured.given import io.restassured.builder.RequestSpecBuilder import org.hkurh.doky.authorization.AuthenticationRequest import org.junit.jupiter.api.Tag -import org.junit.platform.suite.api.IncludeTags -import org.junit.platform.suite.api.Suite -import org.junit.platform.suite.api.SuiteDisplayName import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.web.server.LocalServerPort @@ -19,9 +16,6 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig @ActiveProfiles("test") @Tag("api") -@Suite -@SuiteDisplayName("API Tests") -@IncludeTags("api") @SpringJUnitConfig @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(topics = ["emails-test"]) diff --git a/app-server/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt b/app-server/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt index 98c1832f..605f7a53 100644 --- a/app-server/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt +++ b/app-server/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt @@ -1,9 +1,6 @@ package org.hkurh.doky import org.junit.jupiter.api.Tag -import org.junit.platform.suite.api.IncludeTags -import org.junit.platform.suite.api.Suite -import org.junit.platform.suite.api.SuiteDisplayName import org.springframework.boot.test.context.SpringBootTest import org.springframework.kafka.test.context.EmbeddedKafka import org.springframework.test.context.ActiveProfiles @@ -13,9 +10,6 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig @ActiveProfiles("test") @Tag("integration") -@Suite -@SuiteDisplayName("Integration Tests") -@IncludeTags("integration") @SpringJUnitConfig @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(topics = ["emails-test"]) diff --git a/app-server/src/main/resources/application-test.properties b/app-server/src/main/resources/application-test.properties index 39577a6d..c89ee58e 100644 --- a/app-server/src/main/resources/application-test.properties +++ b/app-server/src/main/resources/application-test.properties @@ -4,7 +4,7 @@ spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3309/doky-test?autoreconnect=true spring.datasource.password=doky-test spring.datasource.username=doky-test -spring.flyway.locations=db/migration/mysql +spring.flyway.locations=classpath:migration/mysql # file storage config doky.filestorage.path=./ci doky.filestorage.type=local-filesystem diff --git a/app-server/src/main/resources/application.properties b/app-server/src/main/resources/application.properties index 98b52b1d..8f3d43a5 100644 --- a/app-server/src/main/resources/application.properties +++ b/app-server/src/main/resources/application.properties @@ -11,7 +11,7 @@ springdoc.default-produces-media-type=application/json # database spring.session.jdbc.initialize-schema=never spring.jpa.open-in-view=false -spring.flyway.locations=db/migration/sqlserver +spring.flyway.locations=classpath:migration/sqlserver # logging server.error.include-stacktrace=never logging.level.web=WARN diff --git a/app-server/src/main/resources/logback-spring.xml b/app-server/src/main/resources/logback-spring.xml deleted file mode 100644 index ffb44501..00000000 --- a/app-server/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - timestamp - UTC - - - logger - - - level - - - thread - - - mdc - - - - - - stackTrace - - - - exceptionClass - - - - - - - - - diff --git a/app-server/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt b/app-server/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt index 0b55426c..d82fe39a 100644 --- a/app-server/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt +++ b/app-server/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt @@ -2,14 +2,8 @@ package org.hkurh.doky import org.junit.jupiter.api.Tag import org.junit.jupiter.api.extension.ExtendWith -import org.junit.platform.suite.api.IncludeTags -import org.junit.platform.suite.api.Suite -import org.junit.platform.suite.api.SuiteDisplayName import org.mockito.junit.jupiter.MockitoExtension @ExtendWith(MockitoExtension::class) @Tag("unit") -@Suite -@SuiteDisplayName("Unit Tests") -@IncludeTags("unit") interface DokyUnitTest diff --git a/app-server/src/test/kotlin/org/hkurh/doky/documents/impl/DefaultDocumentServiceTest.kt b/app-server/src/test/kotlin/org/hkurh/doky/documents/impl/DefaultDocumentServiceTest.kt deleted file mode 100644 index 2b539743..00000000 --- a/app-server/src/test/kotlin/org/hkurh/doky/documents/impl/DefaultDocumentServiceTest.kt +++ /dev/null @@ -1,144 +0,0 @@ -package org.hkurh.doky.documents.impl - -import org.hkurh.doky.DokyUnitTest -import org.hkurh.doky.documents.db.DocumentEntity -import org.hkurh.doky.documents.db.DocumentEntityRepository -import org.hkurh.doky.users.UserService -import org.hkurh.doky.users.db.UserEntity -import org.junit.jupiter.api.DisplayName -import org.mockito.kotlin.mock -import org.springframework.data.domain.Page -import org.springframework.data.domain.Pageable -import org.springframework.data.domain.Sort -import org.springframework.data.jpa.domain.Specification -import org.springframework.data.repository.query.FluentQuery -import java.util.* -import java.util.function.Function - -@DisplayName("DefaultDocumentService unit test") -class DefaultDocumentServiceTest : DokyUnitTest { - - private val documentEntityRepository: MockDocumentEntityRepository = mock() - private val userService: UserService = mock() - - private val documentService: DefaultDocumentService = - DefaultDocumentService(documentEntityRepository, userService) - - private fun createUserEntity(): UserEntity { - return UserEntity().apply { - id = 1 - name = "user" - } - } - - private fun createDocumentEntity(documentName: String): DocumentEntity { - return DocumentEntity().apply { - name = documentName - } - } - - /** - * Mock implementation of the [DocumentEntityRepository] interface. - */ - class MockDocumentEntityRepository : DocumentEntityRepository { - override fun findByCreatorId(documentId: Long): List { - TODO("Not yet implemented") - } - - override fun findByIdAndCreatorId(documentId: Long, creatorId: Long): DocumentEntity? { - TODO("Not yet implemented") - } - - override fun findLatestModified(modifiedDate: Date): List { - TODO("Not yet implemented") - } - - override fun findByListIdAndUserId(documentIdList: List, userId: Long): List { - TODO("Not yet implemented") - } - - override fun save(entity: S & Any): S & Any { - TODO("Not yet implemented") - } - - override fun saveAll(entities: MutableIterable): MutableIterable { - TODO("Not yet implemented") - } - - override fun findAll(): MutableIterable { - TODO("Not yet implemented") - } - - override fun findAll(spec: Specification): MutableList { - TODO("Not yet implemented") - } - - override fun findAll(spec: Specification, pageable: Pageable): Page { - TODO("Not yet implemented") - } - - override fun findAll(spec: Specification, sort: Sort): MutableList { - TODO("Not yet implemented") - } - - override fun findAllById(ids: MutableIterable): MutableIterable { - TODO("Not yet implemented") - } - - override fun count(): Long { - TODO("Not yet implemented") - } - - override fun count(spec: Specification): Long { - TODO("Not yet implemented") - } - - override fun delete(entity: DocumentEntity) { - TODO("Not yet implemented") - } - - override fun delete(spec: Specification): Long { - TODO("Not yet implemented") - } - - override fun deleteAllById(ids: MutableIterable) { - TODO("Not yet implemented") - } - - override fun deleteAll(entities: MutableIterable) { - TODO("Not yet implemented") - } - - override fun deleteAll() { - TODO("Not yet implemented") - } - - override fun findOne(spec: Specification): Optional { - TODO("Not yet implemented") - } - - override fun exists(spec: Specification): Boolean { - TODO("Not yet implemented") - } - - override fun findBy( - spec: Specification, - queryFunction: Function, R> - ): R & Any { - TODO("Not yet implemented") - } - - override fun deleteById(id: Long) { - TODO("Not yet implemented") - } - - override fun existsById(id: Long): Boolean { - TODO("Not yet implemented") - } - - override fun findById(id: Long): Optional { - TODO("Not yet implemented") - } - - } -} diff --git a/app-server/src/test/kotlin/org/hkurh/doky/users/DefaultUserServiceTest.kt b/app-server/src/test/kotlin/org/hkurh/doky/users/DefaultUserServiceTest.kt index ee40fe85..0e5f56e8 100644 --- a/app-server/src/test/kotlin/org/hkurh/doky/users/DefaultUserServiceTest.kt +++ b/app-server/src/test/kotlin/org/hkurh/doky/users/DefaultUserServiceTest.kt @@ -44,7 +44,7 @@ class DefaultUserServiceTest : DokyUnitTest { fun shouldPublishEvent_whenUserSuccessfullyRegistered() { // given val userEntity = createUserEntity() - whenever(userEntityRepository.save(any())).thenReturn(userEntity) + whenever(userEntityRepository.save(any())).thenReturn(userEntity) // when assertDoesNotThrow { userService.create(userUid, userPassword) } @@ -58,7 +58,7 @@ class DefaultUserServiceTest : DokyUnitTest { fun shouldNotPublishEvent_whenUserNotSuccessfullyRegistered() { // given val userEntity = createUserEntity() - whenever(userEntityRepository.save(any())).thenThrow(RuntimeException()) + whenever(userEntityRepository.save(any())).thenThrow(RuntimeException()) // when assertThrows { userService.create(userUid, userPassword) } @@ -72,7 +72,7 @@ class DefaultUserServiceTest : DokyUnitTest { fun shouldSetUserNameFromUid_whenRegister() { // given val userEntity = createUserEntity() - whenever(userEntityRepository.save(any())).thenReturn(userEntity) + whenever(userEntityRepository.save(any())).thenReturn(userEntity) // when userService.create(userUid, userPassword) @@ -87,7 +87,7 @@ class DefaultUserServiceTest : DokyUnitTest { // given val userEntity = createUserEntity() val authority = createAuthorityEntity() - whenever(userEntityRepository.save(any())).thenReturn(userEntity) + whenever(userEntityRepository.save(any())).thenReturn(userEntity) whenever(authorityEntityRepository.findByAuthority(UserAuthority.ROLE_USER)).thenReturn(authority) // when @@ -126,7 +126,7 @@ class DefaultUserServiceTest : DokyUnitTest { TODO("Not yet implemented") } - override fun save(entity: S & Any): S & Any { + override fun save(entity: S): S { TODO("Not yet implemented") } @@ -138,15 +138,15 @@ class DefaultUserServiceTest : DokyUnitTest { TODO("Not yet implemented") } - override fun findAll(spec: Specification): MutableList { + override fun findAll(spec: Specification?): MutableList { TODO("Not yet implemented") } - override fun findAll(spec: Specification, pageable: Pageable): Page { + override fun findAll(spec: Specification?, pageable: Pageable): Page { TODO("Not yet implemented") } - override fun findAll(spec: Specification, sort: Sort): MutableList { + override fun findAll(spec: Specification?, sort: Sort): MutableList { TODO("Not yet implemented") } @@ -158,15 +158,11 @@ class DefaultUserServiceTest : DokyUnitTest { TODO("Not yet implemented") } - override fun count(spec: Specification): Long { + override fun count(spec: Specification?): Long { TODO("Not yet implemented") } - override fun delete(entity: UserEntity) { - TODO("Not yet implemented") - } - - override fun delete(spec: Specification): Long { + override fun delete(spec: Specification?): Long { TODO("Not yet implemented") } @@ -190,10 +186,14 @@ class DefaultUserServiceTest : DokyUnitTest { TODO("Not yet implemented") } - override fun findBy( + override fun findBy( spec: Specification, queryFunction: Function, R> - ): R & Any { + ): R { + TODO("Not yet implemented") + } + + override fun delete(entity: UserEntity) { TODO("Not yet implemented") } @@ -208,6 +208,5 @@ class DefaultUserServiceTest : DokyUnitTest { override fun findById(id: Long): Optional { TODO("Not yet implemented") } - } } diff --git a/build.gradle.kts b/build.gradle.kts index c76d2e19..4a42121e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,9 +8,47 @@ allprojects { group = "org.hkurh" plugins { + kotlin("jvm") version "1.9.25" + kotlin("plugin.spring") version "1.9.25" + kotlin("plugin.jpa") version "1.9.25" apply false + id("org.springframework.boot") version "3.3.4" apply false + id("io.spring.dependency-management") version "1.1.6" id("org.sonarqube") version "5.1.0.4882" } +dependencyManagement { + imports { + mavenBom(libs.spring.boot.bom.get().toString()) + mavenBom(libs.azure.spring.bom.get().toString()) + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +subprojects { + apply(plugin = "org.jetbrains.kotlin.jvm") + apply(plugin = "org.jetbrains.kotlin.plugin.spring") + apply(plugin = "org.jetbrains.kotlin.plugin.jpa") + apply(plugin = "org.springframework.boot") + apply(plugin = "io.spring.dependency-management") + + java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } + } + + val libs = rootProject.extensions.getByType().named("libs") + dependencies { + implementation(libs.findLibrary("kotlin.logging").get()) + testImplementation(libs.findBundle("testing.unit").get()) + } +} + val branchName = if (project.hasProperty("branchName")) { project.property("branchName") as String } else { diff --git a/email-service/build.gradle.kts b/email-service/build.gradle.kts index e4ccd120..c157e249 100644 --- a/email-service/build.gradle.kts +++ b/email-service/build.gradle.kts @@ -1,50 +1,10 @@ -val kotlinVersion = "1.9.25" -val springBootVersion = "3.3.4" -val springDependencyVersion = "1.1.6" -val springAzureVersion = "5.16.0" - -val kotlinLoggingVersion = "6.0.9" -val sendgridVersion = "4.10.1" - -val greenmailVersion = "2.0.1" -val awaitilityVersion = "4.2.1" -val junitSuiteVersion = "1.10.2" -val jupiterVersion = "5.8.2" -val mockitoJupiterVersion = "4.0.0" -val mockitoKotlinVersion = "5.0.0" - -plugins { - kotlin("jvm") version "1.9.25" - kotlin("plugin.spring") version "1.9.25" - id("org.springframework.boot") version "3.3.4" - id("io.spring.dependency-management") version "1.1.6" - kotlin("plugin.jpa") version "1.9.25" -} - dependencyManagement { imports { - mavenBom("com.azure.spring:spring-cloud-azure-dependencies:$springAzureVersion") - mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion") - } -} - -repositories { - mavenLocal() - mavenCentral() -} - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) + mavenBom(libs.spring.boot.bom.get().toString()) + mavenBom(libs.azure.spring.bom.get().toString()) } } -version = if (project.hasProperty("deployVersion")) { - project.property("deployVersion") as String -} else { - "Aardvark-v0.1" -} - configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) @@ -52,39 +12,25 @@ configurations { } dependencies { - implementation("org.springframework.boot:spring-boot-starter") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-mail") - implementation("org.springframework.boot:spring-boot-starter-thymeleaf") - implementation("com.azure.spring:spring-cloud-azure-appconfiguration-config-web") - implementation("com.azure.spring:spring-cloud-azure-starter-keyvault") - implementation("org.jetbrains.kotlin:kotlin-reflect") - implementation("org.springframework.kafka:spring-kafka") - - implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion") - implementation("org.apache.kafka:kafka-clients") - implementation("com.fasterxml.jackson.core:jackson-annotations") - implementation("com.sendgrid:sendgrid-java:$sendgridVersion") - - developmentOnly("org.springframework.boot:spring-boot-devtools") - - runtimeOnly("com.microsoft.sqlserver:mssql-jdbc") - runtimeOnly("com.mysql:mysql-connector-j") - - annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.kafka:spring-kafka-test") - testImplementation("org.junit.jupiter:junit-jupiter:$jupiterVersion") - testImplementation("org.junit.platform:junit-platform-suite-api:$junitSuiteVersion") - testImplementation("org.mockito:mockito-junit-jupiter:$mockitoJupiterVersion") - testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion") - testImplementation("com.icegreen:greenmail:$greenmailVersion") - testImplementation("org.awaitility:awaitility:$awaitilityVersion") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") + implementation(project(":persistence")) + + implementation(libs.bundles.spring.starter.web) + implementation(libs.spring.boot.starter.data.jpa) + implementation(libs.bundles.mail) + implementation(libs.bundles.azure.keyvault) + implementation(libs.kotlin.reflect) + implementation(libs.bundles.kafka) + implementation(libs.bundles.json) + + developmentOnly(libs.spring.boot.devtools) + + annotationProcessor(libs.spring.boot.config.processor) + + testImplementation(libs.bundles.testing.integration) + testImplementation(libs.spring.kafka.test) + testImplementation(libs.greenmail) + + testRuntimeOnly(libs.junit.platform.launcher) } kotlin { @@ -99,22 +45,23 @@ testing { useJUnitJupiter() } register("integrationTest") { + testType = TestSuiteType.INTEGRATION_TEST dependencies { implementation(project()) + implementation(project(":persistence")) - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-test") + implementation(libs.spring.boot.starter.test.get().toString()) + implementation(libs.awaitility.get().toString()) - implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion") + implementation(libs.spring.kafka.test.get().toString()) + implementation(libs.spring.kafka.production.get().toString()) + implementation(libs.kafka.clients.get().toString()) - implementation("org.junit.platform:junit-platform-suite-api:$junitSuiteVersion") + implementation(libs.greenmail.get().toString()) - implementation("com.icegreen:greenmail:$greenmailVersion") - implementation("org.awaitility:awaitility:$awaitilityVersion") + implementation(libs.spring.boot.starter.jdbc.get().toString()) - implementation("org.springframework.kafka:spring-kafka-test") - implementation("org.apache.kafka:kafka-clients") - implementation("org.springframework.kafka:spring-kafka") + implementation(libs.kotlin.logging.get().toString()) } } } @@ -122,7 +69,6 @@ testing { tasks.test { useJUnitPlatform() - maxHeapSize = "1G" testLogging { showStandardStreams = true events("PASSED", "SKIPPED", "FAILED") diff --git a/email-service/gradle/wrapper/gradle-wrapper.jar b/email-service/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a4b76b95..00000000 Binary files a/email-service/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/email-service/gradle/wrapper/gradle-wrapper.properties b/email-service/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index df97d72b..00000000 --- a/email-service/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/email-service/gradlew b/email-service/gradlew deleted file mode 100755 index f5feea6d..00000000 --- a/email-service/gradlew +++ /dev/null @@ -1,252 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# 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/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/email-service/gradlew.bat b/email-service/gradlew.bat deleted file mode 100644 index 9d21a218..00000000 --- a/email-service/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/email-service/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt b/email-service/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt index 98c1832f..605f7a53 100644 --- a/email-service/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt +++ b/email-service/src/integrationTest/kotlin/org/hkurh/doky/DokyIntegrationTest.kt @@ -1,9 +1,6 @@ package org.hkurh.doky import org.junit.jupiter.api.Tag -import org.junit.platform.suite.api.IncludeTags -import org.junit.platform.suite.api.Suite -import org.junit.platform.suite.api.SuiteDisplayName import org.springframework.boot.test.context.SpringBootTest import org.springframework.kafka.test.context.EmbeddedKafka import org.springframework.test.context.ActiveProfiles @@ -13,9 +10,6 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig @ActiveProfiles("test") @Tag("integration") -@Suite -@SuiteDisplayName("Integration Tests") -@IncludeTags("integration") @SpringJUnitConfig @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(topics = ["emails-test"]) diff --git a/email-service/src/main/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerService.kt b/email-service/src/main/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerService.kt index 752c1222..ac8c2938 100644 --- a/email-service/src/main/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerService.kt +++ b/email-service/src/main/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerService.kt @@ -47,7 +47,7 @@ class KafkaEmailNotificationConsumerService( private fun sendResetPasswordEmail(userId: Long) { userEntityRepository.findById(userId).ifPresent { user -> resetPasswordTokenEntityRepository.findByUser(user)?.apply { - this.token?.let { emailService.sendRestorePasswordEmail(user, it) } + this.token.let { emailService.sendRestorePasswordEmail(user, it) } } } } diff --git a/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt b/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt deleted file mode 100644 index 10a3a0d8..00000000 --- a/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.hkurh.doky.password.db - -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.Index -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.Table -import jakarta.persistence.UniqueConstraint -import org.hkurh.doky.users.db.UserEntity -import java.util.* - -@Entity -@Table( - name = "reset_password_tokens", - indexes = [Index(name = "idx_reset_password_tokens_token", columnList = "token")], - uniqueConstraints = [ - UniqueConstraint(name = "uc_reset_password_tokens_token", columnNames = ["token"]), - UniqueConstraint(name = "uc_reset_password_tokens_app_user", columnNames = ["app_user"])] -) -class ResetPasswordTokenEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - var id: Long = -1 - - @OneToOne - @JoinColumn(name = "app_user") - var user: UserEntity? = null - - @Column(name = "token") - var token: String? = null - - @Column(name = "expiration_date") - var expirationDate: Date? = null -} diff --git a/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt b/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt deleted file mode 100644 index 7a62fad2..00000000 --- a/email-service/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.hkurh.doky.password.db - -import org.hkurh.doky.users.db.UserEntity -import org.springframework.data.jpa.repository.JpaSpecificationExecutor -import org.springframework.data.repository.CrudRepository - - -/** - * Repository interface for managing reset password tokens. - * This interface extends the CrudRepository and JpaSpecificationExecutor interfaces. - */ -interface ResetPasswordTokenEntityRepository : - CrudRepository, JpaSpecificationExecutor { - - fun findByUser(user: UserEntity): ResetPasswordTokenEntity? -} diff --git a/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt b/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt deleted file mode 100644 index a2efa676..00000000 --- a/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.hkurh.doky.users.db - -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.Index -import jakarta.persistence.Table -import jakarta.persistence.UniqueConstraint - -@Entity -@Table( - name = "users", - indexes = [Index(name = "idx_users_uid", columnList = "uid")], - uniqueConstraints = [UniqueConstraint(name = "uc_users_uid", columnNames = ["uid"])] -) -class UserEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - var id: Long = -1 - - @Column(name = "uid", nullable = false, unique = true) - var uid: String = "" - - @Column(name = "name") - var name: String? = null -} diff --git a/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt b/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt deleted file mode 100644 index 97572212..00000000 --- a/email-service/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.hkurh.doky.users.db - -import org.springframework.data.jpa.repository.JpaSpecificationExecutor -import org.springframework.data.repository.CrudRepository - -/** - * The [UserEntityRepository] interface extends the [CrudRepository] and [JpaSpecificationExecutor] interfaces to provide - * CRUD operations and advanced queries for [UserEntity] objects. - */ -interface UserEntityRepository : CrudRepository, JpaSpecificationExecutor { - - fun findByUid(uid: String): UserEntity? - - fun existsByUid(uid: String): Boolean -} diff --git a/email-service/src/main/resources/application-test.properties b/email-service/src/main/resources/application-test.properties index 9585165a..5120447f 100644 --- a/email-service/src/main/resources/application-test.properties +++ b/email-service/src/main/resources/application-test.properties @@ -5,6 +5,7 @@ spring.datasource.url=jdbc:mysql://localhost:3309/doky-test?autoreconnect=true spring.datasource.password=doky-test spring.datasource.username=doky-test spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect +spring.flyway.locations=classpath:migration/mysql # email spring.mail.host=localhost spring.mail.port=2525 diff --git a/email-service/src/main/resources/application.properties b/email-service/src/main/resources/application.properties index 40ba681a..ef1c619d 100644 --- a/email-service/src/main/resources/application.properties +++ b/email-service/src/main/resources/application.properties @@ -5,6 +5,7 @@ spring.application.name=email-service # database spring.session.jdbc.initialize-schema=never spring.jpa.open-in-view=false +spring.flyway.locations=classpath:migration/sqlserver # logging logging.level.org.hkurh.doky=DEBUG # email diff --git a/email-service/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt b/email-service/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt index 0b55426c..d82fe39a 100644 --- a/email-service/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt +++ b/email-service/src/test/kotlin/org/hkurh/doky/DokyUnitTest.kt @@ -2,14 +2,8 @@ package org.hkurh.doky import org.junit.jupiter.api.Tag import org.junit.jupiter.api.extension.ExtendWith -import org.junit.platform.suite.api.IncludeTags -import org.junit.platform.suite.api.Suite -import org.junit.platform.suite.api.SuiteDisplayName import org.mockito.junit.jupiter.MockitoExtension @ExtendWith(MockitoExtension::class) @Tag("unit") -@Suite -@SuiteDisplayName("Unit Tests") -@IncludeTags("unit") interface DokyUnitTest diff --git a/email-service/src/test/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerServiceTest.kt b/email-service/src/test/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerServiceTest.kt index 9e30d702..13072444 100644 --- a/email-service/src/test/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerServiceTest.kt +++ b/email-service/src/test/kotlin/org/hkurh/doky/kafka/KafkaEmailNotificationConsumerServiceTest.kt @@ -32,7 +32,7 @@ class KafkaEmailNotificationConsumerServiceTest : DokyUnitTest { // given val existingUserId = 16L val user = createUser(existingUserId) - whenever(userEntityRepository.findById(existingUserId)).thenReturn(Optional.ofNullable(user) as Optional) + whenever(userEntityRepository.findById(existingUserId)).thenReturn(Optional.ofNullable(user)) val message = SendEmailMessage().apply { userId = existingUserId @@ -54,7 +54,7 @@ class KafkaEmailNotificationConsumerServiceTest : DokyUnitTest { val token = "" val user = createUser(existingUserId) val resetToken = createResetToken(user, token) - whenever(userEntityRepository.findById(existingUserId)).thenReturn(Optional.ofNullable(user) as Optional) + whenever(userEntityRepository.findById(existingUserId)).thenReturn(Optional.ofNullable(user)) whenever(resetPasswordTokenEntityRepository.findByUser(user)).thenReturn(resetToken) val message = SendEmailMessage().apply { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..a8211caf --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,87 @@ +[versions] +kotlin-jvm = "1.9.25" +spring-boot = "3.3.4" +azure-spring = "5.16.0" +kotlin-logging = "6.0.9" +flyway = "9.21.0" +jupiter = "5.8.2" +mockito-jupiter = "4.0.0" +mockito-kotlin = "5.0.0" +sendgrid = "4.10.1" +jackson-joda = "2.13.1" +awaitility = "4.2.1" +greenmail = "2.0.1" +jakarta-validation-api = "3.0.2" +jjwt = "0.11.2" +openapi-starter = "2.3.0" +commons-io = "2.11.0" +azure-blob = "12.25.3" +httpclient = "4.5.13" +rest-assured = "5.3.0" +junit4 = "4.13.2" + +[libraries] +spring-boot-bom = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot" } +azure-spring-bom = { group = "com.azure.spring", name = "spring-cloud-azure-dependencies", version.ref = "azure-spring" } +spring-boot-starter = { group = "org.springframework.boot", name = "spring-boot-starter" } +spring-boot-starter-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" } +spring-boot-starter-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" } +spring-boot-starter-mail = { group = "org.springframework.boot", name = "spring-boot-starter-mail" } +spring-boot-starter-thymeleaf = { group = "org.springframework.boot", name = "spring-boot-starter-thymeleaf" } +spring-boot-starter-data-jpa = { group = "org.springframework.boot", name = "spring-boot-starter-data-jpa" } +spring-boot-starter-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-jdbc" } +spring-boot-starter-security = { group = "org.springframework.boot", name = "spring-boot-starter-security" } +spring-boot-starter-validation = { group = "org.springframework.boot", name = "spring-boot-starter-validation" } +spring-boot-starter-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } +spring-boot-config-processor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor" } +spring-boot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } +spring-kafka-production = { group = "org.springframework.kafka", name = "spring-kafka" } +spring-kafka-test = { group = "org.springframework.kafka", name = "spring-kafka-test" } +azure-appconfiguration-config-web = { group = "com.azure.spring", name = "spring-cloud-azure-appconfiguration-config-web" } +azure-starter-keyvault = { group = "com.azure.spring", name = "spring-cloud-azure-starter-keyvault" } +kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "kotlin-logging" } +kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin-jvm" } +flyway-core = { group = "org.flywaydb", name = "flyway-core", version.ref = "flyway" } +flyway-sqlserver = { group = "org.flywaydb", name = "flyway-sqlserver", version.ref = "flyway" } +flyway-mysql = { group = "org.flywaydb", name = "flyway-mysql", version.ref = "flyway" } +sqlserver-connector = { group = "com.microsoft.sqlserver", name = "mssql-jdbc" } +mysql-connector = { group = "com.mysql", name = "mysql-connector-j" } +junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "jupiter" } +junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher" } +mockito-jupiter = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockito-jupiter" } +mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockito-kotlin" } +sendgrid = { group = "com.sendgrid", name = "sendgrid-java", version.ref = "sendgrid" } +kafka-clients = { group = "org.apache.kafka", name = "kafka-clients" } +jackson-annotations = { group = "com.fasterxml.jackson.core", name = "jackson-annotations" } +jackson-datatype-joda = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-joda", version.ref = "jackson-joda" } +awaitility = { group = "org.awaitility", name = "awaitility", version.ref = "awaitility" } +greenmail = { group = "com.icegreen", name = "greenmail", version.ref = "greenmail" } +jakarta-validation-api = { group = "jakarta.validation", name = "jakarta.validation-api", version.ref = "jakarta-validation-api" } +jjwt-api = { group = "io.jsonwebtoken", name = "jjwt-api", version.ref = "jjwt" } +jjwt-impl = { group = "io.jsonwebtoken", name = "jjwt-impl", version.ref = "jjwt" } +jjwt-jackson = { group = "io.jsonwebtoken", name = "jjwt-jackson", version.ref = "jjwt" } +openapi-starter = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "openapi-starter" } +commons-io = { group = "commons-io", name = "commons-io", version.ref = "commons-io" } +azure-blob = { group = "com.azure", name = "azure-storage-blob", version.ref = "azure-blob" } +httpclient = { group = "org.apache.httpcomponents", name = "httpclient", version.ref = "httpclient" } +rest-assured = { group = "io.rest-assured", name = "rest-assured", version.ref = "rest-assured" } +junit4 = { group = "junit", name = "junit", version.ref = "junit4" } + +[bundles] +flyway = ["flyway-core", "flyway-sqlserver", "flyway-mysql"] +database-connectors = ["sqlserver-connector", "mysql-connector"] +testing-unit = ["junit-jupiter", "mockito-jupiter", "mockito-kotlin"] +testing-integration = ["spring-boot-starter-test", "awaitility"] +testing-web = ["httpclient", "rest-assured"] +spring-starter-web = ["spring-boot-starter", "spring-boot-starter-actuator", "spring-boot-starter-web"] +mail = ["spring-boot-starter-mail", "spring-boot-starter-thymeleaf", "sendgrid"] +azure-keyvault = ["azure-appconfiguration-config-web", "azure-starter-keyvault"] +kafka = ["spring-kafka-production", "kafka-clients"] +json = ["jackson-annotations", "jackson-datatype-joda"] +validation = ["spring-boot-starter-validation", "jakarta-validation-api"] +jwt = ["jjwt-api", "jjwt-impl", "jjwt-jackson"] + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-jvm" } +spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } + diff --git a/persistence/build.gradle.kts b/persistence/build.gradle.kts new file mode 100644 index 00000000..e3d7e84a --- /dev/null +++ b/persistence/build.gradle.kts @@ -0,0 +1,33 @@ +dependencyManagement { + imports { + mavenBom(libs.spring.boot.bom.get().toString()) + } +} + +dependencies { + implementation(libs.spring.boot.starter.data.jpa) + implementation(libs.bundles.flyway) + implementation(libs.bundles.database.connectors) +} + +kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") + } +} + +testing { + suites { + val test by getting(JvmTestSuite::class) { + useJUnitJupiter() + } + } +} + +tasks.test { + useJUnitPlatform() + testLogging { + showStandardStreams = true + events("PASSED", "SKIPPED", "FAILED") + } +} diff --git a/persistence/settings.gradle.kts b/persistence/settings.gradle.kts new file mode 100644 index 00000000..9247569d --- /dev/null +++ b/persistence/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "persistence" diff --git a/app-server/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntity.kt b/persistence/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntity.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntity.kt rename to persistence/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntity.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntityRepository.kt b/persistence/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntityRepository.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntityRepository.kt rename to persistence/src/main/kotlin/org/hkurh/doky/documents/db/DocumentEntityRepository.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt b/persistence/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt rename to persistence/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntity.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt b/persistence/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt rename to persistence/src/main/kotlin/org/hkurh/doky/password/db/ResetPasswordTokenEntityRepository.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/security/UserAuthority.kt b/persistence/src/main/kotlin/org/hkurh/doky/security/UserAuthority.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/security/UserAuthority.kt rename to persistence/src/main/kotlin/org/hkurh/doky/security/UserAuthority.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntity.kt b/persistence/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntity.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntity.kt rename to persistence/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntity.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntityRepository.kt b/persistence/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntityRepository.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntityRepository.kt rename to persistence/src/main/kotlin/org/hkurh/doky/users/db/AuthorityEntityRepository.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt b/persistence/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt similarity index 100% rename from app-server/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt rename to persistence/src/main/kotlin/org/hkurh/doky/users/db/UserEntity.kt diff --git a/app-server/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt b/persistence/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt similarity index 80% rename from app-server/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt rename to persistence/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt index 97572212..b2eabd73 100644 --- a/app-server/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt +++ b/persistence/src/main/kotlin/org/hkurh/doky/users/db/UserEntityRepository.kt @@ -7,7 +7,7 @@ import org.springframework.data.repository.CrudRepository * The [UserEntityRepository] interface extends the [CrudRepository] and [JpaSpecificationExecutor] interfaces to provide * CRUD operations and advanced queries for [UserEntity] objects. */ -interface UserEntityRepository : CrudRepository, JpaSpecificationExecutor { +interface UserEntityRepository : CrudRepository, JpaSpecificationExecutor { fun findByUid(uid: String): UserEntity? diff --git a/app-server/src/main/resources/db/migration/afterMigrateError__remove_failed_migrations.sql b/persistence/src/main/resources/migration/afterMigrateError__remove_failed_migrations.sql similarity index 100% rename from app-server/src/main/resources/db/migration/afterMigrateError__remove_failed_migrations.sql rename to persistence/src/main/resources/migration/afterMigrateError__remove_failed_migrations.sql diff --git a/app-server/src/main/resources/db/migration/mysql/V1_0__initial.sql b/persistence/src/main/resources/migration/mysql/V1_0__initial.sql similarity index 100% rename from app-server/src/main/resources/db/migration/mysql/V1_0__initial.sql rename to persistence/src/main/resources/migration/mysql/V1_0__initial.sql diff --git a/app-server/src/main/resources/db/migration/mysql/V1_1__add_user_roles.sql b/persistence/src/main/resources/migration/mysql/V1_1__add_user_roles.sql similarity index 100% rename from app-server/src/main/resources/db/migration/mysql/V1_1__add_user_roles.sql rename to persistence/src/main/resources/migration/mysql/V1_1__add_user_roles.sql diff --git a/app-server/src/main/resources/db/migration/mysql/V1_4__rename_user_column_in_reset_password.sql b/persistence/src/main/resources/migration/mysql/V1_4__rename_user_column_in_reset_password.sql similarity index 100% rename from app-server/src/main/resources/db/migration/mysql/V1_4__rename_user_column_in_reset_password.sql rename to persistence/src/main/resources/migration/mysql/V1_4__rename_user_column_in_reset_password.sql diff --git a/app-server/src/main/resources/db/migration/sqlserver/V1_0__initial.sql b/persistence/src/main/resources/migration/sqlserver/V1_0__initial.sql similarity index 100% rename from app-server/src/main/resources/db/migration/sqlserver/V1_0__initial.sql rename to persistence/src/main/resources/migration/sqlserver/V1_0__initial.sql diff --git a/app-server/src/main/resources/db/migration/sqlserver/V1_1__add_user_roles.sql b/persistence/src/main/resources/migration/sqlserver/V1_1__add_user_roles.sql similarity index 100% rename from app-server/src/main/resources/db/migration/sqlserver/V1_1__add_user_roles.sql rename to persistence/src/main/resources/migration/sqlserver/V1_1__add_user_roles.sql diff --git a/app-server/src/main/resources/db/migration/sqlserver/V1_2__enable_change_tracking_db.sql b/persistence/src/main/resources/migration/sqlserver/V1_2__enable_change_tracking_db.sql similarity index 100% rename from app-server/src/main/resources/db/migration/sqlserver/V1_2__enable_change_tracking_db.sql rename to persistence/src/main/resources/migration/sqlserver/V1_2__enable_change_tracking_db.sql diff --git a/app-server/src/main/resources/db/migration/sqlserver/V1_3__enable_change_tracking_table.sql b/persistence/src/main/resources/migration/sqlserver/V1_3__enable_change_tracking_table.sql similarity index 100% rename from app-server/src/main/resources/db/migration/sqlserver/V1_3__enable_change_tracking_table.sql rename to persistence/src/main/resources/migration/sqlserver/V1_3__enable_change_tracking_table.sql diff --git a/app-server/src/main/resources/db/migration/sqlserver/V1_4__rename_user_column_in_reset_password.sql b/persistence/src/main/resources/migration/sqlserver/V1_4__rename_user_column_in_reset_password.sql similarity index 100% rename from app-server/src/main/resources/db/migration/sqlserver/V1_4__rename_user_column_in_reset_password.sql rename to persistence/src/main/resources/migration/sqlserver/V1_4__rename_user_column_in_reset_password.sql diff --git a/settings.gradle.kts b/settings.gradle.kts index 2edfc389..8374a952 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,8 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + rootProject.name = "doky" include("app-server") include("email-service") +include("persistence")