Examples of ResourceDto


Examples of org.sonar.core.resource.ResourceDto

  // SONAR-4692
  @Test
  public void not_fail_if_module_part_of_same_project() throws Exception {
    String rootProjectKey = "project-key";
    String moduleKey = "module-key";
    ResourceDto rootResource = mock(ResourceDto.class);

    when(rootResource.getKey()).thenReturn(rootProjectKey);

    when(resourceDao.getRootProjectByComponentKey(moduleKey)).thenReturn(rootResource);
    ProjectReactor reactor = createProjectReactor(rootProjectKey);
    reactor.getRoot().addSubProject(ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, moduleKey));
    validator.validate(reactor);
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  // SONAR-4245
  @Test
  public void shouldFailWhenTryingToConvertProjectIntoModule() {
    String rootProjectKey = "project-key";
    String moduleKey = "module-key";
    ResourceDto rootResource = mock(ResourceDto.class);

    when(rootResource.getKey()).thenReturn(moduleKey);

    when(resourceDao.getRootProjectByComponentKey(moduleKey)).thenReturn(rootResource);

    ProjectReactor reactor = createProjectReactor(rootProjectKey);
    reactor.getRoot().addSubProject(ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, moduleKey));
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  @Nullable
  private Long componentId(String componentKey) {
    if (componentKey == null) {
      return null;
    } else {
      ResourceDto resourceDto = resourceDao.getResource(ResourceQuery.create().setKey(componentKey));
      if (resourceDto == null) {
        throw new NotFoundException(String.format("Component '%s' does not exist", componentKey));
      }
      return resourceDto.getId();
    }
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  @CheckForNull
  public List<String> getSourceAsHtml(String componentKey, @Nullable Integer from, @Nullable Integer to) {
    DbSession session = mybatis.openSession(false);
    try {
      ResourceDto component = resourceDao.getResource(ResourceQuery.create().setKey(componentKey), session);
      if (component == null) {
        throw new NotFoundException("The component '" + componentKey + "' does not exists.");
      }
      String source = snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session);
      if (source != null) {
        return splitSourceByLine(source, component.getLanguage(), from, to);
      } else {
        return null;
      }
    } finally {
      MyBatis.closeQuietly(session);
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

      }
      checkKeyFormat(qualifier, kee);

      String uuid = UUID.randomUUID().toString();
      resourceDao.insertOrUpdate(
        new ResourceDto()
          .setUuid(uuid)
          .setProjectUuid(uuid)
          .setKey(kee)
          .setDeprecatedKey(kee)
          .setName(name)
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    }
    return null;
  }

  public void updateComponent(Long id, String key, String name) {
    ResourceDto resource = resourceDao.getResource(id);
    if (resource == null) {
      throw new NotFoundException();
    }
    checkKeyFormat(resource.getQualifier(), key);

    resourceDao.insertOrUpdate(resource.setKey(key).setName(name));
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  private void checkProject(String projectParam, Result<ActionPlan> result) {
    if (Strings.isNullOrEmpty(projectParam)) {
      result.addError(Result.Message.ofL10n(Validation.CANT_BE_EMPTY_MESSAGE, PROJECT_PARAM));
    } else {
      ResourceDto project = resourceDao.getResource(ResourceQuery.create().setKey(projectParam));
      if (project == null) {
        result.addError(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", projectParam));
      }
    }
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

   * Does the user have the given project permission for a component ?
   */
  public boolean hasComponentPermission(String permission, String componentKey) {
    String projectKey = projectKeyByComponentKey.get(componentKey);
    if (projectKey == null) {
      ResourceDto project = resourceDao().getRootProjectByComponentKey(componentKey);
      if (project == null) {
        return false;
      }
      projectKey = project.getKey();
    }
    boolean hasComponentPermission = hasProjectPermission(permission, projectKey);
    if (hasComponentPermission) {
      projectKeyByComponentKey.put(componentKey, projectKey);
      return true;
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    service.createComponent(componentKey, componentName, qualifier);

    ArgumentCaptor<ResourceDto> resourceCaptor = ArgumentCaptor.forClass(ResourceDto.class);
    verify(resourceDao).insertOrUpdate(resourceCaptor.capture());
    ResourceDto created = resourceCaptor.getValue();
    assertThat(created.getUuid()).isNotNull();
    assertThat(created.getProjectUuid()).isEqualTo(created.getUuid());
    assertThat(created.getKey()).isEqualTo(componentKey);
    assertThat(created.getName()).isEqualTo(componentName);
    assertThat(created.getLongName()).isEqualTo(componentName);
    assertThat(created.getScope()).isEqualTo(Scopes.PROJECT);
    assertThat(created.getQualifier()).isEqualTo(qualifier);
    verify(resourceDao, times(2)).findByKey(componentKey);
    verify(resourceIndexerDao).indexResource(componentId);
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  @Test
  public void should_update_component() {
    final long componentId = 1234l;
    final String newKey = "newKey";
    final String newName = "newName";
    ResourceDto resource = mock(ResourceDto.class);
    when(resourceDao.getResource(componentId)).thenReturn(resource);
    when(resource.setKey(newKey)).thenReturn(resource);
    when(resource.setName(newName)).thenReturn(resource);
    service.updateComponent(componentId, newKey, newName);
    verify(resource).setKey(newKey);
    verify(resource).setName(newName);
    verify(resourceDao).insertOrUpdate(resource);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.