001// Generated by delombok at Sun Jul 30 17:21:56 UTC 2023
002package de.cuioss.test.jsf.junit5;
003
004import java.util.List;
005import java.util.SortedSet;
006import org.junit.jupiter.api.BeforeEach;
007import de.cuioss.test.generator.TypedGenerator;
008import de.cuioss.test.generator.junit.EnableGeneratorController;
009import de.cuioss.test.valueobjects.ValueObjectTest;
010import de.cuioss.test.valueobjects.api.property.PropertyConfig;
011import de.cuioss.test.valueobjects.api.property.PropertyConfigs;
012import de.cuioss.test.valueobjects.generator.TypedGeneratorRegistry;
013import de.cuioss.test.valueobjects.junit5.EnableGeneratorRegistry;
014import de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler;
015import de.cuioss.test.valueobjects.property.PropertyMetadata;
016import de.cuioss.test.valueobjects.util.GeneratorRegistry;
017import de.cuioss.test.valueobjects.util.ReflectionHelper;
018import de.cuioss.tools.reflect.MoreReflection;
019
020/**
021 * Extension to {@link JsfEnabledTestEnvironment} that is capable of dealing
022 * with properties and generator like {@link ValueObjectTest}.
023 * <h3>Supported Contracts / Configurations</h3>
024 * <ul>
025 * <li>Faces Mock configuration as defined within
026 * {@link EnableJsfEnvironment}</li>
027 * <li>Handling of Property Generators using annotations, see
028 * {@link de.cuioss.test.valueobjects.api.generator}</li>
029 * <li>Reflection and annotation based property handling, see
030 * {@link de.cuioss.test.valueobjects.api.property}</li>
031 * <li>EnableGeneratorController</li>
032 * </ul>
033 * <p>
034 * In case the actual test-class implements {@link TypedGenerator} itself it
035 * will implicitly registered as {@link TypedGenerator} at
036 * {@link TypedGeneratorRegistry}
037 * </p>
038 *
039 * @author Oliver Wolff
040 * @param <T> identifying the concrete type to be tested
041 */
042@EnableGeneratorController
043@EnableGeneratorRegistry
044public abstract class AbstractPropertyAwareFacesTest<T> extends JsfEnabledTestEnvironment implements ConfigurationCallBackHandler<T>, GeneratorRegistry {
045    private Class<T> targetBeanClass;
046    private List<PropertyMetadata> propertyMetadata;
047
048    /**
049     * Initializes all contracts, properties and generator
050     */
051    @BeforeEach
052    public void initializeAbstractPropertyAwareFacesTest() {
053        this.targetBeanClass = MoreReflection.extractFirstGenericTypeArgument(getClass());
054        this.propertyMetadata = resolvePropertyMetadata();
055    }
056
057    /**
058     * Resolves the {@link PropertyMetadata} by using reflections and the
059     * annotations {@link PropertyConfig} and / {@link PropertyConfigs} if provided
060     *
061     * @return a {@link SortedSet} of {@link PropertyMetadata} defining the base
062     *         line for the configured attributes
063     */
064    protected List<PropertyMetadata> resolvePropertyMetadata() {
065        return ReflectionHelper.handlePropertyMetadata(getClass(), getTargetBeanClass());
066    }
067
068    @java.lang.SuppressWarnings("all")
069    @lombok.Generated
070    public Class<T> getTargetBeanClass() {
071        return this.targetBeanClass;
072    }
073
074    @java.lang.SuppressWarnings("all")
075    @lombok.Generated
076    public List<PropertyMetadata> getPropertyMetadata() {
077        return this.propertyMetadata;
078    }
079}