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

org.jdesktop.test.matchers.Matchers Maven / Gradle / Ivy

Go to download

Code and classes to support testing SwingX. Classes contained in this module are for internal SwingX use only.

There is a newer version: 1.6.5-1
Show newest version
package org.jdesktop.test.matchers;

import static org.hamcrest.CoreMatchers.any;

import java.beans.PropertyChangeEvent;

import org.hamcrest.Matcher;

/**
 * A collection of matchers useful for testing.
 * 
 * @author kschaefer
 */
public final class Matchers {
    /**
     * A matcher for any property change.
     * 
     * @return {@code true} if any property can be matched; {@code false} otherwise
     */
    public static Matcher anyProperty() {
        return any(PropertyChangeEvent.class);
    }

    /**
     * A matcher for a specified property.
     * 
     * @param propertyName
     *            the name of the property to match
     * @return {@code true} if the property exists and has a name that matches the specified name;
     *         {@code false} otherwise
     */
    public static Matcher propertyWithName(String propertyName) {
        return new PropertyChangeEventMatcher(propertyName, null, null);
    }

    /**
     * A matcher for a specified property.
     * 
     * @param propertyName
     *            the name of the property to match
     * @param oldValue
     *            the old property value
     * @param newValue
     *            the new property value
     * @return {@code true} if the property exists and all parameters match the specified values;
     *         {@code false} otherwise
     */
    public static Matcher property(String propertyName, Object oldValue, Object newValue) {
        return new PropertyChangeEventMatcher(propertyName, oldValue, newValue);
    }

    /**
     * This matcher returns {@code true} when the arguments are equivalent.
     * 

* For purposes of this matcher equivalence is as follows: *

    *
  1. the objects are equal
  2. *
  3. the objects contain the same contents, insofar as the {@link java.beans.BeanInfo class * info} for each object instance returns equivalent values
  4. *
* * @param * the type of the matcher * @param object * the object to test * @return {@code true} if the object is equivalent; {@code false} otherwise */ public static Matcher equivalentTo(T object) { return new EquivalentMatcher(object); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy