generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ignoring constructor/record parameter (#809)
- Loading branch information
Showing
5 changed files
with
228 additions
and
10 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...mples/example-kotlin/src/test/kotlin/example/SerdeableWithIgnoredNonSerdeableFieldTest.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,27 @@ | ||
package example | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import io.micronaut.serde.ObjectMapper | ||
import io.micronaut.serde.annotation.Serdeable | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest | ||
import org.junit.jupiter.api.Test | ||
|
||
@MicronautTest | ||
class SerdeableWithIgnoredNonSerdeableFieldTest { | ||
|
||
@Test | ||
fun test(objectMapper: ObjectMapper) { | ||
val original = SerdeableWithIgnoredNonSerdeable(NonSerdeable("value")) | ||
|
||
val serialized = objectMapper.writeValueAsString(original) | ||
val deserialized = objectMapper.readValue(serialized, SerdeableWithIgnoredNonSerdeable::class.java) | ||
|
||
assert(deserialized == original.copy(ignoredNonSerdeable = null)) | ||
} | ||
|
||
} | ||
|
||
@Serdeable | ||
data class SerdeableWithIgnoredNonSerdeable(@field:JsonIgnore val ignoredNonSerdeable: NonSerdeable? = null) | ||
|
||
data class NonSerdeable(val value: String) |
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
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