Test Micronaut POJOs are annotated with @Introspected

I always annotate my model classes with @Introspected. It is easy to test you don't forget the annotation.

Given a POJO:

import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.NonNull;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;

@Introspected
public class EuroExchangeResponse {

    @NonNull
    @NotNull
    private BigDecimal rate;

    @NonNull
    @NotNull
    private Currency target;

    @NonNull
    @NotNull
    private LocalDate date;

    public EuroExchangeResponse(@NonNull BigDecimal rate,
                                @NonNull Currency target,
                                @NonNull LocalDate date) {
        this.rate = rate;
        this.target = target;
        this.date = date;
    }

    // Getters & Setters
}

I write a Spock specification to verify that no exception is thrown when I attempt to retrieve the Bean Introspection:

import io.micronaut.core.beans.BeanIntrospection
import spock.lang.Specification

class EuroExchangeResponseSpec extends Specification {

    void "EuroExchangeResponse is annotated with @Introspected"() {
        when:
        BeanIntrospection.getIntrospection(EuroExchangeResponse)

        then:
        noExceptionThrown()
    }
}

My next events:
๐Ÿ—“ May 27 09:00 AWS Dublin - Micronaut and AWS Lambda
๐Ÿ—“ Jul 20 09:00 Workshop Security in the Micronaut Framework
๐Ÿ—“ Sep 20 09:00 JCON Online 2022 - Getting Started with the Micronaut Framework
๐Ÿ—“ Sep 23 09:00 JCON Online 2022 - Micronautยฎ Framework and Microstream Java-native persistence engine

Tags: #micronaut #spock #test
May 2021, 17.