Search in sources :

Example 1 with NewComponent

use of org.sonar.server.component.NewComponent in project sonarqube by SonarSource.

the class CreateActionTest method create_project_with_deprecated_parameter.

@Test
public void create_project_with_deprecated_parameter() throws Exception {
    OrganizationDto organization = db.organizations().insert();
    userSession.addPermission(PROVISION_PROJECTS, organization);
    ws.newRequest().setMethod(POST.name()).setParam("organization", organization.getKey()).setParam("key", DEFAULT_PROJECT_KEY).setParam(PARAM_NAME, DEFAULT_PROJECT_NAME).execute();
    NewComponent called = verifyCallToComponentUpdater();
    assertThat(called.key()).isEqualTo(DEFAULT_PROJECT_KEY);
    assertThat(called.branch()).isNull();
}
Also used : NewComponent(org.sonar.server.component.NewComponent) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 2 with NewComponent

use of org.sonar.server.component.NewComponent in project sonarqube by SonarSource.

the class CreateActionTest method create_project_with_branch.

@Test
public void create_project_with_branch() throws Exception {
    userSession.addPermission(PROVISION_PROJECTS, db.getDefaultOrganization());
    call(CreateRequest.builder().setKey(DEFAULT_PROJECT_KEY).setName(DEFAULT_PROJECT_NAME).setBranch("origin/master").build());
    NewComponent called = verifyCallToComponentUpdater();
    assertThat(called.key()).isEqualTo(DEFAULT_PROJECT_KEY);
    assertThat(called.branch()).isEqualTo("origin/master");
}
Also used : NewComponent(org.sonar.server.component.NewComponent) Test(org.junit.Test)

Example 3 with NewComponent

use of org.sonar.server.component.NewComponent in project sonarqube by SonarSource.

the class ReportSubmitter method createProject.

private ComponentDto createProject(DbSession dbSession, OrganizationDto organization, String projectKey, @Nullable String projectBranch, @Nullable String projectName) {
    userSession.checkPermission(OrganizationPermission.PROVISION_PROJECTS, organization);
    Integer userId = userSession.getUserId();
    boolean wouldCurrentUserHaveScanPermission = permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(dbSession, organization.getUuid(), userId, projectBranch, projectKey, Qualifiers.PROJECT);
    if (!wouldCurrentUserHaveScanPermission) {
        throw insufficientPrivilegesException();
    }
    NewComponent newProject = newComponentBuilder().setOrganizationUuid(organization.getUuid()).setKey(projectKey).setName(StringUtils.defaultIfBlank(projectName, projectKey)).setBranch(projectBranch).setQualifier(Qualifiers.PROJECT).build();
    return componentUpdater.create(dbSession, newProject, userId);
}
Also used : NewComponent(org.sonar.server.component.NewComponent)

Aggregations

NewComponent (org.sonar.server.component.NewComponent)3 Test (org.junit.Test)2 OrganizationDto (org.sonar.db.organization.OrganizationDto)1