public Responsibility get()

in src/main/java/jetbrains/buildServer/investigationsAutoAssigner/persistent/AssignerArtifactDao.java [92:131]


  public Responsibility get(@Nullable SBuild firstFailedBuild, @NotNull STestRun testRun) {
    List<ResponsibilityPersistentInfo> suggestions;
    try {
      Path resultsFilePath = firstFailedBuild != null ?
                             myAssignerResultsFilePath.getIfExist(firstFailedBuild, testRun) :
                             myAssignerResultsFilePath.getIfExist(testRun.getBuild(), testRun);

      suggestions = mySuggestionsDao.read(resultsFilePath);
    } catch (IOException ex) {
      LOGGER.warn(String.format("%s An error occurs during reading of file with results",
                                Utils.getLogPrefix(testRun)), ex);
      return null;
    }

    for (ResponsibilityPersistentInfo persistentInfo : suggestions) {
      if (persistentInfo.testNameId.equals(String.valueOf(testRun.getTest().getTestNameId()))) {
        if (persistentInfo.investigatorId.equals(Constants.ASSIGNEE_FILTERED_LITERAL)) {

          return TeamCityProperties.getBoolean(SHOULD_PERSIST_FILTERED_TESTS_DESCRIPTION) ?
                 new Responsibility(myUserModel.getGuestUser(),
                                    Constants.ASSIGNEE_FILTERED_DESCRIPTION_PREFIX + persistentInfo.reason) :
                 null;
        }
        LOGGER.debug(String.format("%s Investigation for testRun %s was found",
                                   Utils.getLogPrefix(testRun), testRun.getTestRunId()));
        User user = myUserModel.findUserById(Long.parseLong(persistentInfo.investigatorId));
        if (user == null) {
          LOGGER.warn(String.format("%s User with id '%s' was not found in user model.", Utils.getLogPrefix(testRun),
                                    persistentInfo.investigatorId));
        }
        return user != null ? new Responsibility(user, persistentInfo.reason) : null;
      }
    }

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(String.format("%s Investigation for testRun '%s' wasn't found",
                                 Utils.getLogPrefix(testRun), testRun.getTestRunId()));
    }
    return null;
  }