Package org.sonar.core.issue.db

Examples of org.sonar.core.issue.db.IssueDto


    }
  }

  @Test
  public void set_severity() {
    IssueDto issue = newIssue().setSeverity(Severity.BLOCKER);
    tester.get(IssueDao.class).insert(session, issue);
    session.commit();

    assertThat(indexClient.get(IssueIndex.class).getByKey(issue.getKey()).severity()).isEqualTo(Severity.BLOCKER);

    service.setSeverity(issue.getKey(), Severity.MINOR);

    assertThat(indexClient.get(IssueIndex.class).getByKey(issue.getKey()).severity()).isEqualTo(Severity.MINOR);
  }
View Full Code Here


    assertThat(result.count("UNKNOWN")).isEqualTo(0);
  }

  @Test
  public void search_issues() {
    IssueDto issue = newIssue();
    tester.get(IssueDao.class).insert(session, issue);
    session.commit();

    List<Issue> result = service.search(IssueQuery.builder().build(), new QueryContext()).getHits();
    assertThat(result).hasSize(1);
View Full Code Here

    db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file, project));

    RuleDto rule = RuleTesting.newXooX1();
    tester.get(RuleDao.class).insert(session, rule);

    IssueDto issue = IssueTesting.newDto(rule, file, project);
    db.issueDao().insert(session, issue);

    session.commit();

    clearIssueIndexToSimulateBatchInsertWithoutIndexing();

    queue.add(DEFAULT_PROJECT_KEY, 123L);
    AnalysisReportDto report = queue.bookNextAvailable();

    sut.execute(session, report, project);

    // Check that the issue has well be indexed in E/S
    assertThat(tester.get(IssueIndex.class).getNullableByKey(issue.getKey())).isNotNull();
  }
View Full Code Here

    RuleDto rule = RuleTesting.newXooX1();
    tester.get(RuleDao.class).insert(session, rule);

    List<String> issueKeys = newArrayList();
    for (int i = 0; i < 2001; i++) {
      IssueDto issue = IssueTesting.newDto(rule, file, project);
      tester.get(IssueDao.class).insert(session, issue);
      issueKeys.add(issue.getKey());
    }
    session.commit();
    session.clearCache();

    clearIssueIndexToSimulateBatchInsertWithoutIndexing();
View Full Code Here

  @Test
  public void bulk_change() throws Exception {
    UserDto user = new UserDto().setLogin("fred").setName("Fred");
    db.userDao().insert(session, user);

    IssueDto issue1 = IssueTesting.newDto(rule, file, project).setAssignee("fabrice");
    IssueDto issue2 = IssueTesting.newDto(rule, file, project).setAssignee("simon");
    tester.get(IssueDao.class).insert(session, issue1, issue2);
    session.commit();

    Map<String, Object> properties = newHashMap();
    properties.put("issues", issue1.getKey() + "," + issue2.getKey());
    properties.put("actions", "assign");
    properties.put("assign.assignee", user.getLogin());

    IssueBulkChangeQuery issueBulkChangeQuery = new IssueBulkChangeQuery(properties, true);
    IssueBulkChangeResult result = service.execute(issueBulkChangeQuery, userSession);
View Full Code Here

  @Test
  public void bulk_change_on_500_issues() throws Exception {
    List<String> issueKeys = newArrayList();
    for (int i = 0; i < 500; i++) {
      IssueDto issue = IssueTesting.newDto(rule, file, project).setStatus(Issue.STATUS_OPEN);
      tester.get(IssueDao.class).insert(session, issue);
      issueKeys.add(issue.getKey());
    }
    session.commit();

    Map<String, Object> properties = newHashMap();
    properties.put("issues", Joiner.on(",").join(issueKeys));
View Full Code Here

   * <pre>
   *   issueDao.insert(dbSession, IssueTesting.newDto(rule, file, project).setStatus(Issue.STATUS_RESOLVED).setResolution(Issue.RESOLUTION_FALSE_POSITIVE));
   * </pre>
   */
  public static IssueDto newDto(RuleDto rule, ComponentDto file, ComponentDto project) {
    return new IssueDto()
      .setKee(UUID.randomUUID().toString())
      .setRule(rule)
      .setComponent(file)
      .setProject(project)
      .setStatus(Issue.STATUS_OPEN)
View Full Code Here

    session.close();
  }

  @Test
  public void add_comment() throws Exception {
    IssueDto issue = IssueTesting.newDto(rule, file, project);
    tester.get(IssueDao.class).insert(session, issue);
    session.commit();

    service.addComment(issue.getKey(), "my comment", MockUserSession.get());

    List<DefaultIssueComment> comments = service.findComments(issue.getKey());
    assertThat(comments).hasSize(1);
    assertThat(comments.get(0).markdownText()).isEqualTo("my comment");
  }
View Full Code Here

  @Test
  public void update_project_key() throws Exception {
    ComponentDto file = ComponentTesting.newFileDto(project).setKey("sample:root: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").addComponentPermission(UserRole.ADMIN, project.key(), project.key());
    service.updateKey(project.key(), "sample2:root");
    session.commit();

    // Check project key has been updated
    assertThat(service.getNullableByKey(project.key())).isNull();
    assertThat(service.getNullableByKey("sample2:root")).isNotNull();

    // Check file key has been updated
    assertThat(service.getNullableByKey(file.key())).isNull();
    assertThat(service.getNullableByKey("sample2:root: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
View Full Code Here

  @Test
  public void add_comment_on_removed_issue() throws Exception {
    RuleDto removedRule = RuleTesting.newDto(RuleKey.of("removed", "rule")).setStatus(RuleStatus.REMOVED);
    tester.get(RuleDao.class).insert(session, removedRule);

    IssueDto issue = IssueTesting.newDto(removedRule, file, project).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_REMOVED);
    tester.get(IssueDao.class).insert(session, issue);
    session.commit();

    service.addComment(issue.getKey(), "my comment", MockUserSession.get());

    List<DefaultIssueComment> comments = service.findComments(issue.getKey());
    assertThat(comments).hasSize(1);
    assertThat(comments.get(0).markdownText()).isEqualTo("my comment");
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.issue.db.IssueDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.