Skip to content

Commit

Permalink
EPMRPP-90715 || Change test connection command to throw exception whe…
Browse files Browse the repository at this point in the history
…n incorrect board id.
  • Loading branch information
pbortnik committed Jun 13, 2024
1 parent 059c405 commit 1261794
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

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

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

import com.epam.reportportal.extension.PluginCommand;
import com.epam.reportportal.extension.monday.client.MondayClient;
import com.epam.reportportal.extension.monday.client.MondayClientProvider;
import com.epam.reportportal.extension.monday.model.enums.MondayProperties;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationParams;
Expand All @@ -47,21 +47,23 @@ public String getName() {
@Override
public Boolean executeCommand(Integration integration, Map<String, Object> params) {
IntegrationParams integrationParams = ofNullable(integration.getParams()).orElseThrow(
() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
() -> new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION,
"Integration params are not specified."
));

String url = MondayProperties.URL.getParam(integrationParams);

if (!url.startsWith("https://") || !url.contains(".monday.com")) {
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
throw new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION,
"Invalid URL.");
}

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

MondayClient mondayClient = mondayClientProvider.provide(integrationParams);

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

0 comments on commit 1261794

Please sign in to comment.