/*
 * Copyright 2011 Vasily Shiyan
 *
 * 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 see.reactive;

import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;

public class AbstractDependencyTest {
    @Test
    public void testInterraction() throws Exception {
        final Var<String> a = new Var<String>("asd");
        Signal<Integer> b = new StatefulSignal<Integer>(ImmutableSet.of(a), new Supplier<Integer>() {
            @Override
            public Integer get() {
                return a.now().length();
            }
        });

        assertEquals(Integer.valueOf(3), b.now());
        a.update("omg");
        assertEquals(Integer.valueOf(3), b.now());
        a.update("zxcv");
        assertEquals(Integer.valueOf(4), b.now());
    }
}

@@ -652,32 +652,88 @@
 upplier;%0Aimport 
+org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport static 
 com.google.commo
@@ -758,34 +758,13 @@
 eSet
-;%0Aimport org.junit.Test
+.of
 ;%0A
-%0A
 impo
@@ -849,16 +849,166 @@
 yTest %7B%0A
+%0A    ReactiveFactory reactiveFactory;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        reactiveFactory = new ReactiveFactory();%0A    %7D%0A%0A
     @Tes
@@ -1034,17 +1034,16 @@
 estInter
-r
 action()
@@ -1075,24 +1075,35 @@
    final Var
+iableSignal
 %3CString%3E a =
@@ -1107,23 +1107,27 @@
 a = 
-new Var%3CString%3E
+reactiveFactory.var
 (%22as
@@ -1163,49 +1163,38 @@
 b = 
-new StatefulSignal%3CInteger%3E(ImmutableSet.
+reactiveFactory.bindWithState(
 of(a

Test now uses ReactiveFactory