Search in sources :

Example 16 with PropertyDto

use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.

the class ProjectDataLoaderMediumTest method return_sub_module_settings.

@Test
public void return_sub_module_settings() {
    OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
    dbClient.organizationDao().insert(dbSession, organizationDto);
    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
    dbClient.componentDao().insert(dbSession, project);
    addDefaultProfile();
    // No project properties
    ComponentDto module = ComponentTesting.newModuleDto(project);
    dbClient.componentDao().insert(dbSession, module);
    // No module properties
    ComponentDto subModule = ComponentTesting.newModuleDto(module);
    userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
    dbClient.componentDao().insert(dbSession, subModule);
    // Sub module properties
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(subModule.getId()));
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(subModule.getId()));
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId()));
    dbSession.commit();
    ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
    assertThat(ref.settings(project.key())).isEmpty();
    assertThat(ref.settings(module.key())).isEmpty();
    assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR", "sonar.jira.login.secured", "john", "sonar.coverage.exclusions", "**/*.java"));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) PropertyDto(org.sonar.db.property.PropertyDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 17 with PropertyDto

use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.

the class SettingsRepositoryTest method get_project_settings_from_db.

@Test
public void get_project_settings_from_db() {
    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
    dbClient.componentDao().insert(session, project);
    dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"));
    session.commit();
    Settings settings = underTest.getSettings(ROOT);
    assertThat(settings.getString("key")).isEqualTo("value");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) PropertyDto(org.sonar.db.property.PropertyDto) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 18 with PropertyDto

use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.

the class AddActionTest method add_a_file.

@Test
public void add_a_file() {
    ComponentDto project = insertProjectAndPermissions();
    ComponentDto file = db.components().insertComponent(newFileDto(project));
    userSession.addComponentUuidPermission(UserRole.USER, PROJECT_UUID, file.uuid());
    call(file.key());
    List<PropertyDto> favorites = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder().setUserId(USER_ID).setKey("favourite").build(), dbSession);
    assertThat(favorites).hasSize(1);
    PropertyDto favorite = favorites.get(0);
    assertThat(favorite).extracting(PropertyDto::getResourceId, PropertyDto::getUserId, PropertyDto::getKey).containsOnly(file.getId(), USER_ID, "favourite");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) PropertyDto(org.sonar.db.property.PropertyDto) Test(org.junit.Test)

Example 19 with PropertyDto

use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.

the class StartupMetadataPersisterTest method assertPersistedProperty.

private void assertPersistedProperty(String propertyKey, String expectedValue) {
    PropertyDto prop = dbTester.getDbClient().propertiesDao().selectGlobalProperty(dbTester.getSession(), propertyKey);
    assertThat(prop.getValue()).isEqualTo(expectedValue);
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Example 20 with PropertyDto

use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.

the class GetByProjectActionTest method setDefaultQualityGate.

private void setDefaultQualityGate(long qualityGateId) {
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.qualitygate").setValue(String.valueOf(qualityGateId)));
    db.commit();
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Aggregations

PropertyDto (org.sonar.db.property.PropertyDto)57 Test (org.junit.Test)25 ComponentDto (org.sonar.db.component.ComponentDto)23 OrganizationDto (org.sonar.db.organization.OrganizationDto)13 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)13 DbSession (org.sonar.db.DbSession)8 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)6 MapSettings (org.sonar.api.config.MapSettings)3 Settings (org.sonar.api.config.Settings)3 PropertyTesting.newComponentPropertyDto (org.sonar.db.property.PropertyTesting.newComponentPropertyDto)2 PropertyTesting.newGlobalPropertyDto (org.sonar.db.property.PropertyTesting.newGlobalPropertyDto)2 UserDto (org.sonar.db.user.UserDto)2 Date (java.util.Date)1 Matchers.anyString (org.mockito.Matchers.anyString)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 FilePathWithHashDto (org.sonar.db.component.FilePathWithHashDto)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 PropertyQuery (org.sonar.db.property.PropertyQuery)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1 TestResponse (org.sonar.server.ws.TestResponse)1