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

br.com.objectos.testing.MoreMatchers Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2013 Objectos, Fábrica de Software LTDA.
 *
 * Licensed 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 br.com.objectos.testing;

import java.io.File;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.EventObject;
import java.util.List;
import java.util.Map;

import javax.xml.namespace.NamespaceContext;

import br.com.objectos.core.testing.Testable;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.collection.IsArray;
import org.hamcrest.core.AnyOf;
import org.hamcrest.core.CombinableMatcher.CombinableBothMatcher;
import org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher;
import org.w3c.dom.Node;

/**
 * @author [email protected] (Marcio Endo)
 */
public class MoreMatchers {

  private MoreMatchers() {
  }

  public static  Matcher equalTo(T operand) {
    return new MatcherEqualTo(operand);
  }

  public static Matcher hasContentsEqualTo(String resourceName) {
    return new MatcherFileContents(resourceName);
  }

  public static > Matcher isEqualTo(T operand) {
    return new MatcherTestable(operand);
  }

  public static > Matcher> isEqualTo(List operand) {
    return new MatcherTestableList(operand);
  }

  public static  MatcherToStringEqualToResource toStringEqualTo(String resourceName) {
    return new MatcherToStringEqualToResource(resourceName);
  }

  //

  public static  Matcher allOf(Iterable> matchers) {
    return Matchers.allOf(matchers);
  }

  public static  Matcher allOf(@SuppressWarnings("unchecked") Matcher... matchers) {
    return Matchers.allOf(matchers);
  }

  public static  Matcher allOf(Matcher first, Matcher second) {
    return Matchers. allOf(first, second);
  }

  public static  Matcher allOf(Matcher first, Matcher second,
      Matcher third) {
    return Matchers. allOf(first, second, third);
  }

  public static  Matcher allOf(Matcher first, Matcher second,
      Matcher third, Matcher fourth) {
    return Matchers. allOf(first, second, third, fourth);
  }

  public static  Matcher allOf(Matcher first, Matcher second,
      Matcher third, Matcher fourth, Matcher fifth) {
    return Matchers. allOf(first, second, third, fourth, fifth);
  }

  public static  Matcher allOf(Matcher first, Matcher second,
      Matcher third, Matcher fourth, Matcher fifth,
      Matcher sixth) {
    return Matchers. allOf(first, second, third, fourth, fifth, sixth);
  }

  public static  AnyOf anyOf(Iterable> matchers) {
    return Matchers.anyOf(matchers);
  }

  public static  AnyOf anyOf(Matcher first, Matcher second,
      Matcher third) {
    return Matchers.anyOf(first, second, third);
  }

  public static  AnyOf anyOf(Matcher first, Matcher second,
      Matcher third,
      Matcher fourth) {
    return Matchers.anyOf(first, second, third, fourth);
  }

  public static  AnyOf anyOf(Matcher first, Matcher second,
      Matcher third,
      Matcher fourth, Matcher fifth) {
    return Matchers.anyOf(first, second, third, fourth, fifth);
  }

  public static  AnyOf anyOf(Matcher first, Matcher second,
      Matcher third,
      Matcher fourth, Matcher fifth, Matcher sixth) {
    return Matchers.anyOf(first, second, third, fourth, fifth, sixth);
  }

  public static  AnyOf anyOf(Matcher first, Matcher second) {
    return Matchers.anyOf(first, second);
  }

  public static  AnyOf anyOf(@SuppressWarnings("unchecked") Matcher... matchers) {
    return Matchers.anyOf(matchers);
  }

  public static  CombinableBothMatcher both(Matcher matcher) {
    return Matchers.both(matcher);
  }

  public static  CombinableEitherMatcher either(Matcher matcher) {
    return Matchers.either(matcher);
  }

  public static  Matcher describedAs(String description, Matcher matcher, Object... values) {
    return Matchers.describedAs(description, matcher, values);
  }

  public static  Matcher> everyItem(Matcher itemMatcher) {
    return Matchers.everyItem(itemMatcher);
  }

  public static Matcher anything() {
    return Matchers.anything();
  }

  public static Matcher anything(String description) {
    return Matchers.anything(description);
  }

  public static  Matcher> hasItem(T item) {
    return Matchers.hasItem(item);
  }

  public static  Matcher> hasItem(Matcher itemMatcher) {
    return Matchers.hasItem(itemMatcher);
  }

  public static  Matcher> hasItems(@SuppressWarnings("unchecked") T... items) {
    return Matchers.hasItems(items);
  }

  public static  Matcher> hasItems(@SuppressWarnings("unchecked") Matcher... itemMatchers) {
    return Matchers.hasItems(itemMatchers);
  }

  public static  Matcher any(Class type) {
    return Matchers.any(type);
  }

  public static Matcher containsString(String substring) {
    return Matchers.containsString(substring);
  }

  public static Matcher endsWith(String suffix) {
    return Matchers.endsWith(suffix);
  }

  public static  IsArray array(@SuppressWarnings("unchecked") Matcher... elementMatchers) {
    return Matchers.array(elementMatchers);
  }

  public static  Matcher hasItemInArray(T element) {
    return Matchers.hasItemInArray(element);
  }

  public static  Matcher hasItemInArray(Matcher elementMatcher) {
    return Matchers.hasItemInArray(elementMatcher);
  }

  public static  Matcher arrayContaining(List> itemMatchers) {
    return Matchers.arrayContaining(itemMatchers);
  }

  public static  Matcher arrayContaining(@SuppressWarnings("unchecked") E... items) {
    return Matchers.arrayContaining(items);
  }

  public static  Matcher arrayContaining(@SuppressWarnings("unchecked") Matcher... itemMatchers) {
    return Matchers.arrayContaining(itemMatchers);
  }

  public static  Matcher arrayContainingInAnyOrder(@SuppressWarnings("unchecked") E... items) {
    return Matchers.arrayContainingInAnyOrder(items);
  }

  public static  Matcher arrayContainingInAnyOrder(
      @SuppressWarnings("unchecked") Matcher... itemMatchers) {
    return Matchers.arrayContainingInAnyOrder(itemMatchers);
  }

  public static  Matcher arrayContainingInAnyOrder(
      Collection> itemMatchers) {
    return Matchers.arrayContainingInAnyOrder(itemMatchers);
  }

  public static  Matcher arrayWithSize(Matcher sizeMatcher) {
    return Matchers.arrayWithSize(sizeMatcher);
  }

  public static  Matcher arrayWithSize(int size) {
    return Matchers.arrayWithSize(size);
  }

  public static  Matcher emptyArray() {
    return Matchers.emptyArray();
  }

  public static  Matcher> hasSize(Matcher sizeMatcher) {
    return Matchers.hasSize(sizeMatcher);
  }

  public static  Matcher> hasSize(int size) {
    return Matchers.hasSize(size);
  }

  public static  Matcher> empty() {
    return Matchers.empty();
  }

  public static  Matcher> emptyCollectionOf(Class type) {
    return Matchers.emptyCollectionOf(type);
  }

  public static  Matcher> emptyIterable() {
    return Matchers.emptyIterable();
  }

  public static  Matcher> emptyIterableOf(Class type) {
    return Matchers.emptyIterableOf(type);
  }

  public static  Matcher> contains(
      @SuppressWarnings("unchecked") Matcher... itemMatchers) {
    return Matchers.contains(itemMatchers);
  }

  public static  Matcher> contains(@SuppressWarnings("unchecked") E... items) {
    return Matchers.contains(items);
  }

  public static  Matcher> contains(Matcher itemMatcher) {
    return Matchers.contains(itemMatcher);
  }

  public static  Matcher> contains(List> itemMatchers) {
    return Matchers.contains(itemMatchers);
  }

  public static  Matcher> containsInAnyOrder(@SuppressWarnings("unchecked") T... items) {
    return Matchers.containsInAnyOrder(items);
  }

  public static  Matcher> containsInAnyOrder(
      Collection> itemMatchers) {
    return Matchers.containsInAnyOrder(itemMatchers);
  }

  public static  Matcher> containsInAnyOrder(
      @SuppressWarnings("unchecked") Matcher... itemMatchers) {
    return Matchers.containsInAnyOrder(itemMatchers);
  }

  public static  Matcher> hasEntry(K key, V value) {
    return Matchers.hasEntry(key, value);
  }

  public static  Matcher> hasEntry(
      Matcher keyMatcher,
      Matcher valueMatcher) {
    return Matchers.hasEntry(keyMatcher, valueMatcher);
  }

  public static  Matcher> hasKey(Matcher keyMatcher) {
    return Matchers.hasKey(keyMatcher);
  }

  public static  Matcher> hasKey(K key) {
    return Matchers.hasKey(key);
  }

  public static  Matcher> hasValue(V value) {
    return Matchers.hasValue(value);
  }

  public static  Matcher> hasValue(Matcher valueMatcher) {
    return Matchers.hasValue(valueMatcher);
  }

  public static Matcher closeTo(double operand, double error) {
    return Matchers.closeTo(operand, error);
  }

  public static Matcher closeTo(BigDecimal operand, BigDecimal error) {
    return Matchers.closeTo(operand, error);
  }

  public static > Matcher comparesEqualTo(T value) {
    return Matchers.comparesEqualTo(value);
  }

  public static > Matcher greaterThan(T value) {
    return Matchers.greaterThan(value);
  }

  public static > Matcher greaterThanOrEqualTo(T value) {
    return Matchers.greaterThanOrEqualTo(value);
  }

  public static Matcher equalToIgnoringCase(String expectedString) {
    return Matchers.equalToIgnoringCase(expectedString);
  }

  public static Matcher equalToIgnoringWhiteSpace(String expectedString) {
    return Matchers.equalToIgnoringWhiteSpace(expectedString);
  }

  public static  Matcher hasToString(Matcher toStringMatcher) {
    return Matchers.hasToString(toStringMatcher);
  }

  public static  Matcher hasToString(String expectedToString) {
    return Matchers.hasToString(expectedToString);
  }

  public static Matcher eventFrom(Class eventClass,
      Object source) {
    return Matchers.eventFrom(eventClass, source);
  }

  public static Matcher eventFrom(Object source) {
    return Matchers.eventFrom(source);
  }

  public static  Matcher hasProperty(String propertyName) {
    return Matchers.hasProperty(propertyName);
  }

  public static  Matcher hasProperty(String propertyName, Matcher valueMatcher) {
    return Matchers.hasProperty(propertyName, valueMatcher);
  }

  public static Matcher hasXPath(String xPath, NamespaceContext namespaceContext) {
    return Matchers.hasXPath(xPath, namespaceContext);
  }

  public static Matcher hasXPath(String xPath) {
    return Matchers.hasXPath(xPath);
  }

  public static Matcher hasXPath(String xPath, NamespaceContext namespaceContext,
      Matcher valueMatcher) {
    return Matchers.hasXPath(xPath, namespaceContext, valueMatcher);
  }

  public static Matcher hasXPath(String xPath, Matcher valueMatcher) {
    return Matchers.hasXPath(xPath, valueMatcher);
  }

  public static  Matcher is(T value) {
    return Matchers.is(value);
  }

  public static  Matcher is(Matcher matcher) {
    return Matchers.is(matcher);
  }

  public static  Matcher isA(Class type) {
    return Matchers.isA(type);
  }

  public static  Matcher instanceOf(Class type) {
    return Matchers.instanceOf(type);
  }

  public static  Matcher not(Matcher matcher) {
    return Matchers.not(matcher);
  }

  public static  Matcher not(T value) {
    return Matchers.not(value);
  }

  public static Matcher nullValue() {
    return Matchers.nullValue();
  }

  public static  Matcher nullValue(Class type) {
    return Matchers.nullValue(type);
  }

  public static Matcher notNullValue() {
    return Matchers.notNullValue();
  }

  public static  Matcher notNullValue(Class type) {
    return Matchers.notNullValue(type);
  }

  public static  Matcher sameInstance(T target) {
    return Matchers.sameInstance(target);
  }

  public static  Matcher theInstance(T target) {
    return Matchers.theInstance(target);
  }

  public static Matcher startsWith(String prefix) {
    return Matchers.startsWith(prefix);
  }

  public static  Matcher> iterableWithSize(Matcher sizeMatcher) {
    return Matchers.iterableWithSize(sizeMatcher);
  }

  public static  Matcher> iterableWithSize(int size) {
    return Matchers.iterableWithSize(size);
  }

  public static  Matcher isIn(Collection collection) {
    return Matchers.isIn(collection);
  }

  public static  Matcher isIn(T[] param1) {
    return Matchers.isIn(param1);
  }

  public static  Matcher isOneOf(@SuppressWarnings("unchecked") T... elements) {
    return Matchers.isOneOf(elements);
  }

  public static > Matcher lessThan(T value) {
    return Matchers.lessThan(value);
  }

  public static > Matcher lessThanOrEqualTo(T value) {
    return Matchers.lessThanOrEqualTo(value);
  }

  public static Matcher isEmptyString() {
    return Matchers.isEmptyString();
  }

  public static Matcher isEmptyOrNullString() {
    return Matchers.isEmptyOrNullString();
  }

  public static Matcher stringContainsInOrder(Iterable substrings) {
    return Matchers.stringContainsInOrder(substrings);
  }

  public static  Matcher samePropertyValuesAs(T expectedBean) {
    return Matchers.samePropertyValuesAs(expectedBean);
  }

  public static  Matcher> typeCompatibleWith(Class baseType) {
    return Matchers.typeCompatibleWith(baseType);
  }

}