Search in sources :

Example 1 with ITreeVisitor

use of org.javarosa.core.model.instance.utils.ITreeVisitor in project javarosa by opendatakit.

the class QuestionDataGroupTests method testAcceptsVisitor.

public void testAcceptsVisitor() {
    final MutableBoolean visitorAccepted = new MutableBoolean(false);
    final MutableBoolean dispatchedWrong = new MutableBoolean(false);
    ITreeVisitor sampleVisitor = new ITreeVisitor() {

        public void visit(FormInstance tree) {
            dispatchedWrong.setValue(true);
        }

        public void visit(AbstractTreeElement element) {
            visitorAccepted.setValue(true);
        }
    };
    stringElement.accept(sampleVisitor);
    assertTrue("The visitor's visit method was not called correctly by the QuestionDataElement", visitorAccepted.getValue());
    assertTrue("The visitor was dispatched incorrectly by the QuestionDataElement", !dispatchedWrong.getValue());
}
Also used : AbstractTreeElement(org.javarosa.core.model.instance.AbstractTreeElement) FormInstance(org.javarosa.core.model.instance.FormInstance) ITreeVisitor(org.javarosa.core.model.instance.utils.ITreeVisitor)

Example 2 with ITreeVisitor

use of org.javarosa.core.model.instance.utils.ITreeVisitor in project javarosa by opendatakit.

the class QuestionDataElementTests method testAcceptsVisitor.

public void testAcceptsVisitor() {
    final MutableBoolean visitorAccepted = new MutableBoolean(false);
    final MutableBoolean dispatchedWrong = new MutableBoolean(false);
    ITreeVisitor sampleVisitor = new ITreeVisitor() {

        public void visit(FormInstance tree) {
            dispatchedWrong.bool = true;
        }

        public void visit(AbstractTreeElement element) {
            visitorAccepted.bool = true;
        }
    };
    stringElement.accept(sampleVisitor);
    assertTrue("The visitor's visit method was not called correctly by the QuestionDataElement", visitorAccepted.getValue());
    assertTrue("The visitor was dispatched incorrectly by the QuestionDataElement", !dispatchedWrong.getValue());
}
Also used : AbstractTreeElement(org.javarosa.core.model.instance.AbstractTreeElement) FormInstance(org.javarosa.core.model.instance.FormInstance) ITreeVisitor(org.javarosa.core.model.instance.utils.ITreeVisitor)

Aggregations

AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)2 FormInstance (org.javarosa.core.model.instance.FormInstance)2 ITreeVisitor (org.javarosa.core.model.instance.utils.ITreeVisitor)2