Package org.sonar.core.component

Examples of org.sonar.core.component.ComponentDto


    WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("key", COMPONENT_KEY);
    request.execute().assertJson(getClass(), "app_with_manual_rules.json");
  }

  private ComponentDto addComponent() {
    ComponentDto file = ComponentTesting.newFileDto(project)
      .setId(10L)
      .setQualifier("FIL")
      .setKey(COMPONENT_KEY)
      .setName("Plugin.java")
      .setLongName("src/main/java/org/sonar/api/Plugin.java")
      .setPath("src/main/java/org/sonar/api/Plugin.java")
      .setSubProjectId(5L);
    when(componentDao.getNullableByKey(session, COMPONENT_KEY)).thenReturn(file);
    when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
    when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
    return file;
  }
View Full Code Here


  }

  @Test
  public void write_duplications() throws Exception {
    String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
    ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setSubProjectId(5L);
    String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
    ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setSubProjectId(5L);

    when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
    when(componentDao.getNullableByKey(session, key2)).thenReturn(file2);
    when(componentDao.getNullableById(5L, session)).thenReturn(new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"));
    when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);

    List<DuplicationsParser.Block> blocks = newArrayList();
    blocks.add(new DuplicationsParser.Block(newArrayList(
      new DuplicationsParser.Duplication(file1, 57, 12),
View Full Code Here

  }

  @Test
  public void write_duplications_without_sub_project() throws Exception {
    String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
    ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
    String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
    ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setKey(key2).setLongName("PropertyUpdateQuery");

    when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
    when(componentDao.getNullableByKey(session, key2)).thenReturn(file2);
    when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);
View Full Code Here

  }

  @Test
  public void write_duplications_with_a_removed_component() throws Exception {
    String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
    ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");

    when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
    when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);

    List<DuplicationsParser.Block> blocks = newArrayList();
View Full Code Here

  @Test
  public void show_duplications() throws Exception {
    String componentKey = "src/Foo.java";
    MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "org.codehaus.sonar:sonar", componentKey);

    ComponentDto componentDto = new ComponentDto().setId(10L);
    when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto);

    String data = "{duplications}";
    MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY);
    when(measureDao.getNullableByKey(session, measureKey)).thenReturn(
View Full Code Here

  @Test
  public void no_duplications_when_no_data() throws Exception {
    String componentKey = "src/Foo.java";
    MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "org.codehaus.sonar:sonar", componentKey);

    ComponentDto componentDto = new ComponentDto().setId(10L);
    when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto);

    MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY);
    when(measureDao.getNullableByKey(session, measureKey)).thenReturn(null);
View Full Code Here

    assertThat(duplication2.size()).isEqualTo(5);
  }

  @Test
  public void compare_duplications() throws Exception {
    ComponentDto currentFile = ComponentTesting.newFileDto(project1).setId(11L);
    ComponentDto fileOnSameProject = ComponentTesting.newFileDto(project1).setId(12L);
    ComponentDto fileOnDifferentProject = ComponentTesting.newFileDto(project2).setId(13L);

    DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile);

    // On same file
    assertThat(comparator.compare(new DuplicationsParser.Duplication(currentFile, 2, 2), new DuplicationsParser.Duplication(currentFile, 5, 2))).isEqualTo(-1);
    // Different files on same project
    assertThat(comparator.compare(new DuplicationsParser.Duplication(currentFile, 2, 2), new DuplicationsParser.Duplication(fileOnSameProject, 5, 2))).isEqualTo(-1);
    assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 2, 2), new DuplicationsParser.Duplication(currentFile, 5, 2))).isEqualTo(1);
    // Different files on different projects
    assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 5, 2), new DuplicationsParser.Duplication(fileOnDifferentProject, 2, 2))).isEqualTo(-1);
    assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(1);
    // Files on 2 different projects
    ComponentDto project3 = ComponentTesting.newProjectDto().setId(3L);
    assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2),
      new DuplicationsParser.Duplication(project3, 2, 2))).isEqualTo(1);

    // With null duplications
    assertThat(comparator.compare(null, new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(-1);
View Full Code Here

      MyBatis.closeQuietly(session);
    }
  }

  public static ComponentDto toComponent(ResourceDto resourceDto) {
    return new ComponentDto()
      .setId(resourceDto.getId())
      .setKey(resourceDto.getKey())
      .setPath(resourceDto.getPath())
      .setLongName(resourceDto.getLongName())
      .setName(resourceDto.getName())
View Full Code Here

  @Test
  public void show_issue() 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)
      .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 = new DefaultIssue()
      .setKey(issueKey)
      .setComponentKey("org.sonar.server.issue.IssueClient")
      .setComponentUuid(file.uuid())
      .setProjectKey("org.sonar.Sonar")
      .setProjectUuid(project.uuid())
      .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
      .setLine(12)
      .setMessage("Fix it")
View Full Code Here

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

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

    // Module
    ComponentDto module = ComponentTesting.newModuleDto(project)
      .setId(2L)
      .setKey("org.sonar.server.Server")
      .setLongName("SonarQube :: Server")
      .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

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.