Class BuilderContractImpl<T>
java.lang.Object
de.cuioss.test.valueobjects.contract.BuilderContractImpl<T>
- Type Parameters:
T
- identifying the type of objects to be tested
- All Implemented Interfaces:
TestContract<T>
Defines basic tests for builder. In essence it will try to create a builder
with a minimal set (required only) and one with all properties set. It sets
the properties, build the actual object and verifies whether the properties
are set correctly
- Author:
- Oliver Wolff
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBuilderContractImpl
(BuilderInstantiator<T> instantiator, RuntimeProperties runtimeProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks the concrete contract.static final <T> Optional<BuilderContractImpl<T>>
createBuilderTestContract
(Class<T> beanType, Class<?> annotated, List<PropertyMetadata> initialPropertyMetadata) Factory method for creating an instance ofBuilderContractImpl
depending on the given parameter
-
Field Details
-
DEFAULT_BUILD_METHOD_NAME
The usually chosen name for the actual build method.- See Also:
-
DEFAULT_BUILDER_FACTORY_METHOD_NAME
The usually chosen name for a factory builder method.- See Also:
-
-
Constructor Details
-
BuilderContractImpl
public BuilderContractImpl(BuilderInstantiator<T> instantiator, RuntimeProperties runtimeProperties) - Parameters:
instantiator
- must not be nullruntimeProperties
- must not be null
-
-
Method Details
-
assertContract
Description copied from interface:TestContract
Checks the concrete contract.- Specified by:
assertContract
in interfaceTestContract<T>
-
getInstantiator
- Specified by:
getInstantiator
in interfaceTestContract<T>
- Returns:
- the underlying
ParameterizedInstantiator
-
createBuilderTestContract
public static final <T> Optional<BuilderContractImpl<T>> createBuilderTestContract(Class<T> beanType, Class<?> annotated, List<PropertyMetadata> initialPropertyMetadata) Factory method for creating an instance ofBuilderContractImpl
depending on the given parameter- Parameters:
beanType
- identifying the type to be tested. Must not be nullannotated
- the annotated unit-test-class. It is expected to be annotated withVerifyBuilder
, otherwise the method will returnOptional.empty()
initialPropertyMetadata
- identifying the complete set ofPropertyMetadata
, where the actualPropertyMetadata
for the bean tests will be filtered by using the attributes defined withinVerifyBuilder
. Must not be null.- Returns:
- an instance Of
BeanPropertyContractImpl
in case all requirements for the parameters are correct, otherwise it will returnOptional.empty()
-