Skip to content

Commit

Permalink
EPMRPP-91834 || Add board id validation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbortnik committed Jul 29, 2024
1 parent 317a60d commit fa65d95
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.epam.reportportal.extension.monday.command.connection;

import static com.epam.reportportal.rules.exception.ErrorType.BAD_REQUEST_ERROR;
import static com.epam.reportportal.rules.exception.ErrorType.UNABLE_INTERACT_WITH_INTEGRATION;
import static java.util.Optional.ofNullable;

Expand Down Expand Up @@ -60,10 +61,20 @@ public Boolean executeCommand(Integration integration, Map<String, Object> param

String boardId = MondayProperties.PROJECT.getParam(integrationParams);

verifyBoardId(boardId);

MondayClient mondayClient = mondayClientProvider.provide(integrationParams);

return mondayClient.getBoard(boardId).map(b -> Boolean.TRUE).orElseThrow(
() -> new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION,
"Board with provided id {} not found", boardId));
}

private void verifyBoardId(String boardId) {
try {
Long.parseLong(boardId);
} catch (NumberFormatException e) {
throw new ReportPortalException(BAD_REQUEST_ERROR, "Invalid Board ID");
}
}
}

0 comments on commit fa65d95

Please sign in to comment.