@Test public void testResolvingMultipleConditionalReferencesForBoundedVariable() { String condition1Text = "if (question != true) { question1: \"Label\" boolean }"; String condition2Text = "if (question || false) { question2: \"Label\" boolean }"; String condition3Text = "if (question > 1) { question3: \"Label\" boolean }"; Form form = FormBuilder.build(TestHelper.buildForm("form1", condition1Text, condition2Text, condition3Text)); ReferenceResolver referencesResolver = new ReferenceResolver(form); List<Conditional> expectedConditionals = form.getStatements().stream().map(Conditional.class::cast) .collect(Collectors.toList()); assertThat(referencesResolver.getReferencedConditionals(QUESTION)).hasSize(3); assertThat(referencesResolver.getReferencedConditionals(QUESTION)).containsExactlyElementsOf( expectedConditionals); }
public Collection<Conditional> getReferencedConditionals(final Identifier variableName) { return conditionalReferences.get(variableName); }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<Conditional> getReferencedConditionals(final Identifier variableName) { return conditionalReferences.get(variableName); } }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<Conditional> getReferencedConditionals(final Identifier variableName) { return conditionalReferences.get(variableName); } ReferenceResolver(final Form form); }
ReferenceResolver implements FormVisitor<Void>, StatementVisitor<Void> { public Collection<Conditional> getReferencedConditionals(final Identifier variableName) { return conditionalReferences.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<Conditional> getReferencedConditionals(final Identifier variableName) { return conditionalReferences.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);  }