Package org.sonar.core.resource

Examples of org.sonar.core.resource.ResourceDto


  @Before
  public void before() throws Exception {
    this.purgeDao = mock(PurgeDao.class);
    this.resourceDao = mock(ResourceDao.class);
    when(resourceDao.getResource(anyLong())).thenReturn(new ResourceDto().setQualifier(Qualifiers.PROJECT));

    this.settings = mock(Settings.class);
    this.periodCleaner = mock(DefaultPeriodCleaner.class);
    this.profiler = mock(PurgeProfiler.class);
View Full Code Here


  @Test
  public void shouldInsertAuthorAndDeveloper() throws Exception {
    setupData("shouldInsertAuthorAndDeveloper");

    String login = "developer@company.net";
    ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD");
    dao.insertAuthorAndDeveloper(login, resourceDto);

    checkTables("shouldInsertAuthorAndDeveloper",
      new String[] {"created_at", "updated_at", "copy_resource_id", "description", "enabled", "kee", "deprecated_kee", "path", "language", "long_name", "person_id", "root_id",
        "scope", "authorization_updated_at"},
View Full Code Here

  @Test
  public void shouldPreventAuthorsAndDevelopersDuplication() throws Exception {
    setupData("shouldPreventAuthorsAndDevelopersDuplication");

    String login = "developer@company.net";
    ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV");

    try {
      dao.insertAuthorAndDeveloper("developer@company.net", resourceDto);
      fail();
    } catch (RuntimeException ex) {
View Full Code Here

    if (snapshot != null) {
      return snapshot.getResourceId();
    }

    // Load from db when component does not exist in cache (deleted file for example)
    ResourceDto resourceDto = resourceDao.getResource(ResourceQuery.create().setKey(issue.componentKey()));
    if (resourceDto == null) {
      throw new IllegalStateException("Unknown component: " + issue.componentKey());
    }
    return resourceDto.getId();
  }
View Full Code Here

      validationMessages.add(String.format("\"%s\" is not a valid project or module key. "
        + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", moduleDef.getKey()));
    } else if (isSubProject(moduleDef)) {
      // SONAR-4692 Validate root project is the same than previous analysis to avoid module with same key in different projects
      String moduleKey = ComponentKeys.createKey(moduleDef.getKey(), branch);
      ResourceDto rootInDB = resourceDao.getRootProjectByComponentKey(moduleKey);
      if (rootInDB == null || Qualifiers.LIBRARY.equals(rootInDB.getQualifier())) {
        // This is a new module or previously a library so OK
        return;
      }
      if (rootInDB.getKey().equals(moduleKey)) {
        // SONAR-4245 current subproject is actually a root project in SQ DB
        throw new SonarException(
          String.format("The project '%s' is already defined in SonarQube but not as a module of project '%s'. "
            + "If you really want to stop directly analysing project '%s', please first delete it from SonarQube and then relaunch the analysis of project '%s'.",
            moduleKey, rootProjectKey, moduleKey, rootProjectKey));
      }
      if (!rootProjectKey.equals(rootInDB.getKey())) {
        // SONAR-4692 current subproject is already a subproject in another project
        throw new SonarException(String.format("Module \"%s\" is already part of project \"%s\"", moduleDef.getKey(), rootInDB.getKey()));
      }
    }
  }
View Full Code Here

  public List<String> selectUserPermissions(DbSession session, String user, @Nullable Long componentId) {
    return roleDao.selectUserPermissions(session, user, componentId);
  }

  public void grantDefaultRoles(DbSession session, Long componentId, String qualifier) {
    ResourceDto resource = resourceDao.getResource(componentId, session);
    if (resource == null) {
      throw new IllegalStateException("Unable to find resource with id " + componentId);
    }
    String applicablePermissionTemplateKey = getApplicablePermissionTemplateKey(session, resource.getKey(), qualifier);
    applyPermissionTemplate(session, applicablePermissionTemplateKey, componentId);
  }
View Full Code Here

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

    when(rootResource.getKey()).thenReturn("another-project-key");

    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

  // 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

  // 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

  @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

TOP

Related Classes of org.sonar.core.resource.ResourceDto

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.