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();
}
}
}
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);
}
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));
}
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());
}
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();
}
Aggregations