From bf2856c59bf67b77e5d2b5b8fc008d195597afc3 Mon Sep 17 00:00:00 2001 From: Nathan Przybyszewski <172687074+nprzy@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:38:25 -0600 Subject: [PATCH 1/3] Remove unused dependencies --- build.gradle.kts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b3c6965..cb8368e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,14 +25,9 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion") - implementation("org.jetbrains.exposed:exposed-core:$exposedVersion") - implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion") - implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion") - implementation("org.xerial:sqlite-jdbc:3.46.0.0") implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") implementation("io.ktor:ktor-serialization-jackson:$ktorVersion") implementation("io.ktor:ktor-client-core-jvm:2.3.12") @@ -40,6 +35,7 @@ dependencies { implementation("io.ktor:ktor-client-logging-jvm:2.3.12") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") implementation("org.semver4j:semver4j:5.3.0") + testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") testImplementation("org.assertj:assertj-core:3.26.0") From 0ccb29b4cf5cb8e7f438dc055ef53fab3ce6f9ae Mon Sep 17 00:00:00 2001 From: Nathan Przybyszewski <172687074+nprzy@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:47:14 -0600 Subject: [PATCH 2/3] Move dependencies with common versions to Version Catalog Previously these were kept in gradle.properties, which is not supported by Dependabot. This moves all dependencies that share a common version (and therefore should be upgraded at the same time) to a Gradle Version Catalog, which is supported by Dependabot. --- build.gradle.kts | 23 ++++++++--------------- gradle.properties | 5 ----- gradle/libs.versions.toml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index cb8368e..9e216b7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,8 +9,8 @@ val jacksonVersion: String by project plugins { id("org.springframework.boot") version "3.3.1" id("io.spring.dependency-management") version "1.1.5" - kotlin("jvm") version "1.9.24" - kotlin("plugin.spring") version "1.9.24" + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.spring) } group = "net.djvk" @@ -22,24 +22,17 @@ repositories { } dependencies { + implementation(libs.bundles.openapi) + implementation(libs.ktor.cio) + implementation(libs.ktor.logging) implementation("org.springframework.boot:spring-boot-starter") - implementation("org.jetbrains.kotlin:kotlin-reflect") - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion") - implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") - implementation("io.ktor:ktor-serialization-jackson:$ktorVersion") - implementation("io.ktor:ktor-client-core-jvm:2.3.12") - implementation("io.ktor:ktor-client-cio-jvm:2.3.12") - implementation("io.ktor:ktor-client-logging-jvm:2.3.12") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") implementation("org.semver4j:semver4j:5.3.0") - testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") + testImplementation(libs.kotlin.test) + testImplementation(libs.ktor.mock) testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") testImplementation("org.assertj:assertj-core:3.26.0") - testImplementation("io.ktor:ktor-client-mock-jvm:2.3.12") } tasks.withType { diff --git a/gradle.properties b/gradle.properties index fa7b9bd..e69de29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +0,0 @@ -kotlinVersion=1.7.10 -kotlinCoroutinesVersion=1.6.3 -exposedVersion=0.39.2 -ktorVersion=2.1.1 -jacksonVersion=2.13.4 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..6e243a4 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,33 @@ +[versions] +kotlin = "1.9.24" +ktor = "2.3.12" +jackson = "2.17.0" + +[libraries] +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" } +jackson-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" } +ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } +ktor-contentnegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } +ktor-jackson-client = { module = "io.ktor:ktor-client-jackson", version.ref = "ktor" } +ktor-jackson-serialization = { module = "io.ktor:ktor-serialization-jackson", version.ref = "ktor" } +ktor-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } +ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } +ktor-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } + +[bundles] +# Dependencies required by the generated OpenAPI clients. +openapi = [ + "kotlin-reflect", + "jackson-kotlin", + "jackson-jsr310", + "ktor-core", + "ktor-contentnegotiation", + "ktor-jackson-client", + "ktor-jackson-serialization", +] + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } \ No newline at end of file From e452a0466ecf9e847e645085f2babe04baefc21c Mon Sep 17 00:00:00 2001 From: Dan van Kley Date: Wed, 17 Jul 2024 07:52:37 -0400 Subject: [PATCH 3/3] That last commit would allow invalid primary categories; clean up that logic and test a little. --- .../transactions/PersonalFinanceCategoryEnum.kt | 16 ++++++++++------ .../PersonalFinanceCategoryEnumTest.kt | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnum.kt b/src/main/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnum.kt index 96fc6d6..d96e12c 100644 --- a/src/main/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnum.kt +++ b/src/main/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnum.kt @@ -162,16 +162,20 @@ enum class PersonalFinanceCategoryEnum(val primary: Primary, val detailed: Detai return entries.find { it.primary.name == categoryModel.primary && it.name == categoryModel.detailed } - // Fallback to handle random Plaid bugs + // Fallback to handle random Plaid issues where the primary and detailed are both valid, but + // don't match each other ?: run { - val fallback = entries.find { it.name == categoryModel.detailed } - if (fallback != null) { + val fallbackPrimary = entries.find { it.primary.name == categoryModel.primary } + val fallbackDetailed = entries.find { it.name == categoryModel.detailed } + if (fallbackPrimary != null && fallbackDetailed != null) { logger.warn( - "Invalid personal finance category $categoryModel; falling back to likely " + - "correct value $fallback" + "Incoming personal finance category $categoryModel has valid but non-matching primary and detailed " + + "values. Falling back to using the detailed value $fallbackDetailed" ) + fallbackDetailed + } else { + null } - fallback } // Give up ?: throw IllegalArgumentException("Failed to convert personal finance category $categoryModel to enum") diff --git a/src/test/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnumTest.kt b/src/test/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnumTest.kt index 95a5a46..52c9cad 100644 --- a/src/test/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnumTest.kt +++ b/src/test/kotlin/net/djvk/fireflyPlaidConnector2/transactions/PersonalFinanceCategoryEnumTest.kt @@ -24,7 +24,7 @@ internal class PersonalFinanceCategoryEnumTest { ), Arguments.of( // testName: String, - "Goofy edge case", + "Valid but not matching primary and detailed (should be handled as we see this in prod sometimes)", // input: PersonalFinanceCategory, PersonalFinanceCategory("TRAVEL", "TRANSPORTATION_PUBLIC_TRANSIT"), // expectedResult: PersonalFinanceCategoryEnum?, @@ -36,7 +36,7 @@ internal class PersonalFinanceCategoryEnumTest { // testName: String, "Invalid primary", // input: PersonalFinanceCategory, - PersonalFinanceCategory("TACOS", "FAST_FOOD"), + PersonalFinanceCategory("TACOS", "FOOD_AND_DRINK_FAST_FOOD"), // expectedResult: PersonalFinanceCategoryEnum?, null, // expectedException: Boolean,