use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.
the class GenerateActionTest method setUp.
@Before
public void setUp() {
when(tokenGenerator.generate()).thenReturn("123456789");
when(tokenGenerator.hash(anyString())).thenReturn("987654321");
db.users().insertUser(newUserDto().setLogin(GRACE_HOPPER));
db.users().insertUser(newUserDto().setLogin(ADA_LOVELACE));
ws = new WsActionTester(new GenerateAction(db.getDbClient(), userSession, System2.INSTANCE, tokenGenerator));
}
use of org.sonar.server.ws.WsActionTester in project sonarqube by SonarSource.
the class WebhookDeliveryActionTest method setUp.
@Before
public void setUp() {
ComponentFinder componentFinder = new ComponentFinder(dbClient);
WebhookDeliveryAction underTest = new WebhookDeliveryAction(dbClient, userSession, componentFinder);
ws = new WsActionTester(underTest);
project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("my-project"));
}
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));
}
Aggregations