use of com.atlassian.jira.rest.client.api.domain.BasicPriority in project camel-spring-boot by apache.
the class AddIssueProducerTest 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);
lenient().when(jiraRestClientFactory.createWithBasicHttpAuthentication(any(), any(), any())).thenReturn(jiraClient);
lenient().when(jiraClient.getIssueClient()).thenReturn(issueRestClient);
lenient().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());
lenient().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());
lenient().when(metadataRestClient.getPriorities()).thenReturn(promisePriorities);
lenient().when(issueRestClient.createIssue(any(IssueInput.class))).then(inv -> {
IssueInput issueInput = inv.getArgument(0);
String summary = (String) issueInput.getField("summary").getValue();
Integer issueTypeId = Integer.parseInt(getValue(issueInput, "issuetype", "id"));
IssueType issueType = issueTypes.get(issueTypeId);
String project = getValue(issueInput, "project", "key");
String description = (String) issueInput.getField("description").getValue();
Integer priorityId = Integer.parseInt(getValue(issueInput, "priority", "id"));
BasicPriority priority = issuePriorities.get(priorityId);
backendIssue = createIssue(11L, summary, project, issueType, description, priority, userAssignee, null, null);
BasicIssue basicIssue = new BasicIssue(backendIssue.getSelf(), backendIssue.getKey(), backendIssue.getId());
return Promises.promise(basicIssue);
});
lenient().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.BasicPriority 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
}
};
}
Aggregations