Package org.sonar.core.component

Examples of org.sonar.core.component.ComponentDto


  @Test
  public void use_project_and_sub_project_names_if_no_long_name() throws Exception {
    String issueKey = "ABCD";

    // Project
    ComponentDto project = ComponentTesting.newProjectDto()
      .setId(1L)
      .setKey("org.sonar.Sonar")
      .setName("SonarQube")
      .setLongName(null);
    when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);

    // Module
    ComponentDto module = ComponentTesting.newModuleDto(project)
      .setId(2L)
      .setKey("org.sonar.server.Server")
      .setName("SonarQube :: Server")
      .setLongName(null)
      .setQualifier("BRC")
      .setSubProjectId(1L);
    when(componentDao.getNullableById(module.getId(), session)).thenReturn(module);

    // File
    ComponentDto file = ComponentTesting.newFileDto(module)
      .setId(10L)
      .setKey("org.sonar.server.issue.IssueClient")
      .setLongName("SonarQube :: Issue Client")
      .setQualifier("FIL")
      .setSubProjectId(2L);
    when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);

    DefaultIssue issue = new DefaultIssue()
      .setKey(issueKey)
      .setComponentKey("org.sonar.server.issue.IssueClient")
      .setComponentUuid(file.uuid())
      .setProjectKey("org.sonar.Sonar")
      .setProjectUuid(project.uuid())
      .setModuleUuid(module.uuid())
      .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
      .setLine(12)
View Full Code Here


  @Test
  public void show_issue_on_removed_component() throws Exception {
    String issueKey = "ABCD";

    ComponentDto project = ComponentTesting.newProjectDto()
      .setId(1L)
      .setKey("org.sonar.Sonar")
      .setLongName("SonarQube")
      .setName("SonarQube");
    when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);

    ComponentDto file = ComponentTesting.newFileDto(project)
      .setId(10L)
      .setEnabled(false)
      .setKey("org.sonar.server.issue.IssueClient")
      .setLongName("SonarQube :: Issue Client")
      .setName("SonarQube :: Issue Client")
      .setQualifier("FIL")
      .setSubProjectId(1L);
    when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);

    DefaultIssue issue = createIssue()
      .setComponentUuid(file.uuid())
      .setProjectUuid(project.uuid());
    when(issueService.getByKey(issueKey)).thenReturn(issue);

    MockUserSession.set();
    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issueKey);
View Full Code Here

    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issue.key());
    request.execute().assertJson(getClass(), "show_issue_with_changelog.json");
  }

  private DefaultIssue createStandardIssue() {
    ComponentDto project = ComponentTesting.newProjectDto()
      .setId(1L)
      .setKey("org.sonar.Sonar")
      .setLongName("SonarQube")
      .setName("SonarQube");
    when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);

    ComponentDto file = ComponentTesting.newFileDto(project)
      .setId(10L)
      .setKey("org.sonar.server.issue.IssueClient")
      .setLongName("SonarQube :: Issue Client")
      .setName("SonarQube :: Issue Client")
      .setQualifier("FIL")
      .setSubProjectId(1L);
    when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);

    return createIssue()
      .setComponentUuid(file.uuid())
      .setProjectUuid(project.uuid());
  }
View Full Code Here

      .setSeverity("MAJOR")
      .setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
      .setIssueUpdateDate(DateUtils.parseDate("2014-12-04"));
    db.issueDao().insert(session, issue);

    ComponentDto project2 = ComponentTesting.newProjectDto().setUuid("DBCA").setProjectUuid("DBCA")
      .setKey("MyProject2");
    db.componentDao().insert(session, project2);
    db.snapshotDao().insert(session, SnapshotTesting.createForProject(project2));
    tester.get(PermissionFacade.class).insertGroupPermission(project2.getId(), DefaultGroups.ANYONE, UserRole.USER, session);
    tester.get(PermissionFacade.class).insertGroupPermission(project2.getId(), DefaultGroups.ANYONE, UserRole.CODEVIEWER, session);
    db.issueAuthorizationDao().synchronizeAfter(session, new Date(0));

    ComponentDto file2 = ComponentTesting.newFileDto(project2).setUuid("EDCB")
      .setKey("MyComponent2")
      .setSubProjectId(project2.getId());
    db.componentDao().insert(session, file2);

    IssueDto issue2 = IssueTesting.newDto(rule, file2, project2)
View Full Code Here

    result.assertJson(this.getClass(), "issue_with_extra_fields.json", false);
  }

  @Test
  public void issue_linked_on_removed_file() throws Exception {
    ComponentDto removedFile = ComponentTesting.newFileDto(project).setUuid("EDCB")
      .setEnabled(false)
      .setKey("RemovedComponent")
      .setSubProjectId(project.getId());
    db.componentDao().insert(session, removedFile);
View Full Code Here

    result.assertJson(this.getClass(), "return_full_number_of_issues_when_only_one_component_is_set.json", false);
  }

  @Test
  public void components_contains_sub_projects() throws Exception {
    ComponentDto project = ComponentTesting.newProjectDto().setKey("ProjectHavingModule");
    db.componentDao().insert(session, project);
    db.snapshotDao().insert(session, SnapshotTesting.createForProject(project));

    // project can be seen by anyone
    tester.get(PermissionFacade.class).insertGroupPermission(project.getId(), DefaultGroups.ANYONE, UserRole.USER, session);
    db.issueAuthorizationDao().synchronizeAfter(session, new Date(0));

    ComponentDto module = ComponentTesting.newFileDto(project).setKey("ModuleHavingFile")
      .setScope("PRJ")
      .setSubProjectId(project.getId());
    db.componentDao().insert(session, module);
    db.snapshotDao().insert(session, SnapshotTesting.createForComponent(module, project));

    ComponentDto file = ComponentTesting.newFileDto(module).setKey("FileLinkedToModule");
    db.componentDao().insert(session, file);
    db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file, project));

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

    TimeProfiler profiler = new TimeProfiler(LOG).start(String.format("#%s - %s - Analysis report processing", report.getId(), report.getProjectKey()));

    // Synchronization of a lot of data can only be done with a batch session for the moment
    DbSession session = dbClient.openSession(true);

    ComponentDto project = findProject(report, session);

    try {
      report.succeed();
      for (ComputationStep step : stepRegistry.steps()) {
        TimeProfiler stepProfiler = new TimeProfiler(LOG).start(step.getDescription());
View Full Code Here

    JsonWriter json = response.newJsonWriter();
    json.beginObject();

    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto component = dbClient.componentDao().getNullableByKey(session, fileKey);
      if (component == null) {
        throw new NotFoundException(String.format("Component '%s' does not exist", fileKey));
      }
      userSession.checkComponentPermission(UserRole.USER, fileKey);

      List<Period> periodList = periods(component.projectUuid(), session);
      Integer periodIndex = request.paramAsInt(PARAM_PERIOD);
      Date periodDate = periodDate(periodIndex, periodList);

      RulesAggregation rulesAggregation = issueService.findRulesByComponent(component.key(), periodDate, session);
      Multiset<String> severitiesAggregation = issueService.findSeveritiesByComponent(component.key(), periodDate, session);
      Map<String, MeasureDto> measuresByMetricKey = measuresByMetricKey(component, session);

      appendComponent(json, component, userSession, session);
      appendPermissions(json, component, userSession);
      appendPeriods(json, periodList);
View Full Code Here

    json.prop("path", component.path());
    json.prop("name", component.name());
    json.prop("longName", component.longName());
    json.prop("q", component.qualifier());

    ComponentDto subProject = nullableComponentById(component.subProjectId(), session);
    ComponentDto project = dbClient.componentDao().getByUuid(session, component.projectUuid());

    // Do not display sub project if sub project and project are the same
    boolean displaySubProject = subProject != null && !subProject.getId().equals(project.getId());

    json.prop("subProject", displaySubProject ? subProject.key() : null);
    json.prop("subProjectName", displaySubProject ? subProject.longName() : null);
    json.prop("project", project.key());
    json.prop("projectName", project.longName());

    json.prop("fav", isFavourite);
  }
View Full Code Here

    for (Issue issue : result.getHits()) {
      json.beginObject();

      String actionPlanKey = issue.actionPlanKey();
      ComponentDto file = componentsByUuid.get(issue.componentUuid());
      ComponentDto project = file != null ? projectsByComponentUuid.get(file.uuid()) : null;
      Duration debt = issue.debt();
      Date updateDate = issue.updateDate();

      json
        .prop("key", issue.key())
        .prop("component", file != null ? file.getKey() : null)
        // Only used for the compatibility with the Issues Java WS Client <= 4.4 used by Eclipse
        .prop("componentId", file != null ? file.getId() : null)
        .prop("project", project != null ? project.getKey() : null)
        .prop("rule", issue.ruleKey().toString())
        .prop("status", issue.status())
        .prop("resolution", issue.resolution())
        .prop("severity", issue.severity())
        .prop("message", issue.message())
        .prop("line", issue.line())
        .prop("debt", debt != null ? durations.encode(debt) : null)
        .prop("reporter", issue.reporter())
        .prop("assignee", issue.assignee())
        .prop("author", issue.authorLogin())
        .prop("actionPlan", actionPlanKey)
        .prop("creationDate", isoDate(issue.creationDate()))
        .prop("updateDate", isoDate(updateDate))
        // TODO Remove as part of Front-end rework on Issue Domain
        .prop("fUpdateAge", formatAgeDate(updateDate))
        .prop("closeDate", isoDate(issue.closeDate()));

      writeIssueComments(commentsByIssues.get(issue.key()), usersByLogin, json);
      writeIssueAttributes(issue, json);
      writeIssueExtraFields(issue, project != null ? project.getKey() : null, usersByLogin, actionPlanByKeys, extraFields, json);
      json.endObject();
    }

    json.endArray();
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.component.ComponentDto

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.