You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the @SerdeImport on a test class should enable the serialization of a class annotated with @MappedEntity the same way as if the entity was annotated with @Serdable.
Actual Behaviour
@SerdeImport has seemingly no effect and trying to serialize the entity during a test causes an IntrospectionException.
This only affects tests. @SerdeImport works as expected when used in the actual application code.
Caused by: io.micronaut.core.beans.exceptions.IntrospectionException: No serializable introspection present for type Foo. Consider adding Serdeable. Serializable annotate to type Foo. Alternatively if you are not in control of the project's source code, you can use @SerdeImport(Foo.class) to enable serialization of this type.
at io.micronaut.serde.support.DefaultSerdeIntrospections.getSerializableIntrospection(DefaultSerdeIntrospections.java:111)
at io.micronaut.serde.support.serializers.SerBean.<init>(SerBean.java:117)
at io.micronaut.serde.support.serializers.ObjectSerializer.lambda$getSerializableBean$0(ObjectSerializer.java:165)
at io.micronaut.core.util.SupplierUtil$2.get(SupplierUtil.java:79)
at io.micronaut.serde.support.serializers.ObjectSerializer.getSerializableBean(ObjectSerializer.java:170)
at io.micronaut.serde.support.serializers.ObjectSerializer.createSpecificInternal(ObjectSerializer.java:107)
at io.micronaut.serde.support.serializers.ObjectSerializer.createSpecific(ObjectSerializer.java:99)
at io.micronaut.serde.jackson.JacksonJsonMapper.writeValue(JacksonJsonMapper.java:227)
Steps To Reproduce
Create class annotated with @MappedEntity in the applications source main folder
@MappedEntity
data classFoo(
valid:Long,
valname:String,
)
Run test that using @SerdeImport for the created class and attempt to serialize it.
@MicronautTest
@SerdeImport(Foo::class)
class FooTest(
private val jsonMapper: JsonMapper,
) : ShouldSpec({
should("be able to serialize") {
shouldNotThrow<SerdeException> {
jsonMapper.writeValueAsString(Foo(1, "bar"))
}
}
})
When either removing @MappedEntity or adding @Serdable the test runs successful.
Environment Information
Kotlin Version: 1.9.25
Java Version: 21
Kotest Version: 5
Example Application
No response
Version
4.6.3
The text was updated successfully, but these errors were encountered:
Expected Behavior
Using the
@SerdeImport
on a test class should enable the serialization of a class annotated with@MappedEntity
the same way as if the entity was annotated with@Serdable
.Actual Behaviour
@SerdeImport
has seemingly no effect and trying to serialize the entity during a test causes anIntrospectionException
.This only affects tests.
@SerdeImport
works as expected when used in the actual application code.Steps To Reproduce
@MappedEntity
in the applications source main folder@SerdeImport
for the created class and attempt to serialize it.When either removing
@MappedEntity
or adding@Serdable
the test runs successful.Environment Information
Example Application
No response
Version
4.6.3
The text was updated successfully, but these errors were encountered: