Search in sources :

Example 1 with ListDefinitionsWsResponse

use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.

the class ListDefinitionsAction method handle.

@Override
public void handle(Request request, Response response) {
    userSession.checkIsSystemAdministrator();
    ListDefinitionsWsResponse wsResponse = doHandle();
    writeProtobuf(wsResponse, request, response);
}
Also used : ListDefinitionsWsResponse(org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse)

Example 2 with ListDefinitionsWsResponse

use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.

the class ListDefinitionsActionTest method list_is_ordered_by_create_date.

@Test
public void list_is_ordered_by_create_date() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    when(system2.now()).thenReturn(10_000_000_000L);
    AlmSettingDto almSetting1 = db.almSettings().insertGitHubAlmSetting();
    when(system2.now()).thenReturn(30_000_000_000L);
    AlmSettingDto almSetting2 = db.almSettings().insertGitHubAlmSetting();
    when(system2.now()).thenReturn(20_000_000_000L);
    AlmSettingDto almSetting3 = db.almSettings().insertGitHubAlmSetting();
    ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
    assertThat(wsResponse.getGithubList()).extracting(AlmSettingGithub::getKey).containsExactly(almSetting1.getKey(), almSetting3.getKey(), almSetting2.getKey());
}
Also used : ListDefinitionsWsResponse(org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 3 with ListDefinitionsWsResponse

use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.

the class ListDefinitionsActionTest method list_bitbucket_cloud_settings.

@Test
public void list_bitbucket_cloud_settings() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSetting1 = db.almSettings().insertBitbucketCloudAlmSetting(alm -> alm.setClientId("1").setClientSecret("2"));
    AlmSettingDto almSetting2 = db.almSettings().insertBitbucketCloudAlmSetting(alm -> alm.setClientId("client_id").setClientSecret("client_secret"));
    ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
    assertThat(wsResponse.getBitbucketcloudList()).extracting(AlmSettings.AlmSettingBitbucketCloud::getKey, AlmSettings.AlmSettingBitbucketCloud::getClientId).containsExactlyInAnyOrder(tuple(almSetting1.getKey(), "1"), tuple(almSetting2.getKey(), "client_id"));
}
Also used : ListDefinitionsWsResponse(org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse) UserDto(org.sonar.db.user.UserDto) AlmSettings(org.sonarqube.ws.AlmSettings) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 4 with ListDefinitionsWsResponse

use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.

the class ListDefinitionsActionTest method list_github_settings.

@Test
public void list_github_settings() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    AlmSettingDto almSetting1 = db.almSettings().insertGitHubAlmSetting(s -> s.setClientId(""));
    AlmSettingDto almSetting2 = db.almSettings().insertGitHubAlmSetting(alm -> alm.setClientId("client_id").setClientSecret("client_secret"));
    ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
    assertThat(wsResponse.getGithubList()).extracting(AlmSettingGithub::getKey, AlmSettingGithub::getUrl, AlmSettingGithub::getAppId, AlmSettingGithub::getClientId).containsExactlyInAnyOrder(tuple(almSetting1.getKey(), almSetting1.getUrl(), almSetting1.getAppId(), ""), tuple(almSetting2.getKey(), almSetting2.getUrl(), almSetting2.getAppId(), "client_id"));
}
Also used : ListDefinitionsWsResponse(org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse) UserDto(org.sonar.db.user.UserDto) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 5 with ListDefinitionsWsResponse

use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.

the class ListDefinitionsActionTest method return_empty_list_when_no_settings.

@Test
public void return_empty_list_when_no_settings() {
    UserDto user = db.users().insertUser();
    userSession.logIn(user).setSystemAdministrator();
    ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
    assertThat(wsResponse.getGithubList()).isEmpty();
}
Also used : ListDefinitionsWsResponse(org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse) UserDto(org.sonar.db.user.UserDto) Test(org.junit.Test)

Aggregations

ListDefinitionsWsResponse (org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse)7 Test (org.junit.Test)6 UserDto (org.sonar.db.user.UserDto)6 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)5 AlmSettings (org.sonarqube.ws.AlmSettings)1