use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class GitHubIssueTracker method mapToIssue.
private Issue mapToIssue(com.checkmarx.flow.dto.github.Issue issue) {
if (issue == null) {
return null;
}
Issue i = new Issue();
i.setBody(issue.getBody());
i.setTitle(issue.getTitle());
i.setId(String.valueOf(issue.getId()));
List<String> labels = new ArrayList<>();
for (LabelsItem l : issue.getLabels()) {
labels.add(l.getName());
}
i.setLabels(labels);
i.setUrl(issue.getUrl());
i.setState(issue.getState());
return i;
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class PublishingSteps method azureDevOpsContainsIssue.
@Given("Azure DevOps contains {int} open issue with title: {string} and description containing link: {string}")
public void azureDevOpsContainsIssue(int issueCount, String title, String link) throws IOException {
List<Issue> issues = getIssues();
verifyIssueCount(issues, issueCount);
String linkInHtmlAttribute = HtmlUtils.htmlEscape(link);
for (Issue issue : issues) {
assertEquals(adoProperties.getOpenStatus(), issue.getState(), "Invalid issue state.");
assertEquals(title, issue.getTitle(), "Invalid issue title.");
String description = issue.getBody();
assertNotNull(description, "Issue is missing description.");
assertTrue(description.contains(linkInHtmlAttribute), "Description doesn't contain the link: " + link);
}
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class ADOIssueTracker method getIssue.
private Issue getIssue(String uri, String issueBody, ScanRequest scanRequest) {
HttpEntity<Void> httpEntity = new HttpEntity<>(ADOUtils.createAuthHeaders(scmConfigOverrider.determineConfigToken(properties, scanRequest.getScmInstance())));
log.debug("Getting issue at uri {}", uri);
ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, String.class);
String r = response.getBody();
if (r == null) {
return null;
}
JSONObject o = new JSONObject(r);
JSONObject fields = o.getJSONObject("fields");
Issue i = new Issue();
i.setBody(fields.getString(FIELD_PREFIX.concat(issueBody)));
i.setTitle(fields.getString(TITLE_FIELD));
i.setId(String.valueOf(o.getInt("id")));
String[] tags = fields.getString(TAGS_FIELD).split(";");
i.setLabels(Arrays.asList(tags));
i.setUrl(uri);
i.setState(fields.getString(STATE_FIELD));
return i;
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method mapToIssue.
/**
* Convert Incident object into Issue
* @param incident
* @return Issue object.
*/
private Issue mapToIssue(Incident incident) {
final Issue issue = new Issue();
issue.setId(incident.getSysId());
issue.setState(incident.getState());
issue.setBody(incident.getDescription());
issue.setTitle(incident.getShortDescription());
issue.setLabels(Lists.newArrayList());
issue.setMetadata(Maps.newHashMap());
issue.setUrl(properties.getUrl());
return issue;
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method getIncidentByIDConvertToIssue.
/**
* Find Incident By Sys ID and convert into Issue
* @return Issue object.
*/
private Optional<Issue> getIncidentByIDConvertToIssue(String sysId) {
log.debug("Executing getIncidentByIDConvertToIssue");
try {
String apiRequest = String.format("%s%s?sys_id=%s", properties.getApiUrl(), INCIDENTS, sysId);
Optional<Result> res = Optional.ofNullable(restOperations.getForObject(apiRequest, Result.class));
if (res.isPresent()) {
return res.get().getIncidents().stream().map(i -> this.mapToIssue(i)).findFirst();
}
} catch (RestClientException e) {
log.error("Error occurred while fetching ServiceNow Issue");
log.error(ExceptionUtils.getStackTrace(e));
throw new MachinaRuntimeException();
}
return Optional.empty();
}
Aggregations