Search in sources :

Example 1 with SearchWsResponse

use of org.sonarqube.ws.WsUserTokens.SearchWsResponse in project sonarqube by SonarSource.

the class SearchAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    SearchWsResponse searchWsResponse = doHandle(toSearchWsRequest(request));
    writeProtobuf(searchWsResponse, request, response);
}
Also used : SearchWsResponse(org.sonarqube.ws.WsUserTokens.SearchWsResponse)

Example 2 with SearchWsResponse

use of org.sonarqube.ws.WsUserTokens.SearchWsResponse in project sonarqube by SonarSource.

the class SearchAction method buildResponse.

private static SearchWsResponse buildResponse(String login, List<UserTokenDto> userTokensDto) {
    SearchWsResponse.Builder searchWsResponse = SearchWsResponse.newBuilder();
    SearchWsResponse.UserToken.Builder userTokenBuilder = SearchWsResponse.UserToken.newBuilder();
    searchWsResponse.setLogin(login);
    for (UserTokenDto userTokenDto : userTokensDto) {
        userTokenBuilder.clear().setName(userTokenDto.getName()).setCreatedAt(formatDateTime(new Date(userTokenDto.getCreatedAt())));
        searchWsResponse.addUserTokens(userTokenBuilder);
    }
    return searchWsResponse.build();
}
Also used : SearchWsResponse(org.sonarqube.ws.WsUserTokens.SearchWsResponse) UserTokenDto(org.sonar.db.user.UserTokenDto) Date(java.util.Date)

Example 3 with SearchWsResponse

use of org.sonarqube.ws.WsUserTokens.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method a_user_can_search_its_own_token.

@Test
public void a_user_can_search_its_own_token() {
    userSession.logIn(GRACE_HOPPER);
    dbClient.userTokenDao().insert(dbSession, newUserToken().setCreatedAt(1448523067221L).setName("Project scan on Travis").setLogin(GRACE_HOPPER));
    db.commit();
    SearchWsResponse response = newRequest(null);
    assertThat(response.getUserTokensCount()).isEqualTo(1);
}
Also used : SearchWsResponse(org.sonarqube.ws.WsUserTokens.SearchWsResponse) Test(org.junit.Test)

Aggregations

SearchWsResponse (org.sonarqube.ws.WsUserTokens.SearchWsResponse)3 Date (java.util.Date)1 Test (org.junit.Test)1 UserTokenDto (org.sonar.db.user.UserTokenDto)1