Skip to content

Commit

Permalink
EPMRPP-91641 || Normalize url on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbortnik committed Jul 30, 2024
1 parent fa65d95 commit 62416f4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ protected Ticket invokeCommand(Integration integration, Map<String, Object> para
ticket.setId(issueId);
ticket.setSummary(name);
ticket.setTicketUrl(
Suppliers.formattedSupplier("{}/boards/{}/pulses/{}", removeTrailingSlash(url), boardId,
issueId).get());

Suppliers.formattedSupplier("{}/boards/{}/pulses/{}", url, boardId, issueId).get());
return ticket;
}

Expand Down Expand Up @@ -183,11 +181,5 @@ private void postBackLinks(PostTicketRQ ticketRQ, MondayClient mondayClient, Str
}));
}

private String removeTrailingSlash(String url) {
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1);
}
return url;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import static com.epam.reportportal.extension.monday.utils.ParamUtils.normalizeUrl;
import static com.epam.reportportal.rules.commons.validation.BusinessRule.expect;

import com.epam.reportportal.extension.CommonPluginCommand;
Expand Down Expand Up @@ -51,8 +52,8 @@ public Map<String, Object> executeCommand(Map<String, Object> integrationParams)
Map<String, Object> resultParams =
Maps.newHashMapWithExpectedSize(MondayProperties.values().length);

resultParams.put(
MondayProperties.URL.getName(), MondayProperties.URL.getParam(integrationParams));
resultParams.put(MondayProperties.URL.getName(),
normalizeUrl(MondayProperties.URL.getParam(integrationParams)));
resultParams.put(
MondayProperties.PROJECT.getName(), MondayProperties.PROJECT.getParam(integrationParams));
resultParams.put(MondayProperties.API_TOKEN.getName(),
Expand All @@ -61,4 +62,5 @@ public Map<String, Object> executeCommand(Map<String, Object> integrationParams)

return resultParams;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import static com.epam.reportportal.extension.monday.utils.ParamUtils.normalizeUrl;

import com.epam.reportportal.extension.CommonPluginCommand;
import com.epam.reportportal.extension.monday.model.enums.MondayProperties;
import com.google.common.collect.Maps;
Expand Down Expand Up @@ -43,7 +45,7 @@ public String getName() {
public Map<String, Object> executeCommand(Map<String, Object> integrationParams) {
Map<String, Object> resultParams = Maps.newHashMapWithExpectedSize(integrationParams.size());
MondayProperties.URL.findParam(integrationParams)
.ifPresent(boardId -> resultParams.put(MondayProperties.URL.getName(), boardId));
.ifPresent(url -> resultParams.put(MondayProperties.URL.getName(), normalizeUrl(url)));
MondayProperties.PROJECT.findParam(integrationParams)
.ifPresent(boardId -> resultParams.put(MondayProperties.PROJECT.getName(), boardId));
MondayProperties.API_TOKEN.findParam(integrationParams).ifPresent(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.epam.reportportal.extension.monday.utils;

public class ParamUtils {


public static String normalizeUrl(String url) {
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1);
}
return url;
}

}

0 comments on commit 62416f4

Please sign in to comment.