public async Task Handle(MetricQueryRequest <IndexCountWidget> request, CancellationToken cancellationToken)
        {
            var indexCountWidget = request.DataContext;

            var client = elasticsearchHelper.GetElasticClient(indexCountWidget);

            var indexCountResponse = await client.IndexListAsync(cancellationToken);

            if (indexCountResponse.IsValid)
            {
                request.DataContext.Value = indexCountResponse.Indices.Length;

                if (uiAction != null) //uiAction is null on unit tests...
                {
                    CollectionSynchronizer <IndexEntry, Item> synchronizer = null;
                    switch (indexCountWidget.IndexDetails)
                    {
                    case IndexDetail.None:
                        synchronizer = GetNoneSynchronizer(request);
                        break;

                    case IndexDetail.Health:
                        synchronizer = GetHealthSynchronizer(request);
                        break;

                    case IndexDetail.DocumentsCount:
                        synchronizer = GetDocumentsCountSynchronizer(request);
                        break;

                    case IndexDetail.DeletedDocumentsCount:
                        synchronizer = GetDeletedDocumentsCountSynchronizer(request);
                        break;

                    case IndexDetail.TotalStoreSize:
                        synchronizer = GetTotalStoreSizeSynchronizer(request);
                        break;

                    case IndexDetail.PrimaryStoreSize:
                        synchronizer = GetPrimaryStoreSizeSynchronizer(request);
                        break;
                    }

                    uiAction.Invoke(() => synchronizer.Synchronize(indexCountResponse.Indices, request.DataContext.Items));
                }

                request.DataContext.State = State.Ok;
            }
            else
            {
                indexCountWidget.State = State.Invalid;
            }
        }
Пример #2
0
        public void CollectionSynchronizer_Should_UpdateExistingItems()
        {
            _synchronizer.Synchronize(_sourceList, _destinationList);

            Assert.AreEqual("Existing Item Name 2", _destinationList[0].Name);
        }