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);
}
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();
}
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);
}
Aggregations