use of org.sonar.server.es.EsClient in project sonarqube by SonarSource.
the class EsMonitorTest method attributes_displays_cause_message_when_cause_is_ElasticSearchException_when_client_fails.
@Test
public void attributes_displays_cause_message_when_cause_is_ElasticSearchException_when_client_fails() {
EsClient esClientMock = mock(EsClient.class);
EsMonitor underTest = new EsMonitor(esClientMock);
when(esClientMock.prepareClusterStats()).thenThrow(new RuntimeException("RuntimeException with ES cause", new ElasticsearchException("some cause message")));
Map<String, Object> attributes = underTest.attributes();
assertThat(attributes).hasSize(1);
assertThat(attributes.get("State")).isEqualTo("some cause message");
}
use of org.sonar.server.es.EsClient in project sonarqube by SonarSource.
the class PermissionIndexer method index.
private void index(Collection<PermissionIndexerDao.Dto> authorizations, AuthorizationScope scope, Size bulkSize) {
IndexType indexType = scope.getIndexType();
BulkIndexer bulkIndexer = new BulkIndexer(esClient, indexType.getIndex());
bulkIndexer.setSize(bulkSize);
bulkIndexer.start();
authorizations.stream().filter(scope.getProjectPredicate()).map(dto -> newIndexRequest(dto, indexType)).forEach(bulkIndexer::add);
bulkIndexer.stop();
}
use of org.sonar.server.es.EsClient in project sonarqube by SonarSource.
the class EsMonitorTest method attributes_displays_exception_message_when_cause_is_not_ElasticSearchException_when_client_fails.
@Test
public void attributes_displays_exception_message_when_cause_is_not_ElasticSearchException_when_client_fails() {
EsClient esClientMock = mock(EsClient.class);
EsMonitor underTest = new EsMonitor(esClientMock);
when(esClientMock.prepareClusterStats()).thenThrow(new RuntimeException("RuntimeException with cause not ES", new IllegalArgumentException("some cause message")));
Map<String, Object> attributes = underTest.attributes();
assertThat(attributes).hasSize(1);
assertThat(attributes.get("State")).isEqualTo("RuntimeException with cause not ES");
}
use of org.sonar.server.es.EsClient in project sonarqube by SonarSource.
the class EsMonitorTest method attributes_displays_exception_message_when_cause_null_when_client_fails.
@Test
public void attributes_displays_exception_message_when_cause_null_when_client_fails() {
EsClient esClientMock = mock(EsClient.class);
EsMonitor underTest = new EsMonitor(esClientMock);
when(esClientMock.prepareClusterStats()).thenThrow(new RuntimeException("RuntimeException with no cause"));
Map<String, Object> attributes = underTest.attributes();
assertThat(attributes).hasSize(1);
assertThat(attributes.get("State")).isEqualTo("RuntimeException with no cause");
}
Aggregations