tester.get(ComponentDao.class).insert(session, module);
ComponentDto file = ComponentTesting.newFileDto(module).setKey("sample:root:module:src/File.xoo");
tester.get(ComponentDao.class).insert(session, file);
IssueDto issue = IssueTesting.newDto(rule, file, project);
db.issueDao().insert(session, issue);
session.commit();
MockUserSession.set().setLogin("john").addProjectPermissions(UserRole.ADMIN, project.key());
service.bulkUpdateKey(project.key(), "sample", "sample2");
session.commit();
// Check project key has been updated
assertThat(service.getNullableByKey(project.key())).isNull();
assertThat(service.getNullableByKey("sample2:root")).isNotNull();
// Check module key has been updated
assertThat(service.getNullableByKey(module.key())).isNull();
assertThat(service.getNullableByKey("sample2:root:module")).isNotNull();
// Check file key has been updated
assertThat(service.getNullableByKey(file.key())).isNull();
assertThat(service.getNullableByKey("sample2:root:module:src/File.xoo")).isNotNull();
// Check issues are still here
assertThat(tester.get(IssueIndex.class).getNullableByKey(issue.getKey()).componentUuid()).isEqualTo(file.uuid());
assertThat(tester.get(IssueIndex.class).getNullableByKey(issue.getKey()).projectUuid()).isEqualTo(project.uuid());
// Check that no new issue has been added
assertThat(tester.get(SearchClient.class).prepareCount(IndexDefinition.ISSUES.getIndexName()).setTypes(IndexDefinition.ISSUES.getIndexType()).get().getCount()).isEqualTo(1);
// Check Issue Authorization index