Package org.sonar.core.component

Examples of org.sonar.core.component.ComponentDto


    assertThat(service.findByKey("struts")).isEqualTo(component);
  }

  @Test
  public void find_by_uuid() {
    ComponentDto component = new ComponentDto();
    when(componentService.getNullableByUuid("ABCD")).thenReturn(component);

    assertThat(service.findByUuid("ABCD")).isEqualTo(component);
  }
View Full Code Here


  public void create_component_and_index_it() {
    String componentKey = "new-project";
    String componentName = "New Project";
    String qualifier = Qualifiers.PROJECT;
    long componentId = Long.MAX_VALUE;
    ComponentDto component = mock(ComponentDto.class);
    when(component.getId()).thenReturn(componentId);
    when(resourceDao.findByKey(componentKey)).thenReturn(null).thenReturn(component);

    service.createComponent(componentKey, componentName, qualifier);

    ArgumentCaptor<ResourceDto> resourceCaptor = ArgumentCaptor.forClass(ResourceDto.class);
View Full Code Here

  public void not_create_component_on_sub_views() {
    String componentKey = "new-project";
    String componentName = "New Project";
    String qualifier = Qualifiers.SUBVIEW;
    long componentId = Long.MAX_VALUE;
    ComponentDto component = mock(ComponentDto.class);
    when(component.getId()).thenReturn(componentId);
    when(resourceDao.findByKey(componentKey)).thenReturn(null).thenReturn(component);

    service.createComponent(componentKey, componentName, qualifier);

    verify(resourceDao, never()).insertOrUpdate(any(ResourceDto.class));
View Full Code Here

public class ComponentsFinderSortTest {

  @Test
  public void should_sort_by_asc_name() {
    List<? extends Component> dtoList = newArrayList(
      new ComponentDto().setKey("org.codehaus.sonar").setName("Sonar"),
      new ComponentDto().setKey("org.apache.tika:tika").setName("Apache Tika"),
      new ComponentDto().setKey("org.picocontainer:picocontainer-parent").setName("PicoContainer Parent"),
      new ComponentDto().setKey("org.codehaus.sample")
    );

    ComponentQuery query = ComponentQuery.builder().sort(ComponentQuery.SORT_BY_NAME).asc(true).build();
    ComponentsFinderSort finderSort = new ComponentsFinderSort(dtoList, query);
View Full Code Here

  }

  @Test
  public void should_sort_by_desc_name() {
    List<? extends Component> dtoList = newArrayList(
      new ComponentDto().setKey("org.codehaus.sonar").setName("Sonar"),
      new ComponentDto().setKey("org.apache.tika:tika").setName("Apache Tika"),
      new ComponentDto().setKey("org.picocontainer:picocontainer-parent").setName("PicoContainer Parent"),
      new ComponentDto().setKey("org.codehaus.sample")
    );

    ComponentQuery query = ComponentQuery.builder().sort(ComponentQuery.SORT_BY_NAME).asc(false).build();
    ComponentsFinderSort finderSort = new ComponentsFinderSort(dtoList, query);
View Full Code Here

  }

  @Test
  public void should_not_sort_with_null_sort() {
    List<? extends Component> dtoList = newArrayList(
      new ComponentDto().setKey("org.codehaus.sonar").setName("Sonar"),
      new ComponentDto().setKey("org.apache.tika:tika").setName("Apache Tika"),
      new ComponentDto().setKey("org.picocontainer:picocontainer-parent").setName("PicoContainer Parent"),
      new ComponentDto().setKey("org.codehaus.sample")
    );

    ComponentQuery query = ComponentQuery.builder().sort(null).build();
    ComponentsFinderSort finderSort = new ComponentsFinderSort(dtoList, query);
View Full Code Here

import java.util.UUID;

public class ComponentTesting {

  public static ComponentDto newFileDto(ComponentDto subProjectOrProject) {
    return new ComponentDto()
      .setUuid(UUID.randomUUID().toString())
      .setProjectUuid(subProjectOrProject.projectUuid())
      .setModuleUuid(subProjectOrProject.uuid())
      .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid())
      .setKey("file")
View Full Code Here

      .setLanguage("xoo")
      .setEnabled(true);
  }

  public static ComponentDto newModuleDto(ComponentDto subProjectOrProject) {
    return new ComponentDto()
      .setUuid(UUID.randomUUID().toString())
      .setProjectUuid(subProjectOrProject.projectUuid())
      .setModuleUuid(subProjectOrProject.uuid())
      .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid())
      .setKey("module")
View Full Code Here

      .setEnabled(true);
  }

  public static ComponentDto newProjectDto() {
    String uuid = UUID.randomUUID().toString();
    return new ComponentDto()
      .setUuid(uuid)
      .setProjectUuid(uuid)
      .setKey("project")
      .setName("Project")
      .setLongName("Project")
View Full Code Here

    session.close();
  }

  @Test
  public void delete_project() throws Exception {
    ComponentDto project = ComponentTesting.newProjectDto();
    db.componentDao().insert(session, project);
    session.commit();

    service.delete(project.getKey());

    assertThat(db.componentDao().getNullableByKey(session, project.key())).isNull();
  }
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.