Search in sources :

Example 1 with WsActionTester

use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method do_not_return_module_key_on_single_module_projects.

@Test
public void do_not_return_module_key_on_single_module_projects() throws IOException {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
    ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
    RuleDto newRule = newRule();
    IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
    IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
    db.issueDao().insert(session, issueInModule, issueInRootModule);
    session.commit();
    indexIssues();
    WsActionTester actionTester = new WsActionTester(tester.get(SearchAction.class));
    TestResponse response = actionTester.newRequest().setMediaType(MediaTypes.PROTOBUF).execute();
    SearchWsResponse searchResponse = SearchWsResponse.parseFrom(response.getInputStream());
    assertThat(searchResponse.getIssuesCount()).isEqualTo(2);
    for (Issues.Issue issue : searchResponse.getIssuesList()) {
        assertThat(issue.getProject()).isEqualTo("PK1");
        if (issue.getKey().equals("ISSUE_IN_MODULE")) {
            assertThat(issue.getSubProject()).isEqualTo("MK1");
        } else if (issue.getKey().equals("ISSUE_IN_ROOT_MODULE")) {
            assertThat(issue.hasSubProject()).isFalse();
        }
    }
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) TestResponse(org.sonar.server.ws.TestResponse) Issues(org.sonarqube.ws.Issues) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse) WsActionTester(org.sonar.server.ws.WsActionTester) Test(org.junit.Test)

Example 2 with WsActionTester

use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.

the class AddActionTest method setUp.

@Before
public void setUp() {
    NotificationDispatcherMetadata metadata1 = NotificationDispatcherMetadata.create(NOTIF_MY_NEW_ISSUES).setProperty(GLOBAL_NOTIFICATION, "true").setProperty(PER_PROJECT_NOTIFICATION, "true");
    NotificationDispatcherMetadata metadata2 = NotificationDispatcherMetadata.create(NOTIF_NEW_ISSUES).setProperty(GLOBAL_NOTIFICATION, "true");
    NotificationDispatcherMetadata metadata3 = NotificationDispatcherMetadata.create(NOTIF_NEW_QUALITY_GATE_STATUS).setProperty(GLOBAL_NOTIFICATION, "true").setProperty(PER_PROJECT_NOTIFICATION, "true");
    notificationCenter = new NotificationCenter(new NotificationDispatcherMetadata[] { metadata1, metadata2, metadata3 }, new NotificationChannel[] { emailChannel, twitterChannel, defaultChannel });
    underTest = new AddAction(notificationCenter, new NotificationUpdater(userSession, dbClient), dbClient, new ComponentFinder(dbClient), userSession);
    ws = new WsActionTester(underTest);
}
Also used : NotificationChannel(org.sonar.api.notifications.NotificationChannel) ComponentFinder(org.sonar.server.component.ComponentFinder) NotificationCenter(org.sonar.server.notification.NotificationCenter) NotificationDispatcherMetadata(org.sonar.server.notification.NotificationDispatcherMetadata) NotificationUpdater(org.sonar.server.notification.NotificationUpdater) WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 3 with WsActionTester

use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.

the class DeleteTemplateActionTest method setUp.

@Before
public void setUp() throws Exception {
    GroupWsSupport groupWsSupport = new GroupWsSupport(dbClient, TestDefaultOrganizationProvider.from(db));
    this.underTestWithoutViews = new WsActionTester(new DeleteTemplateAction(dbClient, userSession, new PermissionWsSupport(dbClient, new ComponentFinder(dbClient), groupWsSupport, resourceTypes), defaultTemplatesResolver));
    this.underTestWithViews = new WsActionTester(new DeleteTemplateAction(dbClient, userSession, new PermissionWsSupport(dbClient, new ComponentFinder(dbClient), groupWsSupport, resourceTypesWithViews), defaultTemplatesResolverWithViews));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) PermissionWsSupport(org.sonar.server.permission.ws.PermissionWsSupport) GroupWsSupport(org.sonar.server.usergroups.ws.GroupWsSupport) WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 4 with WsActionTester

use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.

the class SearchTemplatesActionTest method setUp.

@Before
public void setUp() {
    DefaultTemplatesResolver defaultTemplatesResolverWithViews = new DefaultTemplatesResolverImpl(resourceTypesWithoutViews);
    SearchTemplatesDataLoader dataLoaderWithViews = new SearchTemplatesDataLoader(dbClient, defaultTemplatesResolverWithViews);
    underTestWithoutViews = new WsActionTester(new SearchTemplatesAction(dbClient, userSession, i18n, newPermissionWsSupport(), dataLoaderWithViews));
    i18n.setProjectPermissions();
    userSession.logIn().addPermission(ADMINISTER, db.getDefaultOrganization());
}
Also used : WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 5 with WsActionTester

use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.

the class SelectActionTest method setUp.

@Before
public void setUp() {
    ComponentFinder componentFinder = new ComponentFinder(dbClient);
    underTest = new SelectAction(dbClient, userSession, componentFinder);
    ws = new WsActionTester(underTest);
    project = db.components().insertProject();
    gate = insertQualityGate();
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Aggregations

WsActionTester (org.sonar.server.ws.WsActionTester)27 Before (org.junit.Before)21 ComponentFinder (org.sonar.server.component.ComponentFinder)13 Page (org.sonar.api.web.page.Page)3 PluginRepository (org.sonar.core.platform.PluginRepository)3 NotificationCenter (org.sonar.server.notification.NotificationCenter)3 NotificationDispatcherMetadata (org.sonar.server.notification.NotificationDispatcherMetadata)3 NotificationUpdater (org.sonar.server.notification.NotificationUpdater)3 PageRepository (org.sonar.server.ui.PageRepository)3 Test (org.junit.Test)2 NotificationChannel (org.sonar.api.notifications.NotificationChannel)2 ComponentDto (org.sonar.db.component.ComponentDto)2 I18n (org.sonar.api.i18n.I18n)1 Languages (org.sonar.api.resources.Languages)1 ResourceTypes (org.sonar.api.resources.ResourceTypes)1 UuidFactory (org.sonar.core.util.UuidFactory)1 DbClient (org.sonar.db.DbClient)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 H2 (org.sonar.db.dialect.H2)1 IssueDto (org.sonar.db.issue.IssueDto)1