/**
   * Retrieves the Notes about the JUnit test.
   *
   * @param testCase JUnit test.
   * @return Notes about the JUnit test.
   */
  private String getJUnitNotes(CaseResult testCase, int buildNumber) {
    StringBuilder notes = new StringBuilder();
    notes.append(
        Messages.Results_JUnit_NotesForTestCase(
            testCase.getName(),
            testCase.getClassName(),
            testCase.getSkipCount(),
            testCase.getFailCount(),
            (testCase.getSuiteResult() != null ? testCase.getSuiteResult().getTimestamp() : null)));

    /* Added for appending build number and error message */
    notes.append("\nBuild no : " + buildNumber);
    if (null != testCase.getErrorDetails()) {
      notes.append("\nError Message : " + testCase.getErrorDetails());
    }

    return notes.toString();
  }
  /* (non-Javadoc)
   * @see hudson.plugins.testlink.result.ResultSeeker#seekAndUpdate(hudson.plugins.testlink.result.TestCaseWrapper<?>[], hudson.model.AbstractBuild, hudson.Launcher, hudson.model.BuildListener, hudson.plugins.testlink.TestLinkSite, hudson.plugins.testlink.result.Report)
   */
  @Override
  public void seek(
      TestCaseWrapper[] automatedTestCases,
      AbstractBuild<?, ?> build,
      Launcher launcher,
      BuildListener listener,
      TestLinkSite testlink)
      throws ResultSeekerException {
    listener.getLogger().println(Messages.Results_JUnit_LookingForTestCases()); // i18n
    try {
      final JUnitParser parser = new JUnitParser(false);
      final TestResult testResult = parser.parse(this.includePattern, build, launcher, listener);

      for (SuiteResult suiteResult : testResult.getSuites()) {
        for (CaseResult caseResult : suiteResult.getCases()) {
          for (TestCaseWrapper automatedTestCase : automatedTestCases) {
            final String[] commaSeparatedValues =
                automatedTestCase.getKeyCustomFieldValues(this.keyCustomField);
            for (String value : commaSeparatedValues) {
              if (!caseResult.isSkipped() && caseResult.getName().equals(value)) {
                ExecutionStatus status = this.getExecutionStatus(caseResult);
                automatedTestCase.addCustomFieldAndStatus(value, status);

                if (this.isIncludeNotes()) {
                  final String notes = this.getJUnitNotes(caseResult, build.number);
                  automatedTestCase.appendNotes(notes);
                }
                super.handleResult(automatedTestCase, build, listener, testlink, suiteResult);
              }
            }
          }
        }
      }
    } catch (IOException e) {
      throw new ResultSeekerException(e);
    } catch (InterruptedException e) {
      throw new ResultSeekerException(e);
    }
  }