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;

public class EuroExchangeResponse {

    private BigDecimal rate;

    private Currency target;

    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"() {


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


My next events:
🗓 Oct 05 17:00 Jumpstart your Java applications with AWS Lambda and Micronaut