Skip to content
Snippets Groups Projects
Commit 4de71b9f authored by buczekp's avatar buczekp
Browse files

minor: extended RecordingMatcher with convenience method to deal with one recorded object

SVN: 19186
parent 484d70ea
No related branches found
No related tags found
No related merge requests found
...@@ -25,14 +25,14 @@ import org.hamcrest.Matcher; ...@@ -25,14 +25,14 @@ import org.hamcrest.Matcher;
/** /**
* A {@link Matcher} which always matches the objects to be matched and make them available. * A {@link Matcher} which always matches the objects to be matched and make them available.
* *
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public class RecordingMatcher<T> extends BaseMatcher<T> public class RecordingMatcher<T> extends BaseMatcher<T>
{ {
private List<T> objects = new ArrayList<T>(); private List<T> objects = new ArrayList<T>();
/** /**
* Removes all recored objects. * Removes all recored objects.
*/ */
...@@ -40,7 +40,16 @@ public class RecordingMatcher<T> extends BaseMatcher<T> ...@@ -40,7 +40,16 @@ public class RecordingMatcher<T> extends BaseMatcher<T>
{ {
objects.clear(); objects.clear();
} }
/**
* Returns the one recorded object. Fails if not exactly one object was recorded.
*/
public T recordedObject()
{
assert objects.size() == 1 : "expected one recorded object, found " + objects.size();
return objects.get(0);
}
/** /**
* Returns the objects in the order they have been recorded. * Returns the objects in the order they have been recorded.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment