From 4de71b9f89aca82cd6ed64bd340fbd6f6cb571ad Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 16 Dec 2010 08:42:16 +0000 Subject: [PATCH] minor: extended RecordingMatcher with convenience method to deal with one recorded object SVN: 19186 --- .../cisd/common/test/RecordingMatcher.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/common/source/java/ch/systemsx/cisd/common/test/RecordingMatcher.java b/common/source/java/ch/systemsx/cisd/common/test/RecordingMatcher.java index 4e29464e12d..37e9fbb9754 100644 --- a/common/source/java/ch/systemsx/cisd/common/test/RecordingMatcher.java +++ b/common/source/java/ch/systemsx/cisd/common/test/RecordingMatcher.java @@ -25,14 +25,14 @@ import org.hamcrest.Matcher; /** * A {@link Matcher} which always matches the objects to be matched and make them available. - * + * * @author Franz-Josef Elmer */ public class RecordingMatcher<T> extends BaseMatcher<T> { private List<T> objects = new ArrayList<T>(); - + /** * Removes all recored objects. */ @@ -40,7 +40,16 @@ public class RecordingMatcher<T> extends BaseMatcher<T> { 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. */ -- GitLab