Class AssertConfiguration<S,​D>

  • Type Parameters:
    S - The type of the source objects
    D - The type of the destination objects.

    public class AssertConfiguration<S,​D>
    extends Object
    Creates a test for a Mapper object to assert the mapping specification. The expected mapping is to be configured on this object. The method ensure() 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 against null and sample values. It is expected that those test invocations do not throw an exception.
    Author:
    schuettec
    • 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 ReassignAssertBuilder for 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 ReplaceAssertBuilder for 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 SetAssertBuilder for 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 RestructureAssertBuilder for 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 AssertConfiguration for 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 using MappingConfiguration.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 using MappingConfiguration.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 AssertConfiguration for further configuration.
      • expectOtherSourceFieldsToBeOmitted

        public AssertConfiguration<S,​D> expectOtherSourceFieldsToBeOmitted()
        Expects all other source fields to be omitted.
        Returns:
        Returns a AssertConfiguration for further configuration.
      • expectOtherDestinationFieldsToBeOmitted

        public AssertConfiguration<S,​D> expectOtherDestinationFieldsToBeOmitted()
        Expects all other destination fields to be omitted.
        Returns:
        Returns a AssertConfiguration for further configuration.
      • ensure

        public void ensure()
                    throws AssertionError
        Performs the specified assertions against the specified mapper instance. If a replace operation was specified with a transformation function to be also called for null values a null check is performed against the function.
        Throws:
        AssertionError - Thrown if an assertion made about the Mapper object failed.