@SuppressWarnings("unused") private static void tryGetAllIssues(IssueManager issueManager) throws Exception { List<Issue> issues = issueManager.getIssues(projectKey, null); for (Issue issue : issues) { logger.debug(issue.toString()); } }
@Test public void shouldReturnValidIssue() { Issue issue = redmineIssueFactory.createRemineIssue(); assertThat(issue).isNotNull(); assertThat(issue.getSubject()).as("New Subject"); assertThat(issue.getDescription()).as("New Description"); assertThat(issue.getTracker()).isNotNull(); }
@SuppressWarnings("unused") private static void tryCreateIssue(RedmineManager manager) throws RedmineException { Issue issue = new Issue(); issue.setSubject("test123"); final Version ver = VersionFactory.create(512); issue.setTargetVersion(ver); final IssueCategory cat = IssueCategoryFactory.create(673); issue.setCategory(cat); ProjectManager projectManager = manager.getProjectManager(); Project projectByKey = projectManager.getProjectByKey("testid"); issue.setProject(projectByKey); manager.getIssueManager().createIssue(issue); }
@SuppressWarnings("unused") private static void tryUpload( RedmineManager mgr, IssueManager issueManager, AttachmentManager attachmentManager) throws RedmineException, IOException { final byte[] content = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; final Attachment attach1 = attachmentManager.uploadAttachment("test.bin", "application/ternary", content); final Issue testIssue = new Issue(); testIssue.setSubject("This is upload ticket!"); testIssue.addAttachment(attach1); final Project tmpProject = ProjectFactory.create("Upload project", "uploadtmpproject"); final Project project = mgr.getProjectManager().createProject(tmpProject); try { final Issue createdIssue = issueManager.createIssue(project.getIdentifier(), testIssue); try { System.out.println(createdIssue.getAttachments()); } finally { issueManager.deleteIssue(createdIssue.getId()); } } finally { mgr.getProjectManager().deleteProject(project.getIdentifier()); } }
/** * チケットの作成 * * @return 成功または失敗を返す (true:成功, false:失敗) */ public static Boolean createTicket() { // チケットの取得 RedmineManager mgr = RedmineManagerFactory.createWithApiKey(redmineHost, apiAccessKey); try { // チケットを作成する Issue ticket = IssueFactory.create(null); // プロジェクトの指定 int intProjectKey = mgr.getProjectManager().getProjectByKey(projectKey).getId(); Project project = ProjectFactory.create(intProjectKey); ticket.setProject(project); // チケット内容の設定 ticket.setSubject("デプロイ成功."); ticket.setDescription("デプロイを実行しました。" + StringUtil.getTimestamp()); // トラッカー指定 Tracker tracker = TrackerFactory.create(3, "Support"); ticket.setTracker(tracker); // 開始日 ticket.setStartDate(Calendar.getInstance().getTime()); // 期日 ticket.setDueDate(Calendar.getInstance().getTime()); // ステータス (new) ticket.setStatusId(1); // 開始日 ticket.setStartDate(Calendar.getInstance().getTime()); // 期日 ticket.setDueDate(Calendar.getInstance().getTime()); // 進捗率 ticket.setDoneRatio(100); // 担当者 (カレントユーザ) User assignee = mgr.getUserManager().getCurrentUser(); ticket.setAssignee(assignee); // チケットの登録処理 IssueManager issueMgr = mgr.getIssueManager(); Issue newIssue = issueMgr.createIssue(ticket); issueMgr.update(newIssue); // 処理結果 System.out.println(JSON.encode(newIssue, true)); System.out.println("success."); return true; } catch (Exception e) { System.out.println(e.getStackTrace()); return false; } }
public static void writeIssue(Issue issue, final JSONWriter writer) throws JSONException { JsonOutput.addIfNotNull(writer, "id", issue.getId()); JsonOutput.addIfNotNull(writer, "subject", issue.getSubject()); JsonOutput.addIfNotNull(writer, "parent_issue_id", issue.getParentId()); JsonOutput.addIfNotNull(writer, "estimated_hours", issue.getEstimatedHours()); JsonOutput.addIfNotNull(writer, "spent_hours", issue.getSpentHours()); if (issue.getAssignee() != null) JsonOutput.addIfNotNull(writer, "assigned_to_id", issue.getAssignee().getId()); JsonOutput.addIfNotNull(writer, "priority_id", issue.getPriorityId()); JsonOutput.addIfNotNull(writer, "done_ratio", issue.getDoneRatio()); if (issue.getProject() != null) JsonOutput.addIfNotNull(writer, "project_id", issue.getProject().getIdentifier()); if (issue.getAuthor() != null) JsonOutput.addIfNotNull(writer, "author_id", issue.getAuthor().getId()); addShort2(writer, "start_date", issue.getStartDate()); addIfNotNullShort2(writer, "due_date", issue.getDueDate()); if (issue.getTracker() != null) JsonOutput.addIfNotNull(writer, "tracker_id", issue.getTracker().getId()); JsonOutput.addIfNotNull(writer, "description", issue.getDescription()); addIfNotNullFull(writer, "created_on", issue.getCreatedOn()); addIfNotNullFull(writer, "updated_on", issue.getUpdatedOn()); JsonOutput.addIfNotNull(writer, "status_id", issue.getStatusId()); if (issue.getTargetVersion() != null) JsonOutput.addIfNotNull(writer, "fixed_version_id", issue.getTargetVersion().getId()); if (issue.getCategory() != null) JsonOutput.addIfNotNull(writer, "category_id", issue.getCategory().getId()); JsonOutput.addIfNotNull(writer, "notes", issue.getNotes()); writeCustomFields(writer, issue.getCustomFields()); if (issue.getAttachments() != null && issue.getAttachments().size() > 0) { final List<Attachment> uploads = new ArrayList<Attachment>(); for (Attachment attach : issue.getAttachments()) if (attach.getToken() != null) uploads.add(attach); JsonOutput.addArrayIfNotEmpty(writer, "uploads", uploads, UPLOAD_WRITER); } /* * Journals and Relations cannot be set for an issue during creation or * updates. */ }
@SuppressWarnings("unused") private static void changeIssueStatus(IssueManager issueManager) throws RedmineException { Issue issue = issueManager.getIssueById(1771); issue.setSubject("new"); issueManager.update(issue); }
@SuppressWarnings("unused") private static void tryGetIssue(IssueManager issueManager) throws Exception { Issue issue = issueManager.getIssueById(3205, Include.journals, Include.relations, Include.attachments); System.out.println(issue.getJournals()); }
@SuppressWarnings("unused") private static void getIssueWithRelations(IssueManager issueManager) throws RedmineException { Issue issue = issueManager.getIssueById(22751, Include.relations); Collection<IssueRelation> r = issue.getRelations(); logger.debug("Retrieved relations " + r); }