001/*
002 * Copyright 2023 the original author or authors.
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * https://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.cuioss.test.valueobjects.api.contracts;
017
018import java.lang.annotation.ElementType;
019import java.lang.annotation.Retention;
020import java.lang.annotation.RetentionPolicy;
021import java.lang.annotation.Target;
022import java.util.Collection;
023
024import de.cuioss.test.valueobjects.api.property.PropertyConfig;
025import de.cuioss.test.valueobjects.property.PropertyMetadata;
026import de.cuioss.test.valueobjects.property.util.AssertionStrategy;
027import de.cuioss.tools.property.PropertyMemberInfo;
028import de.cuioss.tools.property.PropertyReadWrite;
029
030/**
031 * If used on ValueObjectTest this test checks / tests all Bean-properties.
032 * <p>
033 * <em>Caution:</em> The implementation for this contract assumes a valid bean
034 * regarding Java-Bean Spec, therefore a no-args public constructor is required.
035 * </p>
036 * <p>
037 * In essence it checks the getters and setters. As default it assumes the
038 * individual properties to not provide a default value. This can be controlled
039 * using {@link #defaultValued()}
040 * </p>
041 *
042 * @author Oliver Wolff
043 */
044@Retention(RetentionPolicy.RUNTIME)
045@Target({ ElementType.TYPE })
046public @interface VerifyBeanProperty {
047
048    /**
049     * @return an array of properties, identified by their names that are not to be
050     *         considered for this test: black-list
051     */
052    String[] exclude() default {};
053
054    /**
055     * @return an array of properties, identified by their names that are to be
056     *         considered for this test: white-list
057     */
058    String[] of() default {};
059
060    /**
061     * @return an array of properties, identified by their names that are to be
062     *         treated as required properties, see
063     *         {@link PropertyMetadata#isRequired()}
064     */
065    String[] required() default {};
066
067    /**
068     * @return an array of properties, identified by their names that are to be
069     *         treated as transient properties, see
070     *         {@link PropertyMemberInfo#TRANSIENT}
071     */
072    String[] transientProperties() default {};
073
074    /**
075     * @return an array of properties, identified by their names that are to be
076     *         treated as having a default values, see
077     *         {@link PropertyMetadata#isDefaultValue()}
078     */
079    String[] defaultValued() default {};
080
081    /**
082     * @return an array of properties, identified by their names that are to be
083     *         treated as being read-only, see {@link PropertyReadWrite#READ_ONLY},
084     *         usually used in conjunction with {@link #defaultValued()}
085     */
086    String[] readOnly() default {};
087
088    /**
089     * @return an array of properties, identified by their names that are to be
090     *         treated as being write-only, see
091     *         {@link PropertyReadWrite#WRITE_ONLY}, usually used in cases where a
092     *         property to be written will result in other properties but itself can
093     *         not be accessed directly
094     */
095    String[] writeOnly() default {};
096
097    /**
098     * @return an array of properties, identified by their names representing at
099     *         least a {@link Collection} that are to be asserted ignoring the
100     *         concrete order, see {@link PropertyConfig#assertionStrategy()} and
101     *         {@link AssertionStrategy#COLLECTION_IGNORE_ORDER}. The default
102     *         implementation will always respect / assert the same order of
103     *         elements.
104     */
105    String[] assertUnorderedCollection() default {};
106}