Package de.cuioss.test.valueobjects.util
Class AnnotationHelper
java.lang.Object
de.cuioss.test.valueobjects.util.AnnotationHelper
Simple helper class dealing with annotation on the test-base classes.
- Author:
- Oliver Wolff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<PropertyMetadata>
constructorConfigToPropertyMetadata
(VerifyConstructor config, Collection<PropertyMetadata> givenMetadata) Creates aList
ofPropertyMetadata
according to the given parameterstatic Set<VerifyConstructor>
extractConfiguredConstructorContracts
(Class<?> annotated) Checks the given type for the annotationVerifyConstructor
andVerifyConstructors
and puts all found in the returnedSet
static Set<VerifyFactoryMethod>
extractConfiguredFactoryContracts
(Class<?> annotated) Checks the given type for the annotationVerifyFactoryMethod
andVerifyFactoryMethods
and puts all found in the returned liststatic List<PropertyMetadata>
factoryConfigToPropertyMetadata
(VerifyFactoryMethod config, Collection<PropertyMetadata> givenMetadata) Creates aList
ofPropertyMetadata
according to the given parameterstatic List<PropertyMetadata>
handleMetadataForBuilderTest
(Class<?> annotated, List<PropertyMetadata> givenMetadata) static List<PropertyMetadata>
handleMetadataForMapperTest
(VerifyMapperConfiguration verifyMapper, List<PropertyMetadata> givenMetadata) static List<PropertyMetadata>
handleMetadataForPropertyTest
(Class<?> annotated, List<PropertyMetadata> givenMetadata) static Map<String,
PropertyMetadata> modifyPropertyMetadata
(Map<String, PropertyMetadata> map, String[] defaultValued, String[] readOnly, String[] required, String[] transientProperties, String[] writeOnly, String[] unorderedCollection) Checks the individual contracts and changes / modifies the correspondingPropertyMetadata
accordinglystatic Map<String,
PropertyMetadata> modifyPropertyMetadata
(Map<String, PropertyMetadata> map, List<String> defaultValued, List<String> readOnly, List<String> required, List<String> transientProperties, List<String> writeOnly, List<String> unorderedCollection) Checks the individual contracts and changes / modifies the correspondingPropertyMetadata
accordingly
-
Constructor Details
-
AnnotationHelper
public AnnotationHelper()
-
-
Method Details
-
constructorConfigToPropertyMetadata
public static List<PropertyMetadata> constructorConfigToPropertyMetadata(VerifyConstructor config, Collection<PropertyMetadata> givenMetadata) Creates aList
ofPropertyMetadata
according to the given parameter- Parameters:
config
- identifying the concrete configurationgivenMetadata
- used fore deriving the concrete metadata. Must not be null- Returns:
- a
List
ofPropertyMetadata
according to the given parameter
-
factoryConfigToPropertyMetadata
public static List<PropertyMetadata> factoryConfigToPropertyMetadata(VerifyFactoryMethod config, Collection<PropertyMetadata> givenMetadata) Creates aList
ofPropertyMetadata
according to the given parameter- Parameters:
config
- identifying the concrete configurationgivenMetadata
- used fore deriving the concrete metadata. Must not be null- Returns:
- a
List
ofPropertyMetadata
according to the given parameter
-
extractConfiguredConstructorContracts
Checks the given type for the annotationVerifyConstructor
andVerifyConstructors
and puts all found in the returnedSet
- Parameters:
annotated
- the class that may or may not provide the annotations, must not be null- Returns:
- a
Set
ofVerifyConstructor
extracted from the annotations of the given type. May be empty but never null
-
extractConfiguredFactoryContracts
Checks the given type for the annotationVerifyFactoryMethod
andVerifyFactoryMethods
and puts all found in the returned list- Parameters:
annotated
- the class that may or may not provide the annotations, must not be null- Returns:
- a Set of
VerifyFactoryMethod
extracted from the annotations of the given type. May be empty but never null
-
handleMetadataForPropertyTest
public static List<PropertyMetadata> handleMetadataForPropertyTest(Class<?> annotated, List<PropertyMetadata> givenMetadata) - Parameters:
annotated
- must not be null and must be annotated withVerifyBeanProperty
givenMetadata
- must not be null- Returns:
- a
SortedSet
providing the property configuration derived by the given properties and the annotatedVerifyBeanProperty
-
handleMetadataForBuilderTest
public static List<PropertyMetadata> handleMetadataForBuilderTest(Class<?> annotated, List<PropertyMetadata> givenMetadata) - Parameters:
annotated
- must not be null and must be annotated withVerifyBeanProperty
givenMetadata
- must not be null- Returns:
- a
SortedSet
providing the property configuration derived by the given properties and the annotatedVerifyBuilder
-
handleMetadataForMapperTest
public static List<PropertyMetadata> handleMetadataForMapperTest(VerifyMapperConfiguration verifyMapper, List<PropertyMetadata> givenMetadata) - Parameters:
verifyMapper
- must not be null and must be annotated withVerifyMapperConfiguration
givenMetadata
- must not be null- Returns:
- a
SortedSet
providing the property configuration derived by the given properties and the annotatedVerifyMapperConfiguration
-
modifyPropertyMetadata
public static Map<String,PropertyMetadata> modifyPropertyMetadata(Map<String, PropertyMetadata> map, String[] defaultValued, String[] readOnly, String[] required, String[] transientProperties, String[] writeOnly, String[] unorderedCollection) Checks the individual contracts and changes / modifies the correspondingPropertyMetadata
accordingly- Parameters:
map
- must not be nulldefaultValued
- must not be nullreadOnly
- must not be nullrequired
- must not be nulltransientProperties
- must not be nullwriteOnly
- must not be nullunorderedCollection
- must not be null, seePropertyReflectionConfig.assertUnorderedCollection()
- Returns:
- the filtered map
-
modifyPropertyMetadata
public static Map<String,PropertyMetadata> modifyPropertyMetadata(Map<String, PropertyMetadata> map, List<String> defaultValued, List<String> readOnly, List<String> required, List<String> transientProperties, List<String> writeOnly, List<String> unorderedCollection) Checks the individual contracts and changes / modifies the correspondingPropertyMetadata
accordingly- Parameters:
map
- must not be nulldefaultValued
- must not be nullreadOnly
- must not be nullrequired
- must not be nulltransientProperties
- must not be nullwriteOnly
- must not be nullunorderedCollection
- must not be null, seePropertyReflectionConfig.assertUnorderedCollection()
- Returns:
- the filtered map
-