use of org.sonar.db.component.ComponentDao in project sonarqube by SonarSource.
the class LinesActionTest method setUp.
@Before
public void setUp() {
htmlSourceDecorator = mock(HtmlSourceDecorator.class);
when(htmlSourceDecorator.getDecoratedSourceAsHtml(anyString(), anyString(), anyString())).then(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocationOnMock) throws Throwable {
return "<p>" + invocationOnMock.getArguments()[0] + "</p>";
}
});
sourceService = new SourceService(dbTester.getDbClient(), htmlSourceDecorator);
componentDao = new ComponentDao();
wsTester = new WsTester(new SourcesWs(new LinesAction(new ComponentFinder(dbTester.getDbClient()), dbTester.getDbClient(), sourceService, htmlSourceDecorator, userSessionRule)));
}
use of org.sonar.db.component.ComponentDao in project sonarqube by SonarSource.
the class SearchActionTest method search_nominal.
@Test
public void search_nominal() throws Exception {
when(activeRuleIndex.countAllByQualityProfileKey()).thenReturn(ImmutableMap.of("sonar-way-xoo1-12345", 11L, "my-sonar-way-xoo2-34567", 33L));
when(activeRuleIndex.countAllDeprecatedByQualityProfileKey()).thenReturn(ImmutableMap.of("sonar-way-xoo1-12345", 1L, "my-sonar-way-xoo2-34567", 2L));
OrganizationDto organizationDto = db.organizations().insert();
String organizationUuid = organizationDto.getUuid();
qualityProfileDao.insert(dbSession, QualityProfileDto.createFor("sonar-way-xoo1-12345").setOrganizationUuid(organizationUuid).setLanguage(xoo1.getKey()).setName("Sonar way").setDefault(true), QualityProfileDto.createFor("sonar-way-xoo2-23456").setOrganizationUuid(organizationUuid).setLanguage(xoo2.getKey()).setName("Sonar way"), QualityProfileDto.createFor("my-sonar-way-xoo2-34567").setOrganizationUuid(organizationUuid).setLanguage(xoo2.getKey()).setName("My Sonar way").setParentKee("sonar-way-xoo2-23456"), QualityProfileDto.createFor("sonar-way-other-666").setOrganizationUuid(organizationUuid).setLanguage("other").setName("Sonar way").setDefault(true));
new ComponentDao().insert(dbSession, newProjectDto(organizationDto, "project-uuid1"), newProjectDto(organizationDto, "project-uuid2"));
qualityProfileDao.insertProjectProfileAssociation("project-uuid1", "sonar-way-xoo2-23456", dbSession);
qualityProfileDao.insertProjectProfileAssociation("project-uuid2", "sonar-way-xoo2-23456", dbSession);
db.commit();
String result = ws.newRequest().execute().getInput();
assertJson(result).isSimilarTo(getClass().getResource("SearchActionTest/search.json"));
}
Aggregations