@Test public void return_changelog_on_none_existing_user() { IssueDto issueDto = db.issues().insertIssue(newIssue()); userSession.logIn("john") .addMembership(db.getDefaultOrganization()) .addProjectPermission(USER, project, file); db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserUuid("UNKNOWN").setDiff("severity", "MAJOR", "BLOCKER").setCreationDate(new Date())); ChangelogWsResponse result = call(issueDto.getKey()); assertThat(result.getChangelogList()).hasSize(1); assertThat(result.getChangelogList().get(0).hasUser()).isFalse(); assertThat(result.getChangelogList().get(0).hasUserName()).isFalse(); assertThat(result.getChangelogList().get(0).hasAvatar()).isFalse(); assertThat(result.getChangelogList().get(0).getDiffsList()).isNotEmpty(); }
@Test public void return_changelog_not_having_user() { IssueDto issueDto = db.issues().insertIssue(newIssue()); userSession.logIn("john") .addMembership(db.getDefaultOrganization()) .addProjectPermission(USER, project, file); db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserUuid(null).setDiff("severity", "MAJOR", "BLOCKER").setCreationDate(new Date())); ChangelogWsResponse result = call(issueDto.getKey()); assertThat(result.getChangelogList()).hasSize(1); assertThat(result.getChangelogList().get(0).hasUser()).isFalse(); assertThat(result.getChangelogList().get(0).hasUserName()).isFalse(); assertThat(result.getChangelogList().get(0).hasAvatar()).isFalse(); assertThat(result.getChangelogList().get(0).getDiffsList()).isNotEmpty(); }
@Test public void changelog_of_file_move_contains_file_names() { RuleDto rule = db.rules().insertRule(newRuleDto()); OrganizationDto org = db.organizations().insert(); ComponentDto project = db.components().insertPrivateProject(org); ComponentDto file1 = db.components().insertComponent(newFileDto(project)); ComponentDto file2 = db.components().insertComponent(newFileDto(project)); IssueDto issueDto = db.issues().insertIssue(newDto(rule, file2, project)); userSession.logIn("john") .addMembership(org) .addProjectPermission(USER, project, file); db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setDiff("file", file1.uuid(), file2.uuid()).setCreationDate(new Date())); ChangelogWsResponse result = call(issueDto.getKey()); assertThat(result.getChangelogList()).hasSize(1); assertThat(result.getChangelogList().get(0).hasUser()).isFalse(); assertThat(result.getChangelogList().get(0).getCreationDate()).isNotEmpty(); assertThat(result.getChangelogList().get(0).getDiffsList()).extracting(Diff::getKey, Diff::getOldValue, Diff::getNewValue) .containsOnly(tuple("file", file1.longName(), file2.longName())); }