public void robotComment()

in ddm-rrm-gerrit-integration/src/main/java/com/epam/digital/data/platform/management/gerritintegration/service/GerritServiceImpl.java [374:403]


  public void robotComment(RobotCommentInputDto requestDto, String changeId) {
    ReviewInput reviewInput = new ReviewInput();
    if (requestDto.getComment() != null && !requestDto.getComment().isEmpty()) {
      Map<String, List<ReviewInput.RobotCommentInput>> robotComments = new HashMap<>();
      ReviewInput.RobotCommentInput robotCommentInput = new ReviewInput.RobotCommentInput();
      robotCommentInput.path = requestDto.getFilePath();
      robotCommentInput.robotId = requestDto.getRobotId();
      robotCommentInput.robotRunId = requestDto.getRobotRunId();
      robotCommentInput.message = requestDto.getComment();
      robotComments.put(robotCommentInput.path, Collections.singletonList(robotCommentInput));
      reviewInput.robotComments = robotComments;
    }
    reviewInput.message(requestDto.getMessage());

    try {
      gerritApi.changes().id(changeId).current().review(reviewInput);
    } catch (HttpStatusException ex) {
      if (ex.getStatusCode() == HttpStatus.NOT_FOUND.value()) {
        throw new GerritChangeNotFoundException("Could not found candidate with id " + changeId,
            ex);
      } else {
        throw new GerritCommunicationException(
            "Something went wrong while creating robot comment on candidate with id " + changeId,
            ex);
      }
    } catch (RestApiException ex) {
      throw new GerritCommunicationException(
          "Something went wrong while creating robot comment on candidate with id " + changeId, ex);
    }
  }