-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: various issues found during testing #1450
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...-mapper/dynamodb-mapper-schema-generator-plugin/src/test/resources/RenamedPartitionKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.example | ||
|
||
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 RenamedPartitionKey( | ||
@DynamoDbPartitionKey | ||
@DynamoDbAttribute("user_id") | ||
var id: Int, | ||
|
||
@DynamoDbAttribute("fName") var givenName: String, | ||
@DynamoDbAttribute("lName") var surname: String, | ||
var age: Int, | ||
) |
35 changes: 35 additions & 0 deletions
35
...r-schema-generator-plugin/src/test/resources/standard-item-converters/src/NullableItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.example | ||
|
||
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbItem | ||
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbPartitionKey | ||
import aws.smithy.kotlin.runtime.time.Instant | ||
|
||
@DynamoDbItem | ||
public data class NullableItem( | ||
@DynamoDbPartitionKey var id: Int, | ||
|
||
/** | ||
* A selection of nullable types | ||
*/ | ||
var string: String?, | ||
var byte: Byte?, | ||
var int: Int?, | ||
var instant: Instant?, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other !is NullableItem) return false | ||
|
||
if (id != other.id) return false | ||
if (string != other.string) return false | ||
if (byte != other.byte) return false | ||
if (int != other.int) return false | ||
if (instant?.epochSeconds != other.instant?.epochSeconds) return false | ||
|
||
return true | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ema-generator-plugin/src/test/resources/standard-item-converters/test/NullableItemTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.example | ||
|
||
import aws.smithy.kotlin.runtime.ExperimentalApi | ||
import aws.smithy.kotlin.runtime.time.Instant | ||
import org.example.dynamodbmapper.generatedschemas.NullableItemConverter | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
@OptIn(ExperimentalApi::class) | ||
public class NullableItemTest { | ||
@Test | ||
fun converterTest() { | ||
val nullable = NullableItem( | ||
id = 1, | ||
string = null, | ||
byte = null, | ||
int = 5, | ||
instant = Instant.now(), | ||
) | ||
|
||
val item = NullableItemConverter.convertTo(nullable) | ||
val converted = NullableItemConverter.convertFrom(item) | ||
assertEquals(nullable, converted) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why is a custom
equals
method necessary in this data class?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think it is necessary, I copied it from a different test class which had an
override equals
for byte arrays / other collection types.Can remove in a follow-on PR