Search in sources :

Example 21 with WsActionTester

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

the class RemoveActionTest 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 });
    notificationUpdater = new NotificationUpdater(userSession, dbClient);
    underTest = new RemoveAction(notificationCenter, notificationUpdater, 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 22 with WsActionTester

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

the class CreateActionTest method setUp.

@Before
public void setUp() {
    ComponentFinder componentFinder = new ComponentFinder(dbClient);
    underTest = new CreateAction(dbClient, userSession, componentFinder);
    ws = new WsActionTester(underTest);
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 23 with WsActionTester

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

the class CreateEventActionTest method json_example.

@Test
public void json_example() {
    ComponentDto project = db.components().insertProject();
    SnapshotDto analysis = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(project).setUuid("A2"));
    db.commit();
    uuidFactory = mock(UuidFactory.class);
    when(uuidFactory.create()).thenReturn("E1");
    ws = new WsActionTester(new CreateEventAction(dbClient, uuidFactory, system, userSession));
    logInAsProjectAdministrator(project);
    String result = ws.newRequest().setParam(PARAM_ANALYSIS, analysis.getUuid()).setParam(PARAM_CATEGORY, OTHER.name()).setParam(PARAM_NAME, "My Custom Event").execute().getInput();
    assertJson(result).isSimilarTo(getClass().getResource("create_event-example.json"));
}
Also used : UuidFactory(org.sonar.core.util.UuidFactory) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) WsActionTester(org.sonar.server.ws.WsActionTester) Test(org.junit.Test)

Example 24 with WsActionTester

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

the class SearchMyProjectsActionTest method setUp.

@Before
public void setUp() {
    user = db.users().insertUser();
    userSession.logIn(user);
    alertStatusMetric = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(ALERT_STATUS_KEY).setValueType(ValueType.LEVEL.name()));
    db.commit();
    ws = new WsActionTester(new SearchMyProjectsAction(dbClient, new SearchMyProjectsDataLoader(userSession, dbClient), userSession));
}
Also used : WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 25 with WsActionTester

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

the class ProjectStatusActionTest method setUp.

@Before
public void setUp() {
    dbClient = db.getDbClient();
    dbSession = db.getSession();
    ws = new WsActionTester(new ProjectStatusAction(dbClient, new ComponentFinder(dbClient), userSession));
}
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