@Test
  public void variablesDefinedInVariablesFilesAreLocated_onlyUntilDetectorWantsToContinue()
      throws Exception {
    final IFile sourceFile =
        projectProvider.createFile(
            "importingFile.robot", createVariablesImportSettingsSection("vars.py"));

    final RobotModel model = new RobotModel();
    final RobotSuiteFile suiteFile = model.createSuiteFile(sourceFile);

    final RobotSettingsSection settings = suiteFile.findSection(RobotSettingsSection.class).get();
    final RobotSetting varSetting = (RobotSetting) settings.findChild("Variables");
    final VariablesImport varsImport = (VariablesImport) varSetting.getLinkedElement();

    final VariablesFileImportReference varsImportRef = new VariablesFileImportReference(varsImport);
    varsImportRef.map(ImmutableMap.of("var_a", 42, "var_b", 1729));

    final RobotFileOutput output = suiteFile.getLinkedElement().getParent();
    output.setVariablesImportReferences(newArrayList(varsImportRef));

    final Set<String> visitedVars = new HashSet<>();
    final VariableDefinitionLocator locator = new VariableDefinitionLocator(sourceFile, model);
    locator.locateVariableDefinition(limitedVarFileVariableDetector(visitedVars));
    assertThat(visitedVars).containsOnly("${var_a}");
  }
 private static TestCase getTestCase(final RobotSuiteFile file) {
   final Optional<RobotCasesSection> section = file.findSection(RobotCasesSection.class);
   return section.get().getChildren().get(0).getLinkedElement();
 }
Esempio n. 3
0
 private RobotCasesSection getSection() {
   return fileModel.findSection(RobotCasesSection.class).orNull();
 }