Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into generate-plaid-client
Browse files Browse the repository at this point in the history
  • Loading branch information
nprzy committed Jul 18, 2024
2 parents c14d4f4 + cfe4d2f commit f4e5ad2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
27 changes: 8 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ plugins {
id("org.openapi.generator") version "7.7.0"
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"
Expand All @@ -24,28 +24,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.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")
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(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")
}

var generatePlaidClient = tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generatePlaidClient") {
Expand Down
5 changes: 0 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
kotlinVersion=1.7.10
kotlinCoroutinesVersion=1.6.3
exposedVersion=0.39.2
ktorVersion=2.1.1
jacksonVersion=2.13.4
kotlin.daemon.jvmargs=-Xmx3g
33 changes: 33 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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" }
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -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,
Expand Down

0 comments on commit f4e5ad2

Please sign in to comment.