@@ -0,0 +1,3071 @@
+package io.quarkus.hibernate.orm;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.lang.annotation.ElementType;%0Aimport java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPolicy;%0Aimport java.lang.annotation.Target;%0Aimport java.net.URL;%0Aimport java.util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0Aimport org.hibernate.Hibernate;%0Aimport org.jboss.jandex.AnnotationInstance;%0Aimport org.jboss.jandex.ClassInfo;%0Aimport org.jboss.jandex.DotName;%0Aimport org.jboss.jandex.Index;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport io.quarkus.deployment.index.IndexingUtil;%0Aimport io.quarkus.hibernate.orm.deployment.HibernateOrmAnnotations;%0A%0A/**%0A * Test that hardcoded lists of Hibernate ORM annotations stay up-to-date.%0A */%0Apublic class HibernateOrmAnnotationsTest %7B%0A%0A    private static final DotName RETENTION = DotName.createSimple(Retention.class.getName());%0A    private static final DotName TARGET = DotName.createSimple(Target.class.getName());%0A%0A    @Test%0A    public void testNoMissingPackageLevelAnnotation() throws IOException %7B%0A        Index index = indexHibernateJar();%0A%0A        Set%3CDotName%3E packageLevelHibernateAnnotations = findRuntimeAnnotationsByTargetType(index, ElementType.PACKAGE);%0A        packageLevelHibernateAnnotations.removeIf(name -%3E name.toString().contains(%22.internal.%22));%0A%0A        assertThat(HibernateOrmAnnotations.PACKAGE_ANNOTATIONS)%0A                .containsExactlyInAnyOrderElementsOf(packageLevelHibernateAnnotations);%0A    %7D%0A%0A    private Set%3CDotName%3E findRuntimeAnnotationsByTargetType(Index index, ElementType targetType) %7B%0A        Set%3CDotName%3E annotations = new HashSet%3C%3E();%0A        for (AnnotationInstance retentionAnnotation : index.getAnnotations(RETENTION)) %7B%0A            ClassInfo annotation = retentionAnnotation.target().asClass();%0A            if (RetentionPolicy.RUNTIME.name().equals(retentionAnnotation.value().asEnum())%0A                    && allowsTargetType(annotation, targetType)) %7B%0A                annotations.add(annotation.name());%0A            %7D%0A        %7D%0A        return annotations;%0A    %7D%0A%0A    private boolean allowsTargetType(ClassInfo annotation, ElementType targetType) %7B%0A        AnnotationInstance targetAnnotation = annotation.classAnnotation(TARGET);%0A        if (targetAnnotation == null) %7B%0A            // Can target anything%0A            return true;%0A        %7D%0A%0A        List%3CString%3E allowedTargetTypes = Arrays.asList(targetAnnotation.value().asEnumArray());%0A        return allowedTargetTypes.contains(targetType.name());%0A    %7D%0A%0A    private Index indexHibernateJar() throws IOException %7B%0A        return IndexingUtil.indexJar(determineHibernateJarLocation());%0A    %7D%0A%0A    private File determineHibernateJarLocation() %7B%0A        URL url = Hibernate.class.getProtectionDomain().getCodeSource().getLocation();%0A        if (!url.getProtocol().equals(%22file%22)) %7B%0A            throw new IllegalStateException(%22Hibernate JAR is not a local file? %22 + url);%0A        %7D%0A        return new File(url.getPath());%0A    %7D%0A%7D%0A

Test that hardcoded lists of Hibernate ORM annotations stay up-to-date