@Test
public void insert_and_find_by_key() throws Exception {
RuleDto rule = RuleTesting.newXooX1();
tester.get(RuleDao.class).insert(dbSession, rule);
ComponentDto project = ComponentTesting.newProjectDto();
tester.get(ComponentDao.class).insert(dbSession, project);
// project can be seen by anyone
tester.get(PermissionFacade.class).insertGroupPermission(project.getId(), DefaultGroups.ANYONE, UserRole.USER, dbSession);
dbClient.issueAuthorizationDao().synchronizeAfter(dbSession, new Date(0));
ComponentDto file = ComponentTesting.newFileDto(project);
tester.get(ComponentDao.class).insert(dbSession, file);
IssueDto issue = IssueTesting.newDto(rule, file, project).setIssueAttributes(KeyValueFormat.format(ImmutableMap.of("key", "value")));
dbClient.issueDao().insert(dbSession, issue);