final Iterable<CimProject> metadataProjects = issueClient.getCreateIssueMetadata(
new GetCreateIssueMetadataOptionsBuilder().withProjectKeys("TST").withExpandedIssueTypesFields().build(), pm);
// select project and issue
assertEquals(1, Iterables.size(metadataProjects));
final CimProject project = metadataProjects.iterator().next();
final CimIssueType issueType = EntityHelper.findEntityByName(project.getIssueTypes(), "Bug");
// grab the first component
final Iterable<Object> allowedValuesForComponents = issueType.getField(IssueFieldId.COMPONENTS_FIELD).getAllowedValues();
assertNotNull(allowedValuesForComponents);
assertTrue(allowedValuesForComponents.iterator().hasNext());
final BasicComponent component = (BasicComponent) allowedValuesForComponents.iterator().next();
// 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();