org.axonframework.test.matchers
Class ListMatcher

java.lang.Object
  extended by org.hamcrest.BaseMatcher<List<?>>
      extended by org.axonframework.test.matchers.ListMatcher
All Implemented Interfaces:
org.hamcrest.Matcher<List<?>>, org.hamcrest.SelfDescribing
Direct Known Subclasses:
ExactSequenceMatcher, ListWithAllOfMatcher, ListWithAnyOfMatcher, SequenceMatcher

public abstract class ListMatcher
extends org.hamcrest.BaseMatcher<List<?>>

Abstract implementation for matchers that use event-specific matchers to match against a list of items.

Since:
1.1
Author:
Allard Buijze

Constructor Summary
protected ListMatcher(org.hamcrest.Matcher<?>... matchers)
          Creates an abstract matcher to match a number of Matchers against Events contained inside a Collection.
 
Method Summary
protected abstract  void describeCollectionType(org.hamcrest.Description description)
          Describes the type of collection expected.
 void describeTo(org.hamcrest.Description description)
           
protected  String failedMatcherMessage()
          The message to append behind a failing matcher.
protected  String getLastSeparator()
          The separator to use between the two last events.
protected  List<org.hamcrest.Matcher<?>> getMatchers()
          Returns a read-only list of Matchers, in the order they were provided in the constructor.
 boolean matches(Object item)
           
protected abstract  boolean matchesList(List<?> item)
          Evaluates the matcher for argument item.
protected  boolean matchRemainder(Iterator<org.hamcrest.Matcher<?>> matcherIterator)
          Matches all the remaining Matchers in the given matcherIterator against null.
protected  void reportFailed(org.hamcrest.Matcher matcher)
          Report the given matcher as a failing matcher.
 
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListMatcher

protected ListMatcher(org.hamcrest.Matcher<?>... matchers)
Creates an abstract matcher to match a number of Matchers against Events contained inside a Collection.

Parameters:
matchers - The matchers to match the individual Events in the Collection
Method Detail

matches

public boolean matches(Object item)

matchesList

protected abstract boolean matchesList(List<?> item)
Evaluates the matcher for argument item. The item has been verified to be a list, but the exact type of contents of a list cannot be verified, due to Erasure of Generic Types.

Parameters:
item - the object against which the matcher is evaluated.
Returns:
true if item matches, otherwise false.
See Also:
BaseMatcher

matchRemainder

protected boolean matchRemainder(Iterator<org.hamcrest.Matcher<?>> matcherIterator)
Matches all the remaining Matchers in the given matcherIterator against null.

Parameters:
matcherIterator - The iterator potentially containing more matchers
Returns:
true if no matchers remain or all matchers succeeded

reportFailed

protected void reportFailed(org.hamcrest.Matcher matcher)
Report the given matcher as a failing matcher. This will be used in the error reporting.

Parameters:
matcher - The failing matcher.

getMatchers

protected List<org.hamcrest.Matcher<?>> getMatchers()
Returns a read-only list of Matchers, in the order they were provided in the constructor.

Returns:
a read-only list of Matchers, in the order they were provided in the constructor

describeCollectionType

protected abstract void describeCollectionType(org.hamcrest.Description description)
Describes the type of collection expected. To be used in the sentence: "list with ... of: ". E.g. "all" or "sequence".

Parameters:
description - the description to append the collection type to

describeTo

public void describeTo(org.hamcrest.Description description)

failedMatcherMessage

protected String failedMatcherMessage()
The message to append behind a failing matcher. Defaults to FAILED!.

Returns:
The message to append behind a failing matcher

getLastSeparator

protected String getLastSeparator()
The separator to use between the two last events. Defaults to "and".

Returns:
The separator to use between the two last events. Defaults to "and".


Copyright © 2010-2016. All Rights Reserved.