package org.commcare.android.tests;

import org.commcare.suite.model.graph.Graph;
import org.commcare.suite.model.graph.XYSeries;
import org.javarosa.core.model.instance.TreeReference;

@Config(application = CommCareApplication.class,
        constants = BuildConfig.class)
@RunWith(CommCareTestRunner.class)
public class GraphTest extends XPathEvalTest {

    @Test
    private void testSeriesNodeSetExpansion() {
        EvaluationContext ec = getFunctionHandlers();
        FormInstance instance = createTestInstance();

        addDataRef(instance, "/data/flag", new IntegerData(2));
        addDataRef(instance, "/data/three[1]", new StringData("alpha"));
        addDataRef(instance, "/data/three[2]", new StringData("beta"));
        addDataRef(instance, "/data/three[3]", new StringData("delta"));
        addDataRef(instance, "/data/two[0]", new StringData("omega"));
        addDataRef(instance, "/data/two[1]", new StringData("psi"));

        XYSeries pathSeries = new XYSeries("/data/two");
        Vector<TreeReference> pathNodes = Graph.expandNodeSet(pathSeries, ec);
        Assert.assertEquals(pathNodes.length, 2);

        XYSeries expressionSeries = new XYSeries("if(/data/flag mod 2 = 1, /data/three, /data/two)");
        Vector<TreeReference> expressionNodes = Graph.expandNodeSet(expressionSeries, ec);
        Assert.assertEquals(expressionNodes.length(), 3);
    }

}
@@ -179,16 +179,482 @@
 rence;%0A%0A
+import org.javarosa.core.model.data.IntegerData;%0Aimport org.javarosa.core.model.data.StringData;%0Aimport org.javarosa.core.model.condition.EvaluationContext;%0Aimport org.javarosa.core.model.instance.FormInstance;%0A%0Aimport org.commcare.CommCareApplication;%0Aimport org.commcare.android.CommCareTestRunner;%0Aimport org.commcare.dalvik.BuildConfig;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.robolectric.annotation.Config;%0A%0A%0A
 @Config(

fix imports