Package org.sonar.core.component

Examples of org.sonar.core.component.ComponentDto


    }
  }

  private void writeDuplication(Map<String, String> refByComponentKey, DuplicationsParser.Duplication duplication, JsonWriter json) {
    String ref = null;
    ComponentDto componentDto = duplication.file();
    if (componentDto != null) {
      String componentKey = componentDto.key();
      ref = refByComponentKey.get(componentKey);
      if (ref == null) {
        ref = Integer.toString(refByComponentKey.size() + 1);
        refByComponentKey.put(componentKey, ref);
      }
View Full Code Here


    Map<String, ComponentDto> projectsByUuid = newHashMap();
    Map<Long, ComponentDto> subProjectsById = newHashMap();
    for (Map.Entry<String, String> entry : refByComponentKey.entrySet()) {
      String componentKey = entry.getKey();
      String ref = entry.getValue();
      ComponentDto file = componentDao.getNullableByKey(session, componentKey);
      if (file != null) {
        json.name(ref).beginObject();

        addFile(json, file);
        ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session);
        ComponentDto subProject = getSubProject(file.subProjectId(), subProjectsById, session);
        addProject(json, project, subProject);

        json.endObject();
      }
    }
View Full Code Here

      }
    }
  }

  private ComponentDto getProject(String projectUuid, Map<String, ComponentDto> projectsByUuid, DbSession session) {
    ComponentDto project = projectsByUuid.get(projectUuid);
    if (project == null) {
      project = componentDao.getNullableByUuid(session, projectUuid);
      if (project != null) {
        projectsByUuid.put(project.uuid(), project);
      }
    }
    return project;
  }
View Full Code Here

    }
    return project;
  }

  private ComponentDto getSubProject(@Nullable Long projectId, Map<Long, ComponentDto> subProjectsById, DbSession session) {
    ComponentDto project = subProjectsById.get(projectId);
    if (project == null && projectId != null) {
      project = componentDao.getNullableById(projectId, session);
      if (project != null) {
        subProjectsById.put(project.getId(), project);
      }
    }
    return project;
  }
View Full Code Here

    this.sut = new ComponentIndexationInDatabaseStep(resourceIndexerDao);
  }

  @Test
  public void call_indexProject_of_dao() {
    ComponentDto project = mock(ComponentDto.class);
    when(project.getId()).thenReturn(123L);

    DbSession session = mock(DbSession.class);
    sut.execute(session, mock(AnalysisReportDto.class), project);

    verify(resourceIndexerDao).indexProject(123, session);
View Full Code Here

      .setStatus(FAILED)
      .setCreatedAt(DateUtils.parseDate("2014-10-15"))
      .setUpdatedAt(DateUtils.parseDate("2014-10-16"))
      .setStartedAt(DateUtils.parseDate("2014-10-17"))
      .setFinishedAt(DateUtils.parseDate("2014-10-18"));
    ComponentDto project = ComponentTesting.newProjectDto();

    service.write(dbSession, ANALYSIS_REPORT, new AnalysisReportLog(report, project));
    dbSession.commit();

    // 0. AssertBase case
    assertThat(index.findAll().getHits()).hasSize(1);

    Activity activity = Iterables.getFirst(index.findAll().getHits(), null);
    assertThat(activity).isNotNull();
    Map<String, String> details = activity.details();
    assertThat(details.get("id")).isEqualTo(String.valueOf(report.getId()));
    assertThat(details.get("projectKey")).isEqualTo(project.key());
    assertThat(details.get("projectName")).isEqualTo(project.name());
    assertThat(details.get("projectUuid")).isEqualTo(project.uuid());
    assertThat(details.get("status")).isEqualTo("FAILED");
    assertThat(details.get("submittedAt")).isEqualTo("2014-10-15T00:00:00+0200");
    assertThat(details.get("startedAt")).isEqualTo("2014-10-17T00:00:00+0200");
    assertThat(details.get("finishedAt")).isEqualTo("2014-10-18T00:00:00+0200");
  }
View Full Code Here

    assertThat(report.getSnapshotId()).isEqualTo(123L);
    assertThat(report.getCreatedAt()).isNotNull();
  }

  private ComponentDto insertPermissionsForProject(String projectKey) {
    ComponentDto project = new ComponentDto().setKey(projectKey);
    db.componentDao().insert(session, project);

    tester.get(PermissionFacade.class).insertGroupPermission(project.getId(), DefaultGroups.ANYONE, UserRole.USER, session);
    userSession.addProjectPermissions(UserRole.USER, project.key());

    session.commit();

    return project;
  }
View Full Code Here

    assertThat(sut.all()).isEmpty();
  }

  @Test(expected = ForbiddenException.class)
  public void cannot_add_report_when_not_the_right_rights() {
    ComponentDto project = new ComponentDto()
      .setKey("MyProject");
    db.componentDao().insert(session, project);
    session.commit();

    MockUserSession.set().setLogin("gandalf").addProjectPermissions(UserRole.USER, project.key());

    sut.add(project.getKey(), 123L);
  }
View Full Code Here

    when(testCase.name()).thenReturn(name);
    when(testCase.status()).thenReturn(status);
    when(testCase.durationInMs()).thenReturn(durationInMs);

    TestPlan testPlan = mock(TestPlan.class);
    when(testPlan.component()).thenReturn(new ComponentDto().setKey(testPlanKey).setLongName(testPlanLongName));
    when(testCase.testPlan()).thenReturn(testPlan);
    return testCase;
  }
View Full Code Here

  public void setUp() throws Exception {
    DbClient dbClient = mock(DbClient.class);
    when(dbClient.openSession(false)).thenReturn(session);
    when(dbClient.componentDao()).thenReturn(componentDao);

    project = new ComponentDto().setKey("org.codehaus.sonar:sonar").setQualifier(Qualifiers.PROJECT);
    module = new ComponentDto().setKey("org.codehaus.sonar:sonar-server").setQualifier(Qualifiers.MODULE);
    subModule = new ComponentDto().setKey("org.codehaus.sonar:sonar-server-dao").setQualifier(Qualifiers.MODULE);

    when(componentDao.getNullableByKey(session, project.key())).thenReturn(project);
    when(componentDao.getNullableByKey(session, module.key())).thenReturn(module);
    when(componentDao.getNullableByKey(session, subModule.key())).thenReturn(subModule);
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.