package org.mwg.core.task;

import org.junit.Assert;
import org.junit.Test;
import org.mwg.task.TaskAction;
import org.mwg.task.TaskContext;

public class ActionFromTest extends AbstractActionTest {

    @Test
    public void test() {
        graph.newTask()
                .from("uselessPayload")
                .then(new TaskAction() {
                    @Override
                    public void eval(TaskContext context) {
                        Assert.assertEquals(context.getPreviousResult(), "uselessPayload");
                    }
                })
                .execute();
    }

}

@@ -69,16 +69,62 @@
 t.Test;%0A
+import org.mwg.Callback;%0Aimport org.mwg.Node;%0A
 import o
@@ -637,10 +637,2150 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testFromNodes() %7B%0A        graph.all(0, 0, %22nodes%22, new Callback%3CNode%5B%5D%3E() %7B%0A            @Override%0A            public void on(Node%5B%5D result) %7B%0A                Assert.assertEquals(3,result.length);%0A%0A                String%5B%5D expected = new String%5B%5D%7B(String) result%5B0%5D.get(%22name%22),%0A                        (String) result%5B1%5D.get(%22name%22),%0A                        (String) result%5B2%5D.get(%22name%22)%7D;%0A%0A                graph.newTask()%0A                        .from(result)%0A                        .then(new TaskAction() %7B%0A                            @Override%0A                            public void eval(TaskContext context) %7B%0A                                //empty task%0A                            %7D%0A                        %7D)%0A                        .execute();%0A%0A                String%5B%5D resultName = new String%5B3%5D;%0A                try %7B%0A                    int i = 0;%0A                    for(Node n : result) %7B%0A                        resultName%5Bi%5D = (String) n.get(%22name%22);%0A                        i++;%0A                    %7D%0A                %7D catch (Exception e) %7B%0A                    resultName%5B0%5D = %22fail%22;%0A                %7D%0A%0A                Assert.assertArrayEquals(expected,resultName);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Test%0A    public void testFromNode() %7B%0A        graph.find(0, 0, %22roots%22, %22name=root%22, new Callback%3CNode%5B%5D%3E() %7B%0A            @Override%0A            public void on(Node%5B%5D result) %7B%0A                Assert.assertEquals(1,result.length);%0A%0A                graph.newTask()%0A                        .from(result%5B0%5D)%0A                        .then(new TaskAction() %7B%0A                            @Override%0A                            public void eval(TaskContext context) %7B%0A                                //empty task%0A                            %7D%0A                        %7D)%0A                        .execute();%0A                String name = %22%22;%0A                try %7B%0A                    name = (String) result%5B0%5D.get(%22name%22);%0A                %7D catch (Exception e) %7B%0A                    name = %22fail%22;%0A                %7D%0A%0A                Assert.assertEquals(%22root%22,name);%0A            %7D%0A        %7D);%0A    %7D%0A%0A%0A
 %7D%0A

add ludovic tests