Search in sources :

Example 41 with PropertyDto

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

the class ProjectDataLoaderMediumTest method not_returned_secured_settings_when_lgged_but_no_scan_permission.

@Test
public void not_returned_secured_settings_when_lgged_but_no_scan_permission() {
    OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
    dbClient.organizationDao().insert(dbSession, organizationDto);
    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
    userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
    dbClient.componentDao().insert(dbSession, project);
    addDefaultProfile();
    // Project properties
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()));
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
    dbSession.commit();
    ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
    Map<String, String> projectSettings = ref.settings(project.key());
    assertThat(projectSettings).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR"));
}
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 42 with PropertyDto

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

the class AddActionTest method add_a_project.

@Test
public void add_a_project() {
    ComponentDto project = insertProjectAndPermissions();
    TestResponse result = call(PROJECT_KEY);
    assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT);
    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(project.getId(), USER_ID, "favourite");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) ComponentDto(org.sonar.db.component.ComponentDto) PropertyDto(org.sonar.db.property.PropertyDto) Test(org.junit.Test)

Example 43 with PropertyDto

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

the class ServerIdManagerTest method insertPropertyCoreId.

private void insertPropertyCoreId(String value) {
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(CoreProperties.SERVER_ID).setValue(value));
    dbSession.commit();
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Example 44 with PropertyDto

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

the class StartupMetadataProviderTest method assertNotPersistedProperty.

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

Example 45 with PropertyDto

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

the class StartupMetadataProviderTest 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)

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