use of org.sonar.server.exceptions.ServerException in project sonarqube by SonarSource.
the class RemovedWebServiceHandlerTest method throw_server_exception.
@Test
public void throw_server_exception() {
Request request = mock(Request.class);
when(request.getPath()).thenReturn("/api/resources/index");
try {
RemovedWebServiceHandler.INSTANCE.handle(request, null);
fail();
} catch (ServerException e) {
assertThat(e.getMessage()).isEqualTo("The web service '/api/resources/index' doesn't exist anymore, please read its documentation to use alternatives");
assertThat(e.httpCode()).isEqualTo(410);
}
}
use of org.sonar.server.exceptions.ServerException in project sonarqube by SonarSource.
the class GenerateAction method hashToken.
private String hashToken(DbSession dbSession, String token) {
String tokenHash = tokenGenerator.hash(token);
UserTokenDto userToken = dbClient.userTokenDao().selectByTokenHash(dbSession, tokenHash);
if (userToken == null) {
return tokenHash;
}
throw new ServerException(HTTP_INTERNAL_ERROR, "Error while generating token. Please try again.");
}
Aggregations