use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class AppActionTest method should_generate_app_init_info.
@Test
public void should_generate_app_init_info() throws Exception {
AppAction app = new AppAction(languages, db.getDbClient(), i18n, userSessionRule, defaultOrganizationProvider);
WsTester tester = new WsTester(new RulesWs(app));
userSessionRule.addPermission(ADMINISTER_QUALITY_PROFILES, defaultOrganizationProvider.get().getUuid());
QualityProfileDto profile1 = QProfileTesting.newXooP1("org-123");
QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123").setParentKee(QProfileTesting.XOO_P1_KEY);
db.getDbClient().qualityProfileDao().insert(db.getSession(), profile1);
db.getDbClient().qualityProfileDao().insert(db.getSession(), profile2);
db.commit();
Language xoo = mock(Language.class);
when(xoo.getKey()).thenReturn("xoo");
when(xoo.getName()).thenReturn("Xoo");
Language whitespace = mock(Language.class);
when(whitespace.getKey()).thenReturn("ws");
when(whitespace.getName()).thenReturn("Whitespace");
when(languages.get("xoo")).thenReturn(xoo);
when(languages.all()).thenReturn(new Language[] { xoo, whitespace });
RuleRepositoryDto repo1 = new RuleRepositoryDto("xoo", "xoo", "SonarQube");
RuleRepositoryDto repo2 = new RuleRepositoryDto("squid", "ws", "SonarQube");
db.getDbClient().ruleRepositoryDao().insert(db.getSession(), asList(repo1, repo2));
db.getSession().commit();
when(i18n.message(isA(Locale.class), anyString(), anyString())).thenAnswer(invocation -> invocation.getArguments()[1]);
tester.newGetRequest("api/rules", "app").execute().assertJson(this.getClass(), "app.json");
}
use of org.sonar.server.ws.WsTester 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.server.ws.WsTester in project sonarqube by SonarSource.
the class IssuesActionTest method before.
@Before
public void before() {
IssueIndex issueIndex = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
IssuesAction issuesAction = new IssuesAction(db.getDbClient(), issueIndex, userSessionRule, new ComponentFinder(db.getDbClient()));
tester = new WsTester(new BatchWs(issuesAction));
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class UsersActionTest method before.
@Before
public void before() {
userIndex = new UserIndex(es.client());
usersAction = new UsersAction(userIndex, userSessionRule);
tester = new WsTester(new BatchWs(usersAction));
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class AppActionTest method setUp.
@Before
public void setUp() {
insertMetrics();
wsTester = new WsTester(new ComponentsWs(new AppAction(dbTester.getDbClient(), userSessionRule, new ComponentFinder(dbTester.getDbClient())), mock(SuggestionsAction.class)));
}
Aggregations