Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
a51de4b
Create codegen module
lauzadis Aug 9, 2024
0a779a1
Create codegen module
lauzadis Aug 9, 2024
011f367
Add tests and .api
lauzadis Aug 9, 2024
75e208a
Bootstrap
lauzadis Aug 9, 2024
d8c65c9
tests
lauzadis Aug 9, 2024
5edef54
Fix package name in StringsTest
lauzadis Aug 9, 2024
df80d66
Latest
lauzadis Aug 12, 2024
3d5818e
Rendering correctly now
lauzadis Aug 12, 2024
73514a5
Small style changes
lauzadis Aug 12, 2024
ba04d3e
ktlint
lauzadis Aug 12, 2024
dbd737e
ktlint
lauzadis Aug 12, 2024
1da4704
ktlint
lauzadis Aug 12, 2024
48455a9
Remove unused types
lauzadis Aug 12, 2024
77f0792
StringMap -> stringMap
lauzadis Aug 12, 2024
725a391
Remove old-form codegen
lauzadis Aug 12, 2024
77c3264
cleanup
lauzadis Aug 12, 2024
a0134e0
KDocs
lauzadis Aug 12, 2024
165e59b
apiDump
lauzadis Aug 12, 2024
6120b6b
bootstrap _something_
lauzadis Aug 12, 2024
abae3b0
rename module: annotation-processor -> annotations-processor
lauzadis Aug 12, 2024
924a04e
More skeleton
lauzadis Aug 12, 2024
d864987
.api
lauzadis Aug 12, 2024
3513113
Add extra metadata
lauzadis Aug 12, 2024
e995954
Remove unused function
lauzadis Aug 12, 2024
a1cfc8e
Pass around a `codeGeneratorName`
lauzadis Aug 13, 2024
f5cdd9a
annotations -> annotatedClasses
lauzadis Aug 13, 2024
54ec0b3
rename: AnnotationRenderer -> SchemaRenderer, add common BuilderRende…
lauzadis Aug 13, 2024
c8148fc
Promote `internal` objects back to `public`
lauzadis Aug 13, 2024
1176517
Check property nullability when rendering build method (specifically …
lauzadis Aug 13, 2024
aac0fda
Add TODOs
lauzadis Aug 13, 2024
3f566a6
Replace #L with #T where appropriate
lauzadis Aug 13, 2024
a0f0bfc
ktlint
lauzadis Aug 13, 2024
8327568
Add `RendererBase.use { ... }`
lauzadis Aug 13, 2024
48c4206
Combine operations and annotation processor codegen into common codeg…
lauzadis Aug 13, 2024
7ea934e
Temporarily disable annotation-processor-test
lauzadis Aug 13, 2024
171e47a
Configure `excludeProcessor`
lauzadis Aug 13, 2024
47499cb
Relocate to dynamodbmapper.codegen.* package
lauzadis Aug 14, 2024
3ea7b6f
Break out Types and DynamoDbMapperTypes
lauzadis Aug 14, 2024
599c9b1
ktlint
lauzadis Aug 14, 2024
addb7c7
Handle auto-import of nested types
lauzadis Aug 14, 2024
69b7c5f
ktlint
lauzadis Aug 14, 2024
f010bb5
Fix typo in KDocs
lauzadis Aug 14, 2024
42aebb2
Replace more #L with #T
lauzadis Aug 14, 2024
1788f2a
Replace more #L with #T
lauzadis Aug 14, 2024
5a39f82
Don't explicitly import types from the `kotlin` namespace
lauzadis Aug 14, 2024
e63b9e1
Remove explicit import on user class
lauzadis Aug 14, 2024
b68fa5e
ktlint
lauzadis Aug 14, 2024
c676c56
Merge branch 'feat-ddb-codegen' of github.com:awslabs/aws-sdk-kotlin …
lauzadis Aug 14, 2024
c283149
Bootstrap
lauzadis Aug 15, 2024
1306e75
rename to schema generator plugin
lauzadis Aug 15, 2024
406070a
update test name
lauzadis Aug 15, 2024
5d698ca
Use `kotlin` function
lauzadis Aug 16, 2024
5c2915e
Add two new Type.from methods
lauzadis Aug 16, 2024
98b59fb
Use #T in builder docs
lauzadis Aug 16, 2024
c971520
classType = Type.from(classDeclaration)
lauzadis Aug 16, 2024
881a7a8
apiDump
lauzadis Aug 16, 2024
f4f399a
Move `rendererName` to `renderCtx`
lauzadis Aug 16, 2024
9c63c47
Add single-line `docs(...)` function and fix API validation settings
lauzadis Aug 16, 2024
d3e3aeb
Further nesting of types and rename to `MapperTypes`
lauzadis Aug 16, 2024
1da7f9a
Remove unused types
lauzadis Aug 16, 2024
345fd8e
exclude annotation processor in ops-codegen
lauzadis Aug 16, 2024
fbd7ba1
rename module `codegen` to `hll-codegen`
lauzadis Aug 16, 2024
930fb53
rename module `codegen` to `hll-codegen`
lauzadis Aug 16, 2024
3513aa6
Add `type.baseName`
lauzadis Aug 16, 2024
1ca559c
Move [Member] to shared codegen module and clean up BuilderRenderer
lauzadis Aug 16, 2024
a1b54b6
ktlint
lauzadis Aug 16, 2024
a5d6c9d
Remove unnecessary visibility modifiers
lauzadis Aug 16, 2024
2f26925
Merge branch 'feat-ddb-codegen' of github.com:awslabs/aws-sdk-kotlin …
lauzadis Aug 16, 2024
7e3c972
Remove dependency on kotest since it's not Native-compatible
lauzadis Aug 19, 2024
4873078
Fix native builds
lauzadis Aug 19, 2024
2ae79f9
Latest
lauzadis Aug 19, 2024
4e34cc1
ktlintFormat
lauzadis Aug 19, 2024
07916ad
latest
lauzadis Aug 20, 2024
5deaf7f
revert
lauzadis Aug 20, 2024
94d269a
ktlint
lauzadis Aug 20, 2024
cdafd33
Merge branch 'feat-ddb-mapper' of github.com:awslabs/aws-sdk-kotlin i…
lauzadis Aug 20, 2024
b28f927
revert some manual changes
lauzadis Aug 20, 2024
7f2cdf0
revert some manual changes
lauzadis Aug 20, 2024
9038324
latest
lauzadis Aug 20, 2024
1da0e4a
move gradle plugin up
lauzadis Aug 20, 2024
32ce6c4
Fix issue with publication
lauzadis Aug 20, 2024
52641eb
Publication works!
lauzadis Aug 20, 2024
2e9397a
Plugin works!
lauzadis Aug 21, 2024
2f606d0
Clean up
lauzadis Aug 21, 2024
7c9272f
Clean up
lauzadis Aug 21, 2024
5e03d53
Remove unused module declaration
lauzadis Aug 21, 2024
21dc9e8
Remove extra newline
lauzadis Aug 21, 2024
ca3ec01
Clean up
lauzadis Aug 21, 2024
99a0465
Add a FIXME
lauzadis Aug 21, 2024
72bb40f
Reverting removing kotest
lauzadis Aug 21, 2024
90c4fd8
Add TODO
lauzadis Aug 21, 2024
17a5c5b
ktlint
lauzadis Aug 21, 2024
6343977
Make class open
lauzadis Aug 21, 2024
a0c4d59
Merge branch 'main' of github.com:awslabs/aws-sdk-kotlin into feat-gp…
lauzadis Aug 21, 2024
c5b863b
Merge branch 'feat-ddb-mapper' of github.com:awslabs/aws-sdk-kotlin i…
lauzadis Aug 21, 2024
8bfcf13
Publish sources JAR
lauzadis Aug 22, 2024
4106bed
Add extra configuration to Gradle plugin publication
lauzadis Aug 22, 2024
48968c9
Use sdk-version.txt to pass around the sdkVersion
lauzadis Aug 22, 2024
9642be3
Add a test package which consumes the plugin
lauzadis Aug 22, 2024
09f2f9c
Add a TODO to parameterize the test
lauzadis Aug 22, 2024
2e29bf0
ktlint
lauzadis Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-j
kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "coroutines-version" }

ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp-version" }
ksp-gradle-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp-version" }

slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-version" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j-version" }
Expand Down Expand Up @@ -145,3 +146,4 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-version" }
aws-kotlin-repo-tools-kmp = { id = "aws.sdk.kotlin.gradle.kmp", version.ref = "aws-kotlin-repo-tools-version" }
aws-kotlin-repo-tools-smithybuild = { id = "aws.sdk.kotlin.gradle.smithybuild", version.ref = "aws-kotlin-repo-tools-version" }
aws-kotlin-repo-tools-artifactsizemetrics = { id = "aws.sdk.kotlin.gradle.artifactsizemetrics", version.ref = "aws-kotlin-repo-tools-version" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version = "1.2.1"}
1 change: 1 addition & 0 deletions hll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ apiValidation {
"hll-codegen",
"dynamodb-mapper-annotation-processor-test",
"dynamodb-mapper-codegen",
"dynamodb-mapper-schema-generator-plugin-test",
).filter { it in availableSubprojects } // Some projects may not be in the build depending on bootstrapping
}
32 changes: 32 additions & 0 deletions hll/dynamodb-mapper/dynamodb-mapper-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extra["moduleName"] = "aws.sdk.kotlin.hll.dynamodbmapper.codegen"

plugins {
alias(libs.plugins.kotlin.jvm)
`maven-publish`
}

dependencies {
Expand All @@ -22,3 +23,34 @@ dependencies {
testImplementation(libs.kotest.assertions.core.jvm)
testImplementation(libs.kotlin.test.junit5)
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
showStackTraces = true
showExceptions = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

val sourcesJar by tasks.creating(Jar::class) {
group = "publishing"
description = "Assembles Kotlin sources jar"
archiveClassifier.set("sources")
from(sourceSets.getByName("main").allSource)
}

publishing {
publications {
create<MavenPublication>("dynamodb-mapper-codegen") {
from(components["java"])
artifact(sourcesJar)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public final class aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin : org/gradle/api/Plugin {
public fun <init> ()V
public synthetic fun apply (Ljava/lang/Object;)V
public fun apply (Lorg/gradle/api/Project;)V
}

public final class aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPlugin$inlined$sam$i$org_gradle_api_Action$0 : org/gradle/api/Action {
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public final synthetic fun execute (Ljava/lang/Object;)V
}

public class aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginExtension {
public fun <init> ()V
}

public final class aws/sdk/kotlin/hll/dynamodbmapper/plugins/SchemaGeneratorPluginKt {
public static final field SCHEMA_GENERATOR_PLUGIN_EXTENSION Ljava/lang/String;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
description = "Plugin used to generate DynamoDbMapper schemas from user classes"
extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL :: DynamoDbMapper :: Schema Generator Plugin"
extra["moduleName"] = "aws.sdk.kotlin.hll.dynamodbmapper.plugins"

plugins {
`kotlin-dsl`
`java-gradle-plugin`
alias(libs.plugins.gradle.plugin.publish)
`maven-publish`
}

dependencies {
implementation(kotlin("gradle-plugin"))
implementation(libs.ksp.gradle.plugin)

testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.kotlin.test)
}

gradlePlugin {
website = "https://github.com/awslabs/aws-sdk-kotlin"
vcsUrl = "https://github.com/awslabs/aws-sdk-kotlin.git"
plugins {
create("dynamodb-mapper-schema-generator") {
id = "aws.sdk.kotlin.hll.dynamodbmapper.schema.generator"
displayName = "DynamoDbMapper Schema Generator"
description = "Plugin used to generate DynamoDbMapper schemas from user classes"
tags = setOf("kotlin", "dynamodb", "aws")
implementationClass = "aws.sdk.kotlin.hll.dynamodbmapper.plugins.SchemaGeneratorPlugin"
}
}
}

val sdkVersion: String by project
group = "aws.sdk.kotlin"
version = sdkVersion

publishing {
publications {
create<MavenPublication>("dynamodb-mapper-schema-generator-plugin") {
from(components["java"])
}
}
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
showStackTraces = true
showExceptions = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}

/**
* Create a file containing the sdkVersion to use as a resource
* This saves us from having to manually change version numbers in multiple places
*/
val generateSdkRuntimeVersion by tasks.registering {
val resourcesDir = layout.buildDirectory.dir("resources/main/aws/sdk/kotlin/hll/dynamodbmapper/plugins").get()
val versionFile = file("$resourcesDir/sdk-version.txt")
val gradlePropertiesFile = rootProject.file("gradle.properties")
inputs.file(gradlePropertiesFile)
outputs.file(versionFile)
sourceSets.main.get().output.dir(resourcesDir)
doLast {
versionFile.writeText(sdkVersion)
}
}

tasks.withType<KotlinCompile> {
dependsOn(generateSdkRuntimeVersion)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.plugins

import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.create

open class SchemaGeneratorPluginExtension {
// TODO Add configuration here (such as codegen configuration)
}

const val SCHEMA_GENERATOR_PLUGIN_EXTENSION = "schemaGeneratorPluginExtension"

public class SchemaGeneratorPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
createExtension()
configureDependencies()
}

private fun Project.createExtension(): SchemaGeneratorPluginExtension = extensions.create<SchemaGeneratorPluginExtension>(SCHEMA_GENERATOR_PLUGIN_EXTENSION)

private fun Project.configureDependencies() {
logger.info("Configuring dependencies for schema generation...")
pluginManager.apply("com.google.devtools.ksp")

extensions.configure<KspExtension> {
excludeProcessor("aws.sdk.kotlin.hll.dynamodbmapper.codegen.operations.HighLevelOpsProcessorProvider")
// TODO pass plugin configuration to KSP as args...
}

val sdkVersion = getSdkVersion()
dependencies.add("ksp", "aws.sdk.kotlin:dynamodb-mapper-codegen:$sdkVersion")
}

// Reads sdk-version.txt for the SDK version to add dependencies on. The file is created in this module's build.gradle.kts
private fun getSdkVersion(): String = try {
this.javaClass.getResource("sdk-version.txt")?.readText() ?: throw IllegalStateException("sdk-version.txt does not exist")
} catch (ex: Exception) {
throw IllegalStateException("Failed to load sdk-version.txt which sets the SDK version", ex)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package aws.sdk.kotlin.hll.dynamodbmapper.plugins

import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import java.io.File
import kotlin.test.assertContains

class SchemaGeneratorPluginTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Oh interesting—I was expecting your plugin tests to be another module sort of like dynamodb-mapper-annotation-processor-test. This looks like it works but I wonder if we miss anything by not having actual test modules as part of the overall Gradle project. Do you know if this is the recommended style of testing Gradle plugins and, if so, what tradeoffs it might have?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using the Gradle TestKit which seemed recommended for testing plugins. I think having another test module would be another good test to have, I'll look at adding it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added another test package which consumes the plugin. It's basically a copy of dynamodb-mapper-annotation-processor-test without the manual KSP configuration. We can expand this as more features are added like codegen configuration.

@TempDir
lateinit var testProjectDir: File

private lateinit var settingsFile: File
private lateinit var buildFile: File

@BeforeEach
fun setup() {
settingsFile = File(testProjectDir, "settings.gradle.kts")
buildFile = File(testProjectDir, "build.gradle.kts")
}

@AfterEach
fun cleanup() {
if (settingsFile.exists()) {
settingsFile.delete()
}
if (buildFile.exists()) {
buildFile.delete()
}
}

// TODO Parameterize the test across multiple versions of Kotlin and Gradle
@Test
fun `applies the plugin`() {
val buildFileContent = """
plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("aws.sdk.kotlin.hll.dynamodbmapper.schema.generator")
}
configure<aws.sdk.kotlin.hll.dynamodbmapper.plugins.SchemaGeneratorPluginExtension>{ }
""".trimIndent()

buildFile.writeText(buildFileContent)

val result = GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments("--info", "build")
.withPluginClasspath()
.withGradleVersion("8.5")
.forwardOutput()
.build()

assertContains(setOf(TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE), result.task(":build")?.outcome)
}
Comment on lines +36 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: This test/module may benefit from more dynamic versioning retrieved at runtime to avoid hardcoding things like the Gradle runner version, Kotlin version, etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would have a parameterized test with multiple versions of Kotlin and Gradle. I think it should be added in follow-on PRs, I will add a TODO here.

}
6 changes: 5 additions & 1 deletion hll/dynamodb-mapper/dynamodb-mapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if (project.NATIVE_ENABLED) {
// Start by invoking the JVM-only KSP configuration
dependencies.kspJvm(project(":hll:dynamodb-mapper:dynamodb-mapper-codegen"))

// Then we need to move the generated source from jvm to common. Gradle lacks a move task so we roll our own!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, that's a copy but we want to move the files in this case

// Then we need to move the generated source from jvm to common
val moveGenSrc by tasks.registering {
// Can't move src until the src is generated
dependsOn(tasks.named("kspKotlinJvm"))
Expand All @@ -105,6 +105,10 @@ if (project.NATIVE_ENABLED) {
}
}

tasks.named("jvmSourcesJar") {
dependsOn(moveGenSrc)
}

tasks.withType<KotlinCompilationTask<*>> {
if (this !is KspTaskJvm) {
// Ensure that any **non-KSP** compile tasks depend on the generated src move
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

val sdkVersion: String by project

plugins {
id("aws.sdk.kotlin.hll.dynamodbmapper.schema.generator") version "1.3.17-SNAPSHOT"
}

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":hll:dynamodb-mapper:dynamodb-mapper"))
implementation(project(":hll:dynamodb-mapper:dynamodb-mapper-annotations"))
implementation(project(":hll:dynamodb-mapper:dynamodb-mapper-schema-generator-plugin"))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.tests.plugins

import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbItem
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbPartitionKey

@DynamoDbItem
public data class Group(
@DynamoDbPartitionKey val name: String,
val userIds: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.tests.plugins

import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbAttribute
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbItem
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbPartitionKey

@DynamoDbItem
public data class User(
@DynamoDbPartitionKey val id: Int,
@DynamoDbAttribute("fName") val givenName: String,
@DynamoDbAttribute("lName") val surname: String,
val age: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.tests.plugins

import aws.sdk.kotlin.hll.dynamodbmapper.model.itemOf
import aws.sdk.kotlin.hll.dynamodbmapper.tests.plugins.mapper.schemas.UserConverter
import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import kotlin.test.Test
import kotlin.test.assertEquals

class UserTest {
@Test
fun testConversion() {
val user = User(123, "Steve", "Rogers", 84)
val converted = UserConverter.toItem(user)

assertEquals(
itemOf(
"id" to AttributeValue.N("123"),
"fName" to AttributeValue.S("Steve"),
"lName" to AttributeValue.S("Rogers"),
"age" to AttributeValue.N("84"),
),
converted,
)

val unconverted = UserConverter.fromItem(converted)

assertEquals(user, unconverted)
}
}
Loading