From cfa03c2a562fa0d324c5879c32c1fb2ef2783b86 Mon Sep 17 00:00:00 2001 From: Mairbek Khadikov Date: Wed, 27 Feb 2013 20:29:00 +0200 Subject: [PATCH] Implemented single and singleOrDefault methods --- src/test/groovy/rx/lang/groovy/ObservableTests.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/groovy/rx/lang/groovy/ObservableTests.groovy b/src/test/groovy/rx/lang/groovy/ObservableTests.groovy index 8d4d4b6..15dac20 100644 --- a/src/test/groovy/rx/lang/groovy/ObservableTests.groovy +++ b/src/test/groovy/rx/lang/groovy/ObservableTests.groovy @@ -233,6 +233,17 @@ def class ObservableTests { } } + @Test + public void testSingle1() { + def s = Observable.toObservable("one").single({ x -> x.length() == 3}) + assertEquals("one", s) + } + + @Test(expected = IllegalStateException.class) + public void testSingle2() { + Observable.toObservable("one", "two").single({ x -> x.length() == 3}) + } + def class AsyncObservable implements Func1, Subscription> { public Subscription call(final Observer observer) {