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;
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.MapperTest;
025import de.cuioss.test.valueobjects.api.property.PropertyConfig;
026import de.cuioss.test.valueobjects.property.PropertyMetadata;
027import de.cuioss.test.valueobjects.property.util.AssertionStrategy;
028import de.cuioss.tools.property.PropertyReadWrite;
029
030/**
031 * To be used in conjunction with {@link MapperTest}. Defines the
032 * mapper-specific definitions that will be tested.
033 *
034 * @author Oliver Wolff
035 */
036@Retention(RetentionPolicy.RUNTIME)
037@Target({ ElementType.TYPE })
038public @interface VerifyMapperConfiguration {
039
040    /**
041     * @return identifies the properties that can be asserted using
042     *         {@link Object#equals(Object)}. The format is
043     *         'source.attributeName:target.attributeName'. The target.attributeName
044     *         and source.attributeName must refer to an already defined
045     *         {@link PropertyMetadata}. Sample:
046     *         {@code @VerifyMapperConfiguration(equals="name:firstName")} results
047     *         in {@code assertEquals(source.getName(),target.getFirstName()}
048     */
049    String[] equals() default {};
050
051    /**
052     * @return identifies the properties that change the target but result in a non
053     *         null element. In case of a {@link Collection} it will additionally
054     *         checked on emptiness The format is
055     *         'source.attributeName:target.attributeName'. The target.attributeName
056     *         and source.attributeName must refer to an already existing
057     *         {@link PropertyMetadata}. Sample:
058     *         {@code @VerifyMapperConfiguration(notNullNorEmpty="name:lastName")}
059     *         results in the attribute {@code target.getLastName()} being not null
060     */
061    String[] notNullNorEmpty() default {};
062
063    /**
064     * @return an array of properties, identified by their names that are not to be
065     *         considered for this test: black-list
066     */
067    String[] exclude() default {};
068
069    /**
070     * @return an array of properties, identified by their names that are to be
071     *         considered for this test: white-list
072     */
073    String[] of() default {};
074
075    /**
076     * @return an array of properties, identified by their names that are to be
077     *         treated as required properties, see
078     *         {@link PropertyMetadata#isRequired()}
079     */
080    String[] required() default {};
081
082    /**
083     * @return an array of properties, identified by their names that are to be
084     *         treated as having a default values, see
085     *         {@link PropertyMetadata#isDefaultValue()}
086     */
087    String[] defaultValued() default {};
088
089    /**
090     * @return an array of properties, identified by their names that are to be
091     *         treated as being read-only, see {@link PropertyReadWrite#READ_ONLY},
092     *         usually used in conjunction with {@link #defaultValued()}
093     */
094    String[] readOnly() default {};
095
096    /**
097     * @return an array of properties, identified by their names that are to be
098     *         treated as being write-only, see
099     *         {@link PropertyReadWrite#WRITE_ONLY}, usually used in cases where a
100     *         property to be written will result in other properties but itself can
101     *         not be accessed directly
102     */
103    String[] writeOnly() default {};
104
105    /**
106     * @return an array of properties, identified by their names representing at
107     *         least a {@link Collection} that are to be asserted ignoring the
108     *         concrete order, see {@link PropertyConfig#assertionStrategy()} and
109     *         {@link AssertionStrategy#COLLECTION_IGNORE_ORDER}. The default
110     *         implementation will always respect / assert the same order of
111     *         elements.
112     */
113    String[] assertUnorderedCollection() default {};
114
115}