use of com.atlassian.jira.rest.client.api.domain.Priority in project jira-plugin by jenkinsci.
the class JiraCreateIssueNotifier method createJiraIssue.
/**
* It creates a issue in the given project, with the given description, assignee,components and summary.
* The created issue ID is saved to the file at "filename".
*
* @param build
* @param filename
* @return issue id
* @throws IOException
* @throws InterruptedException
*/
private Issue createJiraIssue(AbstractBuild<?, ?> build, String filename) throws IOException, InterruptedException {
EnvVars vars = build.getEnvironment(TaskListener.NULL);
JiraSession session = getJiraSession(build);
String buildName = getBuildName(vars);
String summary = String.format("Build %s failed", buildName);
String description = String.format("%s\n\nThe build %s has failed.\nFirst failed run: %s", (this.testDescription.equals("")) ? "No description is provided" : vars.expand(this.testDescription), buildName, getBuildDetailsString(vars));
Iterable<String> components = Arrays.stream(component.split(",")).filter(s -> !StringUtils.isEmpty(s)).map(s -> StringUtils.trim(s)).collect(Collectors.toList());
Long type = typeId;
if (type == null || type == 0) {
// zero is default / invalid selection
LOG.info("Returning default issue type id " + BUG_ISSUE_TYPE_ID);
type = BUG_ISSUE_TYPE_ID;
}
Long priority = priorityId;
if (priority != null && priority == 0) {
// remove invalid priority selection
priority = null;
}
Issue issue = session.createIssue(projectKey, description, assignee, components, summary, type, priority);
writeInFile(filename, issue);
return issue;
}
use of com.atlassian.jira.rest.client.api.domain.Priority in project camel-spring-boot by apache.
the class UpdateIssueProducerTest method contextConfiguration.
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
public void beforeApplicationStart(CamelContext context) {
// get chance to mock camelContext/Registry
jiraRestClientFactory = mock(JiraRestClientFactory.class);
jiraClient = mock(JiraRestClient.class);
issueRestClient = mock(IssueRestClient.class);
metadataRestClient = mock(MetadataRestClient.class);
when(jiraRestClientFactory.createWithBasicHttpAuthentication(any(), any(), any())).thenReturn(jiraClient);
when(jiraClient.getIssueClient()).thenReturn(issueRestClient);
when(jiraClient.getMetadataClient()).thenReturn(metadataRestClient);
Map<Integer, IssueType> issueTypes = new HashMap<>();
issueTypes.put(1, new IssueType(null, 1L, "Bug", false, null, null));
issueTypes.put(2, new IssueType(null, 2L, "Task", false, null, null));
Promise<Iterable<IssueType>> promiseIssueTypes = Promises.promise(issueTypes.values());
when(metadataRestClient.getIssueTypes()).thenReturn(promiseIssueTypes);
Map<Integer, Priority> issuePriorities = new HashMap<>();
issuePriorities.put(1, new Priority(null, 1L, "High", null, null, null));
issuePriorities.put(2, new Priority(null, 2L, "Low", null, null, null));
Promise<Iterable<Priority>> promisePriorities = Promises.promise(issuePriorities.values());
when(metadataRestClient.getPriorities()).thenReturn(promisePriorities);
backendIssue = createIssue(11L);
when(issueRestClient.updateIssue(anyString(), any(IssueInput.class))).then(inv -> {
String issueKey = inv.getArgument(0);
IssueInput issueInput = inv.getArgument(1);
String summary = (String) issueInput.getField("summary").getValue();
Integer issueTypeId = Integer.parseInt(getValue(issueInput, "issuetype", "id"));
IssueType issueType = issueTypes.get(issueTypeId);
String description = (String) issueInput.getField("description").getValue();
Integer priorityId = Integer.parseInt(getValue(issueInput, "priority", "id"));
BasicPriority priority = issuePriorities.get(priorityId);
backendIssue = createIssue(11L, summary, issueKey, issueType, description, priority, userAssignee, null, null);
BasicIssue basicIssue = new BasicIssue(backendIssue.getSelf(), backendIssue.getKey(), backendIssue.getId());
return Promises.promise(basicIssue);
});
when(issueRestClient.getIssue(any())).then(inv -> Promises.promise(backendIssue));
camelContext.getRegistry().bind(JIRA_REST_CLIENT_FACTORY, jiraRestClientFactory);
}
@Override
public void afterApplicationStart(CamelContext camelContext) {
// do nothing here
}
};
}
use of com.atlassian.jira.rest.client.api.domain.Priority in project camel-spring-boot by apache.
the class WatchUpdatesConsumerTest method singleChangeTest.
@Test
public void singleChangeTest() throws Exception {
Issue issue = setPriority(issues.get(0), new Priority(null, 4L, "High", null, null, null));
reset(searchRestClient);
AtomicBoolean searched = new AtomicBoolean();
when(searchRestClient.searchJql(any(), any(), any(), any())).then(invocation -> {
if (!searched.get()) {
issues.remove(0);
issues.add(0, issue);
}
SearchResult result = new SearchResult(0, 50, 100, issues);
return Promises.promise(result);
});
mockResult.expectedBodiesReceived(issue.getPriority());
mockResult.expectedHeaderReceived(JiraConstants.ISSUE_CHANGED, "Priority");
mockResult.expectedHeaderReceived(JiraConstants.ISSUE_KEY, "TST-1");
mockResult.expectedMessageCount(1);
mockResult.assertIsSatisfied(0);
}
Aggregations