All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xmlunit.builder.DifferenceEngineConfigurer Maven / Gradle / Ivy

There is a newer version: 2.10.0
Show newest version
/*
  This file is licensed to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 */
package org.xmlunit.builder;

import java.util.Map;

import org.w3c.dom.Attr;
import org.w3c.dom.Node;
import org.xmlunit.diff.ComparisonController;
import org.xmlunit.diff.ComparisonFormatter;
import org.xmlunit.diff.ComparisonListener;
import org.xmlunit.diff.ComparisonResult;
import org.xmlunit.diff.DifferenceEvaluator;
import org.xmlunit.diff.DifferenceEvaluators;
import org.xmlunit.diff.NodeMatcher;
import org.xmlunit.util.Predicate;

/**
 * Subset of the configuration options available for a {@link DifferenceEngine}.
 * @since 2.6.0
 */
public interface DifferenceEngineConfigurer> {

    /**
     * Sets the strategy for selecting nodes to compare.
     * 

* Example with {@link org.xmlunit.diff.DefaultNodeMatcher}: *

     * .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
     * 
* * @see org.xmlunit.diff.DifferenceEngine#setNodeMatcher(NodeMatcher) */ D withNodeMatcher(NodeMatcher nodeMatcher); /** * Provide your own custom {@link DifferenceEvaluator} implementation. *

This overwrites the Default DifferenceEvaluator.

* *

If you want use your custom DifferenceEvaluator in * combination with the default or another DifferenceEvaluator you * should use {@link * DifferenceEvaluators#chain(DifferenceEvaluator...)} or {@link * DifferenceEvaluators#first(DifferenceEvaluator...)} to combine * them:

* *
     *         .withDifferenceEvaluator(
     *             DifferenceEvaluators.chain(
     *                 DifferenceEvaluators.Default,
     *                 new MyCustomDifferenceEvaluator()))
     *         ....
     * 
*/ D withDifferenceEvaluator(DifferenceEvaluator differenceEvaluator); /** * Replace the {@link ComparisonControllers#Default} with your own ComparisonController. *

* Example use: *

     *      .withComparisonController(ComparisonControllers.StopWhenDifferent)
     * 
*/ D withComparisonController(ComparisonController comparisonController); /** * Registers listeners that are notified of each comparison. * * @see org.xmlunit.diff.DifferenceEngine#addComparisonListener(ComparisonListener) */ D withComparisonListeners(ComparisonListener... comparisonListeners); /** * Registers listeners that are notified of each comparison with * outcome other than {@link ComparisonResult#EQUAL}. * * @see org.xmlunit.diff.DifferenceEngine#addDifferenceListener(ComparisonListener) */ D withDifferenceListeners(ComparisonListener... comparisonListeners); /** * Establish a namespace context that will be used in {@link * org.xmlunit.diff.Comparison.Detail#getXPath Comparison.Detail#getXPath}. * *

Without a namespace context (or with an empty context) the * XPath expressions will only use local names for elements and * attributes.

* * @param prefix2Uri mapping between prefix and namespace URI */ D withNamespaceContext(Map prefix2Uri); /** * Registers a filter for attributes. * *

Only attributes for which the predicate returns true are * part of the comparison. By default all attributes are * considered.

* *

The "special" namespace, namespace-location and * schema-instance-type attributes can not be ignored this way. * If you want to suppress comparison of them you'll need to * implement {@link DifferenceEvaluator}.

*/ D withAttributeFilter(Predicate attributeFilter); /** * Registers a filter for nodes. * *

Only nodes for which the predicate returns true are part of * the comparison. By default nodes that are not document types * are considered.

*/ D withNodeFilter(Predicate nodeFilter); /** * Sets a non-default formatter for the differences found. */ D withComparisonFormatter(ComparisonFormatter formatter); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy