@Test public void testResolvingMultipleQuestionReferencesForBoundedVariable() { String question1Text = "question1: \"Label\" boolean (question != true)"; String question2Text = "question2: \"Label\" boolean (question > 2)"; String question3Text = "question3: \"Label\" boolean (question + 2 - 1 == 5)"; Form form = FormBuilder.build(TestHelper.buildForm("form1", question1Text, question2Text, question3Text)); ReferenceResolver referencesResolver = new ReferenceResolver(form); List<ComputedQuestion> expectedConditionals = form.getStatements().stream().map(ComputedQuestion.class::cast) .collect(Collectors.toList()); assertThat(referencesResolver.getReferencedQuestions(QUESTION)).hasSize(3); assertThat(referencesResolver.getReferencedQuestions(QUESTION)).containsExactlyElementsOf(expectedConditionals); }
public Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName) { return questionReferences.get(variableName); }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName) { return questionReferences.get(variableName); } }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName) { return questionReferences.get(variableName); } ReferenceResolver(final Form form); }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName) { return questionReferences.get(variableName); } ReferenceResolver(final Form form); Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName); Collection<Conditional> getReferencedConditionals(final Identifier variableName); @Override Void visit(final Form form); @Override Void visit(final ComputedQuestion question); @Override Void visit(final Question statement); @Override Void visit(final Conditional conditional); }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName) { return questionReferences.get(variableName); } ReferenceResolver(final Form form); Collection<ComputedQuestion> getReferencedQuestions(final Identifier variableName); Collection<Conditional> getReferencedConditionals(final Identifier variableName); @Override Void visit(final Form form); @Override Void visit(final ComputedQuestion question); @Override Void visit(final Question statement); @Override Void visit(final Conditional conditional);  }