- java.lang.Object
-
- com.remondis.remap.AssertConfiguration<S,D>
-
- Type Parameters:
S- The type of the source objectsD- The type of the destination objects.
public class AssertConfiguration<S,D> extends Object
Creates a test for aMapperobject to assert the mapping specification. The expected mapping is to be configured on this object. The methodensure()then performs the assertions against the actual configured mapping configuration of the specified mapper and performs checks using the specified transformation functions. Transformation functions specified for the `replace` operation are checked againstnulland sample values. It is expected that those test invocations do not throw an exception.- Author:
- schuettec
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidensure()Performs the specified assertions against the specified mapper instance.AssertConfiguration<S,D>expectNoImplicitMappings()Expects the mapper to suppress creation of implicit mappings.AssertConfiguration<S,D>expectOmitInDestination(FieldSelector<D> destinationSelector)Specifies an assertion for a destination field to be omitted.AssertConfiguration<S,D>expectOmitInSource(FieldSelector<S> sourceSelector)Specifies an assertion for a source field to be omitted.AssertConfiguration<S,D>expectOtherDestinationFieldsToBeOmitted()Expects all other destination fields to be omitted.AssertConfiguration<S,D>expectOtherSourceFieldsToBeOmitted()Expects all other source fields to be omitted.AssertConfiguration<S,D>expectOthersToBeOmitted()Expects all other field to be omitted.<RS> ReassignAssertBuilder<S,D,RS>expectReassign(FieldSelector<S> sourceSelector)Specifies an assertion for a reassign operation.<RD,RS>
ReplaceAssertBuilder<S,D,RD,RS>expectReplace(TypedSelector<RS,S> sourceSelector, TypedSelector<RD,D> destinationSelector)Specifies an assertion for a replace operation.<RD,RS>
ReplaceCollectionAssertBuilder<S,D,RD,RS>expectReplaceCollection(TypedSelector<Collection<RS>,S> sourceSelector, TypedSelector<Collection<RD>,D> destinationSelector)Specifies an assertion for a replace operation for collections.<RD> RestructureAssertBuilder<S,D,RD>expectRestructure(TypedSelector<RD,D> destinationSelector)Specifies an assertion for a restructure operation.<RD> SetAssertBuilder<S,D,RD>expectSet(TypedSelector<RD,D> destinationSelector)Specifies an assertion for a set operation.AssertConfiguration<S,D>expectToWriteNullIfSourceIsNull()Expects the mapper to suppress creation of implicit mappings.
-
-
-
Method Detail
-
expectReassign
public <RS> ReassignAssertBuilder<S,D,RS> expectReassign(FieldSelector<S> sourceSelector)
Specifies an assertion for a reassign operation.- Parameters:
sourceSelector- The source field selector.- Returns:
- Returns a
ReassignAssertBuilderfor further configuration.
-
expectReplace
public <RD,RS> ReplaceAssertBuilder<S,D,RD,RS> expectReplace(TypedSelector<RS,S> sourceSelector, TypedSelector<RD,D> destinationSelector)
Specifies an assertion for a replace operation.- Parameters:
sourceSelector- The source field selector.destinationSelector- The destination field selector.- Returns:
- Returns a
ReplaceAssertBuilderfor further configuration.
-
expectSet
public <RD> SetAssertBuilder<S,D,RD> expectSet(TypedSelector<RD,D> destinationSelector)
Specifies an assertion for a set operation.- Parameters:
destinationSelector- The destination field selector.- Returns:
- Returns a
SetAssertBuilderfor further configuration.
-
expectRestructure
public <RD> RestructureAssertBuilder<S,D,RD> expectRestructure(TypedSelector<RD,D> destinationSelector)
Specifies an assertion for a restructure operation.- Parameters:
destinationSelector- The destination field selector.- Returns:
- Returns a
RestructureAssertBuilderfor further configuration.
-
expectReplaceCollection
public <RD,RS> ReplaceCollectionAssertBuilder<S,D,RD,RS> expectReplaceCollection(TypedSelector<Collection<RS>,S> sourceSelector, TypedSelector<Collection<RD>,D> destinationSelector)
Specifies an assertion for a replace operation for collections.- Parameters:
sourceSelector- The source field selector.destinationSelector- The destination field selector.- Returns:
- Returns a
ReplaceCollectionAssertBuilderfor further configuration.
-
expectOmitInSource
public AssertConfiguration<S,D> expectOmitInSource(FieldSelector<S> sourceSelector)
Specifies an assertion for a source field to be omitted.- Parameters:
sourceSelector- The source field selector.- Returns:
- Returns a
AssertConfigurationfor further configuration.
-
expectNoImplicitMappings
public AssertConfiguration<S,D> expectNoImplicitMappings()
Expects the mapper to suppress creation of implicit mappings. Note: This requires the user to define the mappings explicitly usingMappingConfiguration.reassign(FieldSelector)or any other mapping operation. Therefore all this explicit mappings must be backed by an assertion.- Returns:
- Returns this instance for further configuration.
-
expectToWriteNullIfSourceIsNull
public AssertConfiguration<S,D> expectToWriteNullIfSourceIsNull()
Expects the mapper to suppress creation of implicit mappings. Note: This requires the user to define the mappings explicitly usingMappingConfiguration.reassign(FieldSelector)or any other mapping operation. Therefore all this explicit mappings must be backed by an assertion.- Returns:
- Returns this instance for further configuration.
-
expectOmitInDestination
public AssertConfiguration<S,D> expectOmitInDestination(FieldSelector<D> destinationSelector)
Specifies an assertion for a destination field to be omitted.- Parameters:
destinationSelector- The destination field selector.- Returns:
- Returns a
AssertConfigurationfor further configuration.
-
expectOthersToBeOmitted
public AssertConfiguration<S,D> expectOthersToBeOmitted()
Expects all other field to be omitted.- Returns:
- Returns a
AssertConfigurationfor further configuration.
-
expectOtherSourceFieldsToBeOmitted
public AssertConfiguration<S,D> expectOtherSourceFieldsToBeOmitted()
Expects all other source fields to be omitted.- Returns:
- Returns a
AssertConfigurationfor further configuration.
-
expectOtherDestinationFieldsToBeOmitted
public AssertConfiguration<S,D> expectOtherDestinationFieldsToBeOmitted()
Expects all other destination fields to be omitted.- Returns:
- Returns a
AssertConfigurationfor further configuration.
-
ensure
public void ensure() throws AssertionErrorPerforms the specified assertions against the specified mapper instance. If a replace operation was specified with a transformation function to be also called fornullvalues a null check is performed against the function.- Throws:
AssertionError- Thrown if an assertion made about theMapperobject failed.
-
-