// grab the first priority
final Iterable<Object> allowedValuesForPriority = issueType.getField(IssueFieldId.PRIORITY_FIELD).getAllowedValues();
assertNotNull(allowedValuesForPriority);
assertTrue(allowedValuesForPriority.iterator().hasNext());
final BasicPriority priority = (BasicPriority) allowedValuesForPriority.iterator().next();
// build issue input
final String summary = "My new issue!";
final String description = "Some description";
final BasicUser assignee = IntegrationTestUtil.USER1;
final List<String> affectedVersionsNames = Collections.emptyList();
final DateTime dueDate = new DateTime(new Date().getTime());
final ArrayList<String> fixVersionsNames = Lists.newArrayList("1.1");
// prepare IssueInput
final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary)
.setDescription(description)
.setAssignee(assignee)
.setAffectedVersionsNames(affectedVersionsNames)
.setFixVersionsNames(fixVersionsNames)
.setComponents(component)
.setDueDate(dueDate)
.setPriority(priority);
// create
final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInputBuilder.build(), pm);
assertNotNull(basicCreatedIssue.getKey());
// get issue and check if everything was set as we expected
final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey(), pm);
assertNotNull(createdIssue);
assertEquals(basicCreatedIssue.getKey(), createdIssue.getKey());
assertEquals(project.getKey(), createdIssue.getProject().getKey());
assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
assertEquals(summary, createdIssue.getSummary());
assertEquals(description, createdIssue.getDescription());
final BasicUser actualAssignee = createdIssue.getAssignee();
assertNotNull(actualAssignee);
assertEquals(assignee.getSelf(), actualAssignee.getSelf());
final Iterable<String> actualAffectedVersionsNames = EntityHelper.toNamesList(createdIssue.getAffectedVersions());
assertThat(affectedVersionsNames, containsInAnyOrder(toArray(actualAffectedVersionsNames, String.class)));
final Iterable<String> actualFixVersionsNames = EntityHelper.toNamesList(createdIssue.getFixVersions());
assertThat(fixVersionsNames, containsInAnyOrder(toArray(actualFixVersionsNames, String.class)));
assertTrue(createdIssue.getComponents().iterator().hasNext());
assertEquals(component.getId(), createdIssue.getComponents().iterator().next().getId());
// strip time from dueDate
final DateTime expectedDueDate = JsonParseUtil.parseDate(JsonParseUtil.formatDate(dueDate));
assertEquals(expectedDueDate, createdIssue.getDueDate());
final BasicPriority actualPriority = createdIssue.getPriority();
assertNotNull(actualPriority);
assertEquals(priority.getId(), actualPriority.getId());
}