|
| 1 | +package io.micronaut.serde.jackson.mixin |
| 2 | + |
| 3 | + |
| 4 | +import io.micronaut.annotation.processing.test.AbstractTypeElementSpec |
| 5 | +import spock.lang.PendingFeature |
| 6 | + |
| 7 | +class SerdeImportMixinIntrospectionSpec extends AbstractTypeElementSpec { |
| 8 | + |
| 9 | + void "test import field introspection"() { |
| 10 | + when: |
| 11 | + def introspection = buildBeanIntrospection('test.$io_micronaut_serde_jackson_mixin_MuxedEvent', ''' |
| 12 | +package test; |
| 13 | +
|
| 14 | +import io.micronaut.core.annotation.Introspected; |
| 15 | +import io.micronaut.serde.annotation.SerdeImport; |
| 16 | +import java.util.*; |
| 17 | +import java.lang.annotation.*; |
| 18 | +import static java.lang.annotation.ElementType.*; |
| 19 | +
|
| 20 | +@Introspected(accessKind = Introspected.AccessKind.FIELD, visibility = Introspected.Visibility.ANY) |
| 21 | +class MuxedEventMixin { |
| 22 | +} |
| 23 | +
|
| 24 | +@SerdeImport(mixin = MuxedEventMixin.class, value = io.micronaut.serde.jackson.mixin.MuxedEvent.class) |
| 25 | +class Test { |
| 26 | +} |
| 27 | +
|
| 28 | +
|
| 29 | + ''') |
| 30 | + |
| 31 | + then: |
| 32 | + introspection != null |
| 33 | + introspection.getBeanType().getName() == "io.micronaut.serde.jackson.mixin.MuxedEvent" |
| 34 | + introspection.getBeanProperties().size() == 2 |
| 35 | + introspection.getBeanProperties().collect { it.name } == ['compartment', "content"] |
| 36 | + } |
| 37 | + |
| 38 | + @PendingFeature(reason = "includedAnnotations is not used in PropertyQuery") |
| 39 | + void "test import field introspection 2"() { |
| 40 | + when: |
| 41 | + def introspection = buildBeanIntrospection('test.$io_micronaut_serde_jackson_mixin_MuxedEvent2', ''' |
| 42 | +package test; |
| 43 | +
|
| 44 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 45 | +import io.micronaut.core.annotation.Introspected; |
| 46 | +import io.micronaut.serde.annotation.SerdeImport; |
| 47 | +import java.util.*; |
| 48 | +import java.lang.annotation.*; |
| 49 | +import static java.lang.annotation.ElementType.*; |
| 50 | +
|
| 51 | +@Introspected(accessKind = Introspected.AccessKind.FIELD, visibility = Introspected.Visibility.ANY, includedAnnotations = JsonProperty.class) |
| 52 | +class MuxedEventMixin { |
| 53 | +} |
| 54 | +
|
| 55 | +@SerdeImport(mixin = MuxedEventMixin.class, value = io.micronaut.serde.jackson.mixin.MuxedEvent2.class) |
| 56 | +class Test { |
| 57 | +} |
| 58 | +
|
| 59 | +
|
| 60 | + ''') |
| 61 | + |
| 62 | + then: |
| 63 | + introspection != null |
| 64 | + introspection.getBeanType().getName() == "io.micronaut.serde.jackson.mixin.MuxedEvent2" |
| 65 | + introspection.getBeanProperties().size() == 2 |
| 66 | + introspection.getBeanProperties().collect { it.name } == ['compartment', "content"] |
| 67 | + } |
| 68 | +} |
| 69 | + |
0 commit comments