Esempio n. 1
0
  private String parseData(Validations result) {
    if (result.getValidationErrors() == null || result.getValidationErrors().isEmpty()) {
      return "";
    }
    StringBuilder builder = new StringBuilder();
    for (Map.Entry<String, List<ValidationError>> entry : result.getValidationErrors().entrySet()) {
      builder.append(this.checkstyleFormatter.checkstyleErrors(entry.getKey(), entry.getValue()));
    }

    return builder.toString();
  }
Esempio n. 2
0
  @Override
  public void run() {
    if (this.checkstyleFuture.isDone() && this.runResultFuture.isDone()) {
      try {
        RunResult tests = this.runResultFuture.get();
        Validations checks;
        try {
          checks = this.checkstyleFuture.get();
        } catch (ExecutionException ex) {
          if (ex.getCause() instanceof UnsupportedOperationException) {
            checks = new Validations();
            checks.setValidationErrors(new HashMap<String, List<ValidationError>>());
          } else {
            throw ex;
          }
        }

        if (tests.status == PASSED && !checks.getValidationErrors().isEmpty()) {
          output.write("All tests passed, but there are checkstyle errors.\n".getBytes());
          output.write(parseData(checks).getBytes());
          output.write("\n".getBytes());
          socket.close();
          return;
        }

        output.write(parseData(tests).getBytes());
        output.write(parseData(checks).getBytes());
        output.write("\n".getBytes());
        socket.close();

      } catch (InterruptedException | ExecutionException | IOException ex) {
        System.err.println(ex.getMessage());
        Logger.getLogger(TestsListener.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }