use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method does_not_return_non_active_projects.
@Test
public void does_not_return_non_active_projects() throws Exception {
// Disabled project
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
// Disabled project with analysis
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
// A view
dbTester.components().insertProjectAndSnapshot(newView(dbTester.getDefaultOrganization()));
// A developer
dbTester.components().insertProjectAndSnapshot(newDeveloper(dbTester.getDefaultOrganization(), "dev"));
dbSession.commit();
assertResultSetIsEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_language_distribution_measure.
@Test
public void return_language_distribution_measure() throws Exception {
MetricDto metric = insertMetric("ncloc_language_distribution", DATA);
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
insertMeasure(project, analysis, metric, "<null>=2;java=6;xoo=18");
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById.get(project.uuid()).getMeasures().getLanguages()).containsOnly("<null>", "java", "xoo");
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PropertiesDaoTest method shouldFindUsersForNotification.
@Test
public void shouldFindUsersForNotification() throws SQLException {
ComponentDto project1 = insertProject("uuid_45");
ComponentDto project2 = insertProject("uuid_56");
int userId1 = insertUser("user1");
int userId2 = insertUser("user2");
int userId3 = insertUser("user3");
insertProperty("notification.NewViolations.Email", "true", project1.getId(), userId2);
insertProperty("notification.NewViolations.Twitter", "true", null, userId3);
insertProperty("notification.NewViolations.Twitter", "true", project2.getId(), userId1);
insertProperty("notification.NewViolations.Twitter", "true", project2.getId(), userId3);
assertThat(underTest.selectUsersForNotification("NewViolations", "Email", null)).isEmpty();
assertThat(underTest.selectUsersForNotification("NewViolations", "Email", "uuid_78")).isEmpty();
assertThat(underTest.selectUsersForNotification("NewViolations", "Email", "uuid_45")).hasSize(1).containsOnly("user2");
assertThat(underTest.selectUsersForNotification("NewViolations", "Twitter", null)).hasSize(1).containsOnly("user3");
assertThat(underTest.selectUsersForNotification("NewViolations", "Twitter", "uuid_78")).isEmpty();
assertThat(underTest.selectUsersForNotification("NewViolations", "Twitter", "uuid_56")).hasSize(2).containsOnly("user1", "user3");
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PropertiesDaoTest method select_properties_by_keys_and_component_ids.
@Test
public void select_properties_by_keys_and_component_ids() throws Exception {
ComponentDto project = dbTester.components().insertProject();
ComponentDto project2 = dbTester.components().insertProject();
UserDto user = UserTesting.newUserDto();
dbClient.userDao().insert(session, user);
String key = "key";
String anotherKey = "anotherKey";
insertProperties(newGlobalPropertyDto().setKey(key), newComponentPropertyDto(project).setKey(key), newComponentPropertyDto(project2).setKey(key), newComponentPropertyDto(project2).setKey(anotherKey), newUserPropertyDto(user).setKey(key));
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet(key), newHashSet(project.getId()))).extracting("key", "resourceId").containsOnly(tuple(key, project.getId()));
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet(key), newHashSet(project.getId(), project2.getId()))).extracting("key", "resourceId").containsOnly(tuple(key, project.getId()), tuple(key, project2.getId()));
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet(key, anotherKey), newHashSet(project.getId(), project2.getId()))).extracting("key", "resourceId").containsOnly(tuple(key, project.getId()), tuple(key, project2.getId()), tuple(anotherKey, project2.getId()));
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet("unknown"), newHashSet(project.getId()))).isEmpty();
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet("key"), newHashSet(123456789L))).isEmpty();
assertThat(underTest.selectPropertiesByKeysAndComponentIds(session, newHashSet("unknown"), newHashSet(123456789L))).isEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class EventDaoTest method select_by_analysis_uuid.
@Test
public void select_by_analysis_uuid() {
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
SnapshotDto otherAnalysis = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbTester.commit();
dbTester.events().insertEvent(newEvent(analysis).setUuid("A1"));
dbTester.events().insertEvent(newEvent(otherAnalysis).setUuid("O1"));
dbTester.events().insertEvent(newEvent(analysis).setUuid("A2"));
dbTester.events().insertEvent(newEvent(otherAnalysis).setUuid("O2"));
dbTester.events().insertEvent(newEvent(analysis).setUuid("A3"));
dbTester.events().insertEvent(newEvent(otherAnalysis).setUuid("O3"));
List<EventDto> result = underTest.selectByAnalysisUuid(dbSession, analysis.getUuid());
assertThat(result).hasSize(3);
assertThat(result).extracting(EventDto::getUuid).containsOnly("A1", "A2", "A3");
}
Aggregations