Search in sources :

Example 1 with ComponentDao

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)));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) HtmlSourceDecorator(org.sonar.server.source.HtmlSourceDecorator) WsTester(org.sonar.server.ws.WsTester) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.anyString(org.mockito.Matchers.anyString) SourceService(org.sonar.server.source.SourceService) ComponentDao(org.sonar.db.component.ComponentDao) Before(org.junit.Before)

Example 2 with ComponentDao

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"));
}
Also used : OrganizationDto(org.sonar.db.organization.OrganizationDto) ComponentDao(org.sonar.db.component.ComponentDao) Test(org.junit.Test)

Aggregations

ComponentDao (org.sonar.db.component.ComponentDao)2 Before (org.junit.Before)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 ComponentFinder (org.sonar.server.component.ComponentFinder)1 HtmlSourceDecorator (org.sonar.server.source.HtmlSourceDecorator)1 SourceService (org.sonar.server.source.SourceService)1 WsTester (org.sonar.server.ws.WsTester)1