private static IssueChangeDto newDto(String issueKey) { IssueChangeDto dto = new IssueChangeDto(); dto.setIssueKey(issueKey); // technical dates - do not use the context date dto.setCreatedAt(System2.INSTANCE.now()); dto.setUpdatedAt(System2.INSTANCE.now()); return dto; }
private Consumer<CommentData> updateComment(DbSession dbSession) { return commentData -> { commentData.getIssueChangeDto().setUpdatedAt(system2.now()); commentData.getIssueChangeDto().setChangeData(commentData.getRequest().getText()); dbClient.issueChangeDao().update(dbSession, commentData.getIssueChangeDto()); dbSession.commit(); }; }
@Test public void to_comment() { IssueChangeDto changeDto = new IssueChangeDto() .setKey("EFGH") .setUserUuid("user_uuid") .setChangeData("Some text") .setIssueKey("ABCDE") .setCreatedAt(System2.INSTANCE.now()) .setUpdatedAt(System2.INSTANCE.now()); DefaultIssueComment comment = changeDto.toComment(); assertThat(comment.key()).isEqualTo("EFGH"); assertThat(comment.markdownText()).isEqualTo("Some text"); assertThat(comment.createdAt()).isNotNull(); assertThat(comment.updatedAt()).isNotNull(); assertThat(comment.userUuid()).isEqualTo("user_uuid"); assertThat(comment.issueKey()).isEqualTo("ABCDE"); }
public static IssueChangeDto newIssuechangeDto(IssueDto issue) { return new IssueChangeDto() .setKey(UuidFactoryFast.getInstance().create()) .setIssueKey(issue.getKey()) .setChangeData("data_" + randomAlphanumeric(40)) .setChangeType(IssueChangeDto.TYPE_FIELD_CHANGE) .setUserUuid("userUuid_" + randomAlphanumeric(40)) .setIssueChangeCreationDate(nextLong()) .setCreatedAt(nextLong()) .setUpdatedAt(nextLong()); }
@Test public void update_unknown_key() { IssueDto issue = db.issues().insertIssue(); IssueChangeDto issueChange = db.issues().insertChange(issue); assertThat(underTest.update(db.getSession(), new IssueChangeDto() .setKey("UNKNOWN") .setIssueKey("other_issue_uuid") .setChangeData("new comment") .setUpdatedAt(DateUtils.parseDate("2013-06-30").getTime()))) .isFalse(); assertThat(underTest.selectByIssueKeys(db.getSession(), singletonList(issue.getKey()))) .extracting(IssueChangeDto::getKey, IssueChangeDto::getIssueKey, IssueChangeDto::getChangeData, IssueChangeDto::getChangeType, IssueChangeDto::getIssueChangeCreationDate, IssueChangeDto::getCreatedAt, IssueChangeDto::getUpdatedAt) .containsExactlyInAnyOrder( tuple(issueChange.getKey(), issue.getKey(), issueChange.getChangeData(), issueChange.getChangeType(), issueChange.getIssueChangeCreationDate(), issueChange.getCreatedAt(), issueChange.getUpdatedAt())); }
private static IssueChangeDto newDto(String issueKey) { IssueChangeDto dto = new IssueChangeDto(); dto.setIssueKey(issueKey); // technical dates - do not use the context date dto.setCreatedAt(System2.INSTANCE.now()); dto.setUpdatedAt(System2.INSTANCE.now()); return dto; }
private Consumer<CommentData> updateComment(DbSession dbSession) { return commentData -> { commentData.getIssueChangeDto().setUpdatedAt(system2.now()); commentData.getIssueChangeDto().setChangeData(commentData.getRequest().getText()); dbClient.issueChangeDao().update(dbSession, commentData.getIssueChangeDto()); dbSession.commit(); }; }