Ejemplo n.º 1
0
 /** Uuids of all the components that have open issues on this project. */
 public Set<String> loadUuidsOfComponentsWithOpenIssues() {
   DbSession session = dbClient.openSession(false);
   try {
     return dbClient
         .issueDao()
         .selectComponentUuidsOfOpenIssuesForProjectUuid(
             session, treeRootHolder.getRoot().getUuid());
   } finally {
     MyBatis.closeQuietly(session);
   }
 }
Ejemplo n.º 2
0
  private long insertNewProjectInDbAndReturnSnapshotId(int id) {
    String suffix = String.valueOf(id);
    ComponentDto project =
        ComponentTesting.newProjectDto("project-uuid-" + suffix).setKey("project-key-" + suffix);
    RuleDto rule = RuleTesting.newDto(RuleKey.of("sonarqube", "rule-" + suffix));
    dbClient.ruleDao().insert(dbSession, rule);
    IssueDto issue = IssueTesting.newDto(rule, project, project).setKee("issue-key-" + suffix);
    dbClient.componentDao().insert(dbSession, project);
    SnapshotDto snapshot =
        dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(project));
    dbClient.issueDao().insert(dbSession, issue);
    dbSession.commit();

    return snapshot.getId();
  }
Ejemplo n.º 3
0
  @Test
  public void delete_project_and_data_in_db_by_uuid() throws Exception {
    long snapshotId1 = insertNewProjectInDbAndReturnSnapshotId(1);
    long snapshotId2 = insertNewProjectInDbAndReturnSnapshotId(2);

    newRequest().setParam(PARAM_ID, "project-uuid-1").execute();
    dbSession.commit();

    assertThat(dbClient.componentDao().selectByUuid(dbSession, "project-uuid-1")).isAbsent();
    assertThat(dbClient.componentDao().selectOrFailByUuid(dbSession, "project-uuid-2")).isNotNull();
    assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId1)).isNull();
    assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId2)).isNotNull();
    assertThat(dbClient.issueDao().selectByKey(dbSession, "issue-key-1").isPresent()).isFalse();
    assertThat(dbClient.issueDao().selectOrFailByKey(dbSession, "issue-key-2")).isNotNull();
  }
Ejemplo n.º 4
0
 IssueDto getByKeyForUpdate(DbSession session, String key) {
   // Load from index to check permission : if the user has no permission to see the issue an
   // exception will be generated
   Issue authorizedIssueIndex = getByKey(key);
   return dbClient.issueDao().selectOrFailByKey(session, authorizedIssueIndex.key());
 }