Skip to content

Commit

Permalink
Reintroduce dynamodb kotlin (#244)
Browse files Browse the repository at this point in the history
* Reintroduce DynamoDB v2 Kotlin DSL

* using latest Micronaut

* fixed Kotlin classpath

* migrated imports

* fixed incompatibility with varargs

* updated license
  • Loading branch information
musketyr authored Jul 12, 2024
1 parent 3d9aca7 commit b85327d
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 22 deletions.
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

slug=agorapulse/micronaut-aws-sdk
group=com.agorapulse
micronautVersion = 4.2.0
micronautGradlePluginVersion = 4.2.0
micronautVersion = 4.5.0
micronautGradlePluginVersion = 4.4.0
gruVersion = 2.0.5
awsSdkVersion = 1.12.692
awsSdk2Version = 2.25.22
Expand All @@ -32,6 +32,7 @@ nexusPluginVersion=1.0.0
closureSupportVersion=0.6.3
mockitoVersion=2.23.4
kotlinVersion=1.9.21
kspVersion=1.9.21-1.0.15

# other versions creates conflicts in Groovydoc
groovyVersion = 4.0.16
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jetbrains.kotlin.plugin.allopen:org.jetbrains.kotlin.plugin.allopen.gradle.plugin:$kotlinVersion")
classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kspVersion")
classpath("io.micronaut.gradle:micronaut-minimal-plugin:$micronautGradlePluginVersion")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,9 @@
* limitations under the License.
*/
plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
id 'org.jetbrains.kotlin.plugin.allopen' version "$kotlinVersion"
id 'com.google.devtools.ksp' version '1.9.21-1.0.15'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.plugin.allopen'
id 'com.google.devtools.ksp'
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,14 +17,14 @@
*/
package com.agorapulse.micronaut.amazon.awssdk.dynamodb.kotlin

import io.micronaut.test.annotation.MicronautTest
import io.micronaut.test.extensions.junit5.annotation.MicronautTest
import jakarta.inject.Inject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import reactor.core.publisher.Flux
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.*
import javax.inject.Inject

// tag::header[]
@MicronautTest // <1>
Expand Down Expand Up @@ -56,16 +56,18 @@ class DeclarativeServiceTest {
)
Assertions.assertNotNull(
s.saveAll(
listOf(
createEntity("3", "1", "foo", Date.from(REFERENCE_DATE.plus(7, ChronoUnit.DAYS))),
createEntity("3", "2", "bar", Date.from(REFERENCE_DATE.plus(14, ChronoUnit.DAYS)))
)
)
)
Assertions.assertNotNull(s.get("1", "1"))
Assertions.assertNotNull(s.load("1", "1"))
Assertions.assertEquals(2, s.getAll("1", Arrays.asList("2", "1"))!!.size)
Assertions.assertEquals(2, s.loadAll("1", Arrays.asList("2", "1"))!!.size)
Assertions.assertEquals(2, s.getAll("1", "2", "1")!!.size)
Assertions.assertEquals(0, s.loadAll("1", "3", "4")!!.size)
Assertions.assertEquals(2, s.getAll("1", listOf("2", "1"))!!.size)
Assertions.assertEquals(0, s.loadAll("1", listOf("3", "4"))!!.size)
Assertions.assertEquals(2, s.count("1"))
Assertions.assertEquals(1, s.count("1", "1"))
Assertions.assertEquals(1, s.countByRangeIndex("1", "bar"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2018-2023 Agorapulse.
* Copyright 2018-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,6 @@ interface DynamoDBEntityService {
fun loadAll(hash: String?, rangeKeys: List<String?>?): List<DynamoDBEntity?>?
fun loadAll(hash: String?, vararg rangeKeys: String?): List<DynamoDBEntity?>?
fun save(entity: DynamoDBEntity?): DynamoDBEntity?
fun saveAll(vararg entities: DynamoDBEntity?): List<DynamoDBEntity?>?
fun saveAll(entities: Iterable<DynamoDBEntity?>?): List<DynamoDBEntity?>?
fun count(hashKey: String?): Int
fun count(hashKey: String?, rangeKey: String?): Int
Expand Down

0 comments on commit b85327d

Please sign in to comment.