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.Repeatable; 020import java.lang.annotation.Retention; 021import java.lang.annotation.RetentionPolicy; 022import java.lang.annotation.Target; 023import java.util.Collection; 024 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.PropertyMemberInfo; 029import de.cuioss.tools.property.PropertyReadWrite; 030 031/** 032 * If used on ValueObjectTest this test checks / tests constructors. 033 * <p> 034 * In order to define the constructor-args in the correct order you need to pass 035 * them using {@link #of()} 036 * </p> 037 * <p> 038 * As default it assumes the individual arguments to be optional, saying null is 039 * allowed. This can be controlled by {@link #required()} 040 * </p> 041 * 042 * @author Oliver Wolff 043 */ 044@Retention(RetentionPolicy.RUNTIME) 045@Target({ ElementType.TYPE }) 046@Repeatable(VerifyConstructors.class) 047public @interface VerifyConstructor { 048 049 /** 050 * @return an array of properties, identified by their names that are to be 051 * considered for this test: Caution: The order of the names must 052 * exactly match the order of the attributes of corresponding 053 * constructor. 054 */ 055 String[] of(); 056 057 /** 058 * @return an array of properties, identified by their names that are to be 059 * treated as required properties, see 060 * {@link PropertyMetadata#isRequired()}. it is used 061 */ 062 String[] required() default {}; 063 064 /** 065 * @return boolean indicating whether all attribute defined at {@link #of()} are 066 * to be treated as required attributes. Defaults to {@code false} 067 */ 068 boolean allRequired() default false; 069 070 /** 071 * @return an array of properties, identified by their names that are to be 072 * treated as transient properties, see 073 * {@link PropertyMemberInfo#TRANSIENT} 074 */ 075 String[] transientProperties() default {}; 076 077 /** 078 * @return an array of properties, identified by their names that are to be 079 * treated as having a default values, see 080 * {@link PropertyMetadata#isDefaultValue()} 081 */ 082 String[] defaultValued() default {}; 083 084 /** 085 * @return an array of properties, identified by their names that are to be 086 * treated as being read-only, see {@link PropertyReadWrite#READ_ONLY}, 087 * usually used in conjunction with {@link #defaultValued()} 088 */ 089 String[] readOnly() default {}; 090 091 /** 092 * @return an array of properties, identified by their names that are to be 093 * treated as being write-only, see 094 * {@link PropertyReadWrite#WRITE_ONLY}, usually used in cases where a 095 * property to be written will result in other properties but itself can 096 * not be accessed directly 097 */ 098 String[] writeOnly() default {}; 099 100 /** 101 * @return an array of properties, identified by their names representing at 102 * least a {@link Collection} that are to be asserted ignoring the 103 * concrete order, see {@link PropertyConfig#assertionStrategy()} and 104 * {@link AssertionStrategy#COLLECTION_IGNORE_ORDER}. The default 105 * implementation will always respect / assert the same order of 106 * elements. 107 */ 108 String[] assertUnorderedCollection() default {}; 109}