From 25459f704312a980b3bbc4bdaeb554ea38c9dcbc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:01:49 +0000 Subject: [PATCH] Remove IElasticsearchClient interface (#6161) (#6162) Remove IElasticsearchClient interface. We have deemed that this interface is not all that useful as it may change between versions if APIs are added, which ends up breaking and implementations. It's not super useful for testing scenarios and we'll look to provide better options and documentation instead. Co-authored-by: Steve Gordon --- .../Client/ElasticsearchClient-BulkAll.cs | 9 -- .../Client/IElasticsearchClient.cs | 42 --------- .../Client/IndexManyExtensions.cs | 4 +- .../ElasticsearchClientSettings.cs | 2 +- .../ElasticsearchClientProductRegistration.cs | 2 +- .../FutureGenerated/FutureGenerated.cs | 53 +++-------- .../Helpers/BulkAllObservable.cs | 4 +- .../_Generated/Api/SourceRequest.g.cs | 2 +- .../Client/ElasticsearchClient.g.cs | 2 +- .../Client/IElasticsearchClient.g.cs | 92 ------------------- .../Tests.Core/Client/FixedResponseClient.cs | 2 +- tests/Tests.Core/Client/TestClient.cs | 33 ++++--- .../Extensions/EphemeralClusterExtensions.cs | 2 +- .../ClusterTestClassBase.cs | 2 +- .../Clusters/ClientTestClusterBase.cs | 2 +- .../Clusters/ITestCluster.cs | 2 +- .../Clusters/XPackCluster.cs | 2 +- .../NodeSeeders/DefaultSeeder.cs | 6 +- .../NodeSeeders/TimeSeriesSeeder.cs | 4 +- .../Serialization/ExpectJsonTestBase.cs | 2 +- .../Serialization/JsonRoundTripper.cs | 4 +- .../Serialization/SerializationTester.cs | 4 +- .../Errors/ServerErrorTestsBase.cs | 2 +- .../Indexing/IndexingDocuments.doc.cs | 2 +- .../Document/Multiple/Bulk/BulkApiTests.cs | 2 +- .../Bulk/BulkResponseParstingTests.cs | 2 +- .../Multiple/BulkAll/BulkAllApiTestsBase.cs | 2 +- .../Document/Single/Delete/DeleteApiTests.cs | 4 +- .../Single/Exists/DocumentExistsApiTests.cs | 2 +- .../Document/Single/Update/UpdateApiTests.cs | 2 +- .../IntegrationDocumentationTestBase.cs | 4 +- .../EndpointTests/ApiIntegrationTestBase.cs | 4 +- .../EndpointTests/CoordinatedUsage.cs | 26 +++--- .../RequestResponseApiTestBase.cs | 20 ++-- .../EndpointTests/TestState/EndpointUsage.cs | 30 +++--- .../Framework/EndpointTests/UrlTester.cs | 14 +-- .../EndpointTests/UrlTesterExtensions.cs | 4 +- 37 files changed, 113 insertions(+), 284 deletions(-) delete mode 100644 src/Elastic.Clients.Elasticsearch/Client/IElasticsearchClient.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Client/IElasticsearchClient.g.cs diff --git a/src/Elastic.Clients.Elasticsearch/Client/ElasticsearchClient-BulkAll.cs b/src/Elastic.Clients.Elasticsearch/Client/ElasticsearchClient-BulkAll.cs index 1337bc35afe..981ad3a0cae 100644 --- a/src/Elastic.Clients.Elasticsearch/Client/ElasticsearchClient-BulkAll.cs +++ b/src/Elastic.Clients.Elasticsearch/Client/ElasticsearchClient-BulkAll.cs @@ -9,15 +9,6 @@ namespace Elastic.Clients.Elasticsearch; -public partial interface IElasticsearchClient -{ - //HelpersNamespace Helpers { get; } - - BulkAllObservable BulkAll(IEnumerable documents, Action> configure, CancellationToken cancellationToken = default); - - BulkAllObservable BulkAll(IBulkAllRequest request, CancellationToken cancellationToken = default); -} - public partial class ElasticsearchClient { //public HelpersNamespace Helpers { get; private set; } diff --git a/src/Elastic.Clients.Elasticsearch/Client/IElasticsearchClient.cs b/src/Elastic.Clients.Elasticsearch/Client/IElasticsearchClient.cs deleted file mode 100644 index e72814a1f8d..00000000000 --- a/src/Elastic.Clients.Elasticsearch/Client/IElasticsearchClient.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using Elastic.Transport; - -namespace Elastic.Clients.Elasticsearch -{ - /// - /// ElasticsearchClient is Elastic.Clients.Elasticsearch's strongly typed client which exposes fully mapped Elasticsearch endpoints. - /// - /// - /// It is generally expected to be used as a singleton instance for the lifetime of the host application. - /// - public partial interface IElasticsearchClient - { - /// - /// The configured connection settings for the client. - /// - IElasticsearchClientSettings ElasticsearchClientSettings { get; } - - /// - /// Access to the that this instance of the client uses to resolve types to e.g - /// indices, property, field names. - /// - Inferrer Infer { get; } - - /// - /// Access the configured - /// Out of the box and this point to the same instance. - /// - Serializer RequestResponseSerializer { get; } - - /// - /// Access the configured - /// Out of the box and this point to the same instance. - /// - Serializer SourceSerializer { get; } - - ITransport Transport { get; } - } -} diff --git a/src/Elastic.Clients.Elasticsearch/Client/IndexManyExtensions.cs b/src/Elastic.Clients.Elasticsearch/Client/IndexManyExtensions.cs index 4c569960649..52a6c90e9de 100644 --- a/src/Elastic.Clients.Elasticsearch/Client/IndexManyExtensions.cs +++ b/src/Elastic.Clients.Elasticsearch/Client/IndexManyExtensions.cs @@ -24,7 +24,7 @@ public static class IndexManyExtensions /// List of objects to index, Id will be inferred (Id property or IdProperty attribute on type) /// Override the inferred indexname for T /// Override the inferred typename for T - public static BulkResponse IndexMany(this IElasticsearchClient client, IEnumerable @objects, IndexName index = null) + public static BulkResponse IndexMany(this ElasticsearchClient client, IEnumerable @objects, IndexName index = null) where T : class { var bulkRequest = CreateIndexBulkRequest(objects, index); @@ -41,7 +41,7 @@ public static BulkResponse IndexMany(this IElasticsearchClient client, IEnume /// List of objects to index, Id will be inferred (Id property or IdProperty attribute on type) /// Override the inferred indexname for T /// Override the inferred typename for T - public static Task IndexManyAsync(this IElasticsearchClient client, IEnumerable objects, IndexName index = null, + public static Task IndexManyAsync(this ElasticsearchClient client, IEnumerable objects, IndexName index = null, CancellationToken cancellationToken = default ) where T : class diff --git a/src/Elastic.Clients.Elasticsearch/Common/Configuration/ElasticsearchClientSettings.cs b/src/Elastic.Clients.Elasticsearch/Common/Configuration/ElasticsearchClientSettings.cs index 604a606a905..353c364e338 100644 --- a/src/Elastic.Clients.Elasticsearch/Common/Configuration/ElasticsearchClientSettings.cs +++ b/src/Elastic.Clients.Elasticsearch/Common/Configuration/ElasticsearchClientSettings.cs @@ -409,7 +409,7 @@ public abstract class protected ConnectionConfigurationBase(NodePool nodePool, ITransportClient connection, Serializer? serializer, IProductRegistration registration = null) - : base(nodePool, connection, serializer, registration ?? new ElasticsearchProductRegistration(typeof(IElasticsearchClient))) => + : base(nodePool, connection, serializer, registration ?? new ElasticsearchProductRegistration(typeof(ElasticsearchClient))) => UserAgent(ConnectionConfiguration.DefaultUserAgent); bool ITransportClientConfigurationValues.IncludeServerStackTraceOnError => _includeServerStackTraceOnError; diff --git a/src/Elastic.Clients.Elasticsearch/Common/ElasticsearchClientProductRegistration.cs b/src/Elastic.Clients.Elasticsearch/Common/ElasticsearchClientProductRegistration.cs index c4b96b1e61d..2553c4638eb 100644 --- a/src/Elastic.Clients.Elasticsearch/Common/ElasticsearchClientProductRegistration.cs +++ b/src/Elastic.Clients.Elasticsearch/Common/ElasticsearchClientProductRegistration.cs @@ -12,7 +12,7 @@ internal sealed class ElasticsearchClientProductRegistration : ElasticsearchProd { public ElasticsearchClientProductRegistration(Type markerType) : base(markerType) { } - public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(IElasticsearchClient)); + public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(ElasticsearchClient)); /// /// Elastic.Clients.Elasticsearch handles 404 in its , we do not want the low level client throwing diff --git a/src/Elastic.Clients.Elasticsearch/FutureGenerated/FutureGenerated.cs b/src/Elastic.Clients.Elasticsearch/FutureGenerated/FutureGenerated.cs index c76f270bd0b..ed847468513 100644 --- a/src/Elastic.Clients.Elasticsearch/FutureGenerated/FutureGenerated.cs +++ b/src/Elastic.Clients.Elasticsearch/FutureGenerated/FutureGenerated.cs @@ -1064,20 +1064,16 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } } - public partial class ElasticsearchClient - { - public SourceResponse Source(DocumentPath id, Action> configure = null) - { - var descriptor = new SourceRequestDescriptor(document: id.Document, index: id?.Self?.Index, id: id?.Self?.Id); - configure?.Invoke(descriptor); - return DoRequest, SourceResponse>(descriptor); - } - } + //public partial class ElasticsearchClient + //{ + // public SourceResponse Source(DocumentPath id, Action> configure = null) + // { + // var descriptor = new SourceRequestDescriptor(document: id.Document, index: id?.Self?.Index, id: id?.Self?.Id); + // configure?.Invoke(descriptor); + // return DoRequest, SourceResponse>(descriptor); + // } + //} - public partial interface IElasticsearchClient - { - public SourceResponse Source(DocumentPath id, Action> configure = null); - } public abstract partial class BulkResponseItemBase { @@ -1092,7 +1088,7 @@ public abstract partial class BulkResponseItemBase // TODO - Should be added as a rule to the descriptor generator //public sealed partial class SourceRequestDescriptor //{ - // public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) { } + // public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) => Doc //} public partial class SourceRequestDescriptor @@ -1545,29 +1541,6 @@ public partial struct Refresh : IStringable public class DocType { } - public partial interface IElasticsearchClient - { - DeleteResponse Delete(Id id, Action> configureRequest); - - Task DeleteAsync(Id id, Action> configureRequest, CancellationToken cancellationToken = default); - - CreateResponse Create(TDocument document, Action> configureRequest); - - Task CreateAsync(TDocument document, Action> configureRequest, CancellationToken cancellationToken = default); - - IndexResponse Index(TDocument document, Action> configureRequest); - - Task IndexAsync(TDocument document, Action> configureRequest, CancellationToken cancellationToken = default); - - Task> UpdateAsync(IndexName index, Id id, Action> configureRequest = null, CancellationToken cancellationToken = default); - - UpdateResponse Update(IndexName index, Id id, Action> configureRequest = null); - - CountResponse Count(Action> configureRequest = null); - - Task CountAsync(Action> configureRequest = null, CancellationToken cancellationToken = default); - } - public partial class ElasticsearchClient { public IndexResponse Index(TDocument document, Action> configureRequest) @@ -1626,11 +1599,11 @@ public UpdateResponse Update(IndexName i return DoRequest, UpdateResponse>(descriptor); } - public SourceResponse Source(DocumentPath id, Action configureRequest = null) + public SourceResponse Source(DocumentPath id, Action> configureRequest = null) { - var descriptor = new SourceRequestDescriptor(typeof(TDocument), new Id(typeof(TDocument))); + var descriptor = new SourceRequestDescriptor(document: id.Document, index: id?.Self?.Index ?? typeof(TDocument), id: id?.Self?.Id ?? Id.From(id.Document)); configureRequest?.Invoke(descriptor); - return DoRequest>(descriptor); + return DoRequest, SourceResponse>(descriptor); } public CountResponse Count(Action> configureRequest = null) diff --git a/src/Elastic.Clients.Elasticsearch/Helpers/BulkAllObservable.cs b/src/Elastic.Clients.Elasticsearch/Helpers/BulkAllObservable.cs index 91846965897..f34a72f580a 100644 --- a/src/Elastic.Clients.Elasticsearch/Helpers/BulkAllObservable.cs +++ b/src/Elastic.Clients.Elasticsearch/Helpers/BulkAllObservable.cs @@ -22,7 +22,7 @@ public class BulkAllObservable : IDisposable, IObservable private readonly int _backOffRetries; private readonly TimeSpan _backOffTime; private readonly int _bulkSize; - private readonly IElasticsearchClient _client; + private readonly ElasticsearchClient _client; private readonly CancellationToken _compositeCancelToken; private readonly CancellationTokenSource _compositeCancelTokenSource; @@ -36,7 +36,7 @@ public class BulkAllObservable : IDisposable, IObservable private readonly Action _bulkResponseCallback; - public BulkAllObservable(IElasticsearchClient client, IBulkAllRequest partitionedBulkRequest, CancellationToken cancellationToken = default) + public BulkAllObservable(ElasticsearchClient client, IBulkAllRequest partitionedBulkRequest, CancellationToken cancellationToken = default) { _client = client; _partitionedBulkRequest = partitionedBulkRequest; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SourceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SourceRequest.g.cs index 9e8930d80c0..0e4be4b923b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SourceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SourceRequest.g.cs @@ -199,4 +199,4 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o { } } -} \ No newline at end of file +} diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs index fdde3681f29..f92174c1e36 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs @@ -26,7 +26,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public partial class ElasticsearchClient : IElasticsearchClient + public partial class ElasticsearchClient { public AsyncSearchNamespace AsyncSearch { get; private set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/IElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/IElasticsearchClient.g.cs deleted file mode 100644 index 9a05131ac97..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/IElasticsearchClient.g.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.AsyncSearch; -using Elastic.Clients.Elasticsearch.Cluster; -using Elastic.Clients.Elasticsearch.Eql; -using Elastic.Clients.Elasticsearch.IndexManagement; -using System; -using System.Threading; -using System.Threading.Tasks; - -#nullable restore -namespace Elastic.Clients.Elasticsearch -{ - public partial interface IElasticsearchClient - { - AsyncSearchNamespace AsyncSearch { get; } - - ClusterNamespace Cluster { get; } - - EqlNamespace Eql { get; } - - IndexManagementNamespace IndexManagement { get; } - - BulkResponse Bulk(BulkRequest request); - Task BulkAsync(BulkRequest request, CancellationToken cancellationToken = default); - BulkResponse Bulk(Action configureRequest = null); - Task BulkAsync(Action configureRequest = null, CancellationToken cancellationToken = default); - ClosePointInTimeResponse ClosePointInTime(ClosePointInTimeRequest request); - Task ClosePointInTimeAsync(ClosePointInTimeRequest request, CancellationToken cancellationToken = default); - ClosePointInTimeResponse ClosePointInTime(Action configureRequest = null); - Task ClosePointInTimeAsync(Action configureRequest = null, CancellationToken cancellationToken = default); - CountResponse Count(CountRequest request); - Task CountAsync(CountRequest request, CancellationToken cancellationToken = default); - CountResponse Count(Action configureRequest = null); - Task CountAsync(Action configureRequest = null, CancellationToken cancellationToken = default); - CreateResponse Create(CreateRequest request); - Task CreateAsync(CreateRequest request, CancellationToken cancellationToken = default); - CreateResponse Create(TDocument document, Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null); - Task CreateAsync(TDocument document, Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null, CancellationToken cancellationToken = default); - DeleteResponse Delete(DeleteRequest request); - Task DeleteAsync(DeleteRequest request, CancellationToken cancellationToken = default); - DeleteResponse Delete(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action configureRequest = null); - Task DeleteAsync(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action configureRequest = null, CancellationToken cancellationToken = default); - ExistsResponse Exists(ExistsRequest request); - Task ExistsAsync(ExistsRequest request, CancellationToken cancellationToken = default); - ExistsResponse Exists(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action configureRequest = null); - Task ExistsAsync(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action configureRequest = null, CancellationToken cancellationToken = default); - GetResponse Get(GetRequest request); - Task> GetAsync(GetRequest request, CancellationToken cancellationToken = default); - GetResponse Get(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null); - Task> GetAsync(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null, CancellationToken cancellationToken = default); - IndexResponse Index(IndexRequest request); - Task IndexAsync(IndexRequest request, CancellationToken cancellationToken = default); - IndexResponse Index(TDocument document, Elastic.Clients.Elasticsearch.IndexName index, Action> configureRequest = null); - Task IndexAsync(TDocument document, Elastic.Clients.Elasticsearch.IndexName index, Action> configureRequest = null, CancellationToken cancellationToken = default); - OpenPointInTimeResponse OpenPointInTime(OpenPointInTimeRequest request); - Task OpenPointInTimeAsync(OpenPointInTimeRequest request, CancellationToken cancellationToken = default); - OpenPointInTimeResponse OpenPointInTime(Elastic.Clients.Elasticsearch.Indices indices, Action configureRequest = null); - Task OpenPointInTimeAsync(Elastic.Clients.Elasticsearch.Indices indices, Action configureRequest = null, CancellationToken cancellationToken = default); - PingResponse Ping(PingRequest request); - Task PingAsync(PingRequest request, CancellationToken cancellationToken = default); - PingResponse Ping(Action configureRequest = null); - Task PingAsync(Action configureRequest = null, CancellationToken cancellationToken = default); - SearchResponse Search(SearchRequest request); - Task> SearchAsync(SearchRequest request, CancellationToken cancellationToken = default); - SearchResponse Search(Action> configureRequest = null); - Task> SearchAsync(Action> configureRequest = null, CancellationToken cancellationToken = default); - SourceResponse Source(SourceRequest request); - Task> SourceAsync(SourceRequest request, CancellationToken cancellationToken = default); - SourceResponse Source(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null); - Task> SourceAsync(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null, CancellationToken cancellationToken = default); - UpdateResponse Update(UpdateRequest request); - Task> UpdateAsync(UpdateRequest request, CancellationToken cancellationToken = default); - UpdateResponse Update(TDocument document, TPartialDocument partialDocument, Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null); - Task> UpdateAsync(TDocument document, TPartialDocument partialDocument, Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id, Action> configureRequest = null, CancellationToken cancellationToken = default); - } -} \ No newline at end of file diff --git a/tests/Tests.Core/Client/FixedResponseClient.cs b/tests/Tests.Core/Client/FixedResponseClient.cs index 6ecb0c40a6d..f51213addee 100644 --- a/tests/Tests.Core/Client/FixedResponseClient.cs +++ b/tests/Tests.Core/Client/FixedResponseClient.cs @@ -13,7 +13,7 @@ namespace Tests.Core.Client { public static class FixedResponseClient { - public static IElasticsearchClient Create( + public static ElasticsearchClient Create( object response, int statusCode = 200, Func modifySettings = null, diff --git a/tests/Tests.Core/Client/TestClient.cs b/tests/Tests.Core/Client/TestClient.cs index 305d887a972..92b258f7670 100644 --- a/tests/Tests.Core/Client/TestClient.cs +++ b/tests/Tests.Core/Client/TestClient.cs @@ -7,26 +7,25 @@ using Tests.Core.Client.Settings; using Tests.Domain.Extensions; -namespace Tests.Core.Client +namespace Tests.Core.Client; + +public static class TestClient { - public static class TestClient - { - public static readonly TestConfigurationBase Configuration = TestConfiguration.Instance; + public static readonly TestConfigurationBase Configuration = TestConfiguration.Instance; - public static readonly IElasticsearchClient Default = - new ElasticsearchClient(new TestElasticsearchClientSettings().ApplyDomainSettings()); + public static readonly ElasticsearchClient Default = + new ElasticsearchClient(new TestElasticsearchClientSettings().ApplyDomainSettings()); - public static readonly IElasticsearchClient DefaultInMemoryClient = - new ElasticsearchClient(new AlwaysInMemoryElasticsearchClientSettings().ApplyDomainSettings()); + public static readonly ElasticsearchClient DefaultInMemoryClient = + new ElasticsearchClient(new AlwaysInMemoryElasticsearchClientSettings().ApplyDomainSettings()); - public static readonly IElasticsearchClient DisabledStreaming = - new ElasticsearchClient(new TestElasticsearchClientSettings().ApplyDomainSettings().DisableDirectStreaming()); + public static readonly ElasticsearchClient DisabledStreaming = + new ElasticsearchClient(new TestElasticsearchClientSettings().ApplyDomainSettings().DisableDirectStreaming()); - public static IElasticsearchClient FixedInMemoryClient(byte[] response) => new ElasticsearchClient( - new AlwaysInMemoryElasticsearchClientSettings(response) - .ApplyDomainSettings() - .DisableDirectStreaming() - .EnableHttpCompression(false) - ); - } + public static ElasticsearchClient FixedInMemoryClient(byte[] response) => new ElasticsearchClient( + new AlwaysInMemoryElasticsearchClientSettings(response) + .ApplyDomainSettings() + .DisableDirectStreaming() + .EnableHttpCompression(false) + ); } diff --git a/tests/Tests.Core/Extensions/EphemeralClusterExtensions.cs b/tests/Tests.Core/Extensions/EphemeralClusterExtensions.cs index 061eb9e7d97..2b025d0029f 100644 --- a/tests/Tests.Core/Extensions/EphemeralClusterExtensions.cs +++ b/tests/Tests.Core/Extensions/EphemeralClusterExtensions.cs @@ -23,7 +23,7 @@ public static ElasticsearchClientSettings CreateConnectionSettings( return new TestElasticsearchClientSettings(uris => new StaticNodePool(clusterNodes)); } - public static IElasticsearchClient GetOrAddClient( + public static ElasticsearchClient GetOrAddClient( this IEphemeralCluster cluster, Func modifySettings = null ) diff --git a/tests/Tests.Core/ManagedElasticsearch/ClusterTestClassBase.cs b/tests/Tests.Core/ManagedElasticsearch/ClusterTestClassBase.cs index 7781ab2dadb..bd5a1a04540 100644 --- a/tests/Tests.Core/ManagedElasticsearch/ClusterTestClassBase.cs +++ b/tests/Tests.Core/ManagedElasticsearch/ClusterTestClassBase.cs @@ -19,7 +19,7 @@ protected ClusterTestClassBase(TCluster cluster) Cluster.ClusterConfiguration.CacheEsHomeInstallation = true; } - public IElasticsearchClient Client => Cluster.Client; + public ElasticsearchClient Client => Cluster.Client; public TCluster Cluster { get; } } } diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/ClientTestClusterBase.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/ClientTestClusterBase.cs index ad6e81cb91c..7a887ab5adf 100644 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/ClientTestClusterBase.cs +++ b/tests/Tests.Core/ManagedElasticsearch/Clusters/ClientTestClusterBase.cs @@ -28,7 +28,7 @@ protected ClientTestClusterBase(params ElasticsearchPlugin[] plugins) : this( protected ClientTestClusterBase(ClientTestClusterConfiguration configuration) : base(configuration) { } - public IElasticsearchClient Client => this.GetOrAddClient(s => ConnectionSettings(s.ApplyDomainSettings())); + public ElasticsearchClient Client => this.GetOrAddClient(s => ConnectionSettings(s.ApplyDomainSettings())); protected virtual ElasticsearchClientSettings ConnectionSettings(ElasticsearchClientSettings s) => s; diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/ITestCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/ITestCluster.cs index 3b71b18a0ad..79fd2a1b1bd 100644 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/ITestCluster.cs +++ b/tests/Tests.Core/ManagedElasticsearch/Clusters/ITestCluster.cs @@ -8,6 +8,6 @@ namespace Tests.Core.ManagedElasticsearch.Clusters { public interface ITestCluster { - IElasticsearchClient Client { get; } + ElasticsearchClient Client { get; } } } diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs index 486f4faec09..df103b83bf9 100644 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs +++ b/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs @@ -23,7 +23,7 @@ public XPackCluster() : this(new XPackClusterConfiguration()) { } public XPackCluster(XPackClusterConfiguration configuration) : base(configuration) { } - public virtual IElasticsearchClient Client => + public virtual ElasticsearchClient Client => this.GetOrAddClient(s => Authenticate(ConnectionSettings(s.ApplyDomainSettings()))); protected virtual ElasticsearchClientSettings Authenticate(ElasticsearchClientSettings s) => s diff --git a/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs b/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs index 126d113b63c..0b4da463e2b 100644 --- a/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs +++ b/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs @@ -30,15 +30,15 @@ public class DefaultSeeder NumberOfReplicas = 0, }; - public DefaultSeeder(IElasticsearchClient client, IndexSettings indexSettings) + public DefaultSeeder(ElasticsearchClient client, IndexSettings indexSettings) { Client = client; IndexSettings = indexSettings ?? _defaultIndexSettings; } - public DefaultSeeder(IElasticsearchClient client) : this(client, null) { } + public DefaultSeeder(ElasticsearchClient client) : this(client, null) { } - private IElasticsearchClient Client { get; } + private ElasticsearchClient Client { get; } private IndexSettings IndexSettings { get; } diff --git a/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/TimeSeriesSeeder.cs b/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/TimeSeriesSeeder.cs index ce64afb3bd7..3540f6cf424 100644 --- a/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/TimeSeriesSeeder.cs +++ b/tests/Tests.Core/ManagedElasticsearch/NodeSeeders/TimeSeriesSeeder.cs @@ -15,9 +15,9 @@ namespace Tests.Core.ManagedElasticsearch.NodeSeeders; public class TimeSeriesSeeder { public static readonly string IndicesWildCard = "customlogs-*"; - private readonly IElasticsearchClient _client; + private readonly ElasticsearchClient _client; - public TimeSeriesSeeder(IElasticsearchClient client) => _client = client; + public TimeSeriesSeeder(ElasticsearchClient client) => _client = client; public void SeedNode() { diff --git a/tests/Tests.Core/Serialization/ExpectJsonTestBase.cs b/tests/Tests.Core/Serialization/ExpectJsonTestBase.cs index f489c69c7a7..b0784e7b275 100644 --- a/tests/Tests.Core/Serialization/ExpectJsonTestBase.cs +++ b/tests/Tests.Core/Serialization/ExpectJsonTestBase.cs @@ -12,7 +12,7 @@ namespace Tests.Core.Serialization { public abstract class ExpectJsonTestBase { - protected ExpectJsonTestBase(IElasticsearchClient client) => Tester = new SerializationTester(client); + protected ExpectJsonTestBase(ElasticsearchClient client) => Tester = new SerializationTester(client); protected abstract object ExpectJson { get; } protected abstract IReadOnlyList ExpectNdjson { get; } diff --git a/tests/Tests.Core/Serialization/JsonRoundTripper.cs b/tests/Tests.Core/Serialization/JsonRoundTripper.cs index b2f4dbcf85a..6880638d131 100644 --- a/tests/Tests.Core/Serialization/JsonRoundTripper.cs +++ b/tests/Tests.Core/Serialization/JsonRoundTripper.cs @@ -50,11 +50,11 @@ public T DeserializesTo(Action assert = null) public void FromRequest(IResponse response) => ToSerializeTo(response.ApiCall.RequestBodyInBytes); - public void FromRequest(Func call) where T : IResponse => FromRequest(call(Tester.Client)); + public void FromRequest(Func call) where T : IResponse => FromRequest(call(Tester.Client)); public void FromResponse(IResponse response) => ToSerializeTo(response.ApiCall.ResponseBodyInBytes); - public void FromResponse(Func call) where T : IResponse => FromResponse(call(Tester.Client)); + public void FromResponse(Func call) where T : IResponse => FromResponse(call(Tester.Client)); private void ToSerializeTo(byte[] json) { diff --git a/tests/Tests.Core/Serialization/SerializationTester.cs b/tests/Tests.Core/Serialization/SerializationTester.cs index 188e3c000ff..e5e62051ddb 100644 --- a/tests/Tests.Core/Serialization/SerializationTester.cs +++ b/tests/Tests.Core/Serialization/SerializationTester.cs @@ -19,13 +19,13 @@ namespace Tests.Core.Serialization { public class SerializationTester { - public SerializationTester(IElasticsearchClient client) => Client = client; + public SerializationTester(ElasticsearchClient client) => Client = client; // TODO: This needs a fair bit of cleanup and refactoring. Code is hacked for initial testing using STJ public static SerializationTester Default { get; } = new(TestClient.DefaultInMemoryClient); - public IElasticsearchClient Client { get; } + public ElasticsearchClient Client { get; } //public static SerializationTester DefaultWithJsonNetSerializer { get; } = new SerializationTester(TestClient.InMemoryWithJsonNetSerializer); diff --git a/tests/Tests/ClientConcepts/Errors/ServerErrorTestsBase.cs b/tests/Tests/ClientConcepts/Errors/ServerErrorTestsBase.cs index f65a3c14b89..67b581fb184 100644 --- a/tests/Tests/ClientConcepts/Errors/ServerErrorTestsBase.cs +++ b/tests/Tests/ClientConcepts/Errors/ServerErrorTestsBase.cs @@ -19,7 +19,7 @@ protected ServerErrorTestsBase() } protected abstract string Json { get; } - private IElasticsearchClient HighLevelClient { get; } + private ElasticsearchClient HighLevelClient { get; } private string ResponseJson => string.Concat(@"{ ""error"": ", Json, @", ""status"":500 }"); diff --git a/tests/Tests/ClientConcepts/HighLevel/Indexing/IndexingDocuments.doc.cs b/tests/Tests/ClientConcepts/HighLevel/Indexing/IndexingDocuments.doc.cs index c036a75c6cd..41a42cb8fb8 100644 --- a/tests/Tests/ClientConcepts/HighLevel/Indexing/IndexingDocuments.doc.cs +++ b/tests/Tests/ClientConcepts/HighLevel/Indexing/IndexingDocuments.doc.cs @@ -18,7 +18,7 @@ namespace Tests.ClientConcepts.HighLevel.Indexing */ public class Indexing : DocumentationTestBase { - private readonly IElasticsearchClient _client = new ElasticsearchClient( + private readonly ElasticsearchClient _client = new ElasticsearchClient( new ElasticsearchClientSettings(new SingleNodePool(new Uri("http://localhost:9200")), new InMemoryConnection())); /// hide diff --git a/tests/Tests/Document/Multiple/Bulk/BulkApiTests.cs b/tests/Tests/Document/Multiple/Bulk/BulkApiTests.cs index 59021b38cc8..c45f80a7e8c 100644 --- a/tests/Tests/Document/Multiple/Bulk/BulkApiTests.cs +++ b/tests/Tests/Document/Multiple/Bulk/BulkApiTests.cs @@ -116,7 +116,7 @@ protected override LazyResponses ClientUsage() => Calls( (client, r) => client.BulkAsync(r) ); - protected override void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) + protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { // TODO - REPLACE WITH FLUENT diff --git a/tests/Tests/Document/Multiple/Bulk/BulkResponseParstingTests.cs b/tests/Tests/Document/Multiple/Bulk/BulkResponseParstingTests.cs index a027f2e084a..6f027c81901 100644 --- a/tests/Tests/Document/Multiple/Bulk/BulkResponseParstingTests.cs +++ b/tests/Tests/Document/Multiple/Bulk/BulkResponseParstingTests.cs @@ -23,7 +23,7 @@ public void CanDeserialize() x.Items.Should().HaveCount(count).And.NotContain(i => i == null); } - private static BulkResponse Deserialize(byte[] response, IElasticsearchClient client) + private static BulkResponse Deserialize(byte[] response, ElasticsearchClient client) { using var ms = new MemoryStream(response); return client.RequestResponseSerializer.Deserialize(ms); diff --git a/tests/Tests/Document/Multiple/BulkAll/BulkAllApiTestsBase.cs b/tests/Tests/Document/Multiple/BulkAll/BulkAllApiTestsBase.cs index 3df13496d5b..6cc2b1d4758 100644 --- a/tests/Tests/Document/Multiple/BulkAll/BulkAllApiTestsBase.cs +++ b/tests/Tests/Document/Multiple/BulkAll/BulkAllApiTestsBase.cs @@ -16,7 +16,7 @@ public abstract class BulkAllApiTestsBase : IClusterFixture Client = cluster.Client; - protected IElasticsearchClient Client { get; } + protected ElasticsearchClient Client { get; } protected static string CreateIndexName() => $"project-copy-{Guid.NewGuid().ToString("N")[8..]}"; diff --git a/tests/Tests/Document/Single/Delete/DeleteApiTests.cs b/tests/Tests/Document/Single/Delete/DeleteApiTests.cs index 6ed9237b6fd..aaff33c59f2 100644 --- a/tests/Tests/Document/Single/Delete/DeleteApiTests.cs +++ b/tests/Tests/Document/Single/Delete/DeleteApiTests.cs @@ -28,7 +28,7 @@ public DeleteApiTests(WritableCluster cluster, EndpointUsage usage) : base(clust protected override string ExpectedUrlPathAndQuery => $"/project/_doc/{CallIsolatedValue}?routing={U(CallIsolatedValue)}"; - protected override void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) + protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { foreach (var id in values.Values) Client.Index(Project.Instance, i => i.Id(id).Routing(id)); @@ -71,7 +71,7 @@ public OriginalDeleteApiTests(WritableCluster cluster, EndpointUsage usage) : ba protected override bool SupportsDeserialization => false; protected override string ExpectedUrlPathAndQuery => $"/project/_doc/{CallIsolatedValue}?routing={U(CallIsolatedValue)}"; - protected override void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) + protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { foreach (var id in values.Values) Client.Index(Project.Instance, i => i.Id(id).Routing(id)); diff --git a/tests/Tests/Document/Single/Exists/DocumentExistsApiTests.cs b/tests/Tests/Document/Single/Exists/DocumentExistsApiTests.cs index 99dde7d620e..d8bfd023e2b 100644 --- a/tests/Tests/Document/Single/Exists/DocumentExistsApiTests.cs +++ b/tests/Tests/Document/Single/Exists/DocumentExistsApiTests.cs @@ -24,7 +24,7 @@ public DocumentExistsApiTests(WritableCluster cluster, EndpointUsage usage) : ba protected override bool SupportsDeserialization => false; protected override ExistsRequestDescriptor NewDescriptor() => new(Infer.Index(), CallIsolatedValue); - protected override void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) + protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { foreach (var id in values.Values) Client.Index(Project.Instance, i => i.Id(id).Routing(id)); diff --git a/tests/Tests/Document/Single/Update/UpdateApiTests.cs b/tests/Tests/Document/Single/Update/UpdateApiTests.cs index b776092d293..e84e473dbf8 100644 --- a/tests/Tests/Document/Single/Update/UpdateApiTests.cs +++ b/tests/Tests/Document/Single/Update/UpdateApiTests.cs @@ -47,7 +47,7 @@ public UpdateApiTests(WritableCluster cluster, EndpointUsage usage) : base(clust protected override bool SupportsDeserialization => false; protected override string ExpectedUrlPathAndQuery => $"/project/_update/{CallIsolatedValue}?routing={CallIsolatedValue}"; - protected override void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) + protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { foreach (var id in values.Values) Client.Index(Project.Instance, i => i.Id(id).Routing(id)); diff --git a/tests/Tests/Framework/DocumentationTests/IntegrationDocumentationTestBase.cs b/tests/Tests/Framework/DocumentationTests/IntegrationDocumentationTestBase.cs index 860fa367827..033164d6c5d 100644 --- a/tests/Tests/Framework/DocumentationTests/IntegrationDocumentationTestBase.cs +++ b/tests/Tests/Framework/DocumentationTests/IntegrationDocumentationTestBase.cs @@ -10,7 +10,7 @@ namespace Tests.Framework.DocumentationTests { public abstract class DocumentationTestBase { - protected virtual IElasticsearchClient Client => TestClient.DefaultInMemoryClient; + protected virtual ElasticsearchClient Client => TestClient.DefaultInMemoryClient; protected static string RandomString() => Guid.NewGuid().ToString("N").Substring(0, 8); } @@ -21,6 +21,6 @@ public abstract class IntegrationDocumentationTestBase : DocumentationTestBase protected IntegrationDocumentationTestBase(ClientTestClusterBase cluster) => Cluster = cluster; - protected override IElasticsearchClient Client => Cluster.Client; + protected override ElasticsearchClient Client => Cluster.Client; } } diff --git a/tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs b/tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs index c0fb63b6f97..075e58cd8e4 100644 --- a/tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs +++ b/tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs @@ -24,7 +24,7 @@ public abstract class ApiIntegrationTestBase Cluster.Client; + public override ElasticsearchClient Client => Cluster.Client; protected abstract bool ExpectIsValid { get; } protected abstract int ExpectStatusCode { get; } protected override TInitializer Initializer => Activator.CreateInstance(); @@ -70,7 +70,7 @@ public abstract class NdJsonApiIntegrationTestBase Cluster.Client; + public override ElasticsearchClient Client => Cluster.Client; protected abstract bool ExpectIsValid { get; } protected abstract int ExpectStatusCode { get; } protected override TInitializer Initializer => Activator.CreateInstance(); diff --git a/tests/Tests/Framework/EndpointTests/CoordinatedUsage.cs b/tests/Tests/Framework/EndpointTests/CoordinatedUsage.cs index 2b7954bfd6c..b739acab302 100644 --- a/tests/Tests/Framework/EndpointTests/CoordinatedUsage.cs +++ b/tests/Tests/Framework/EndpointTests/CoordinatedUsage.cs @@ -38,7 +38,7 @@ public CoordinatedUsage(ITestCluster cluster, EndpointUsage usage, string prefix Prefix = prefix; } - protected IElasticsearchClient Client => _cluster.Client; + protected ElasticsearchClient Client => _cluster.Client; private string Prefix { get; } private static string RandomFluent { get; } = $"f-{RandomString()}"; private static string RandomFluentAsync { get; } = $"fa-{RandomString()}"; @@ -78,10 +78,10 @@ public void Add(string name, string versionRange, Func Calls( Func initializerBody, Func fluentBody, - Func, TResponse> fluent, - Func, Task> fluentAsync, - Func request, - Func> requestAsync, + Func, TResponse> fluent, + Func, Task> fluentAsync, + Func request, + Func> requestAsync, Action onResponse = null, Func uniqueValueSelector = null ) @@ -105,14 +105,14 @@ public Func Calls( , k); } - public Func Call(Func call) => + public Func Call(Func call) => Call(async (s, c) => { await call(s, c); return VoidResponse; }); - public Func Call(Func> call) where TResponse : IResponse + public Func Call(Func> call) where TResponse : IResponse { var client = Client; return k => Usage.CallOnce( @@ -136,13 +136,13 @@ private async ValueTask> CallAllClientMethod EndpointUsage usage, Func initializerBody, Func fluentBody, - Func, TResponse> fluent, - Func, Task> fluentAsync, - Func request, - Func> requestAsync, + Func, TResponse> fluent, + Func, Task> fluentAsync, + Func request, + Func> requestAsync, Action onResponse, Func uniqueValueSelector, - IElasticsearchClient client + ElasticsearchClient client ) where TResponse : class, IResponse where TDescriptor : class @@ -151,7 +151,7 @@ IElasticsearchClient client var dict = new Dictionary(); async Task InvokeApiCall( ClientMethod method, - Func> invoke + Func> invoke ) { usage.CallUniqueValues.CurrentView = method; diff --git a/tests/Tests/Framework/EndpointTests/RequestResponseApiTestBase.cs b/tests/Tests/Framework/EndpointTests/RequestResponseApiTestBase.cs index 6bdc26e4856..3330c9431c7 100644 --- a/tests/Tests/Framework/EndpointTests/RequestResponseApiTestBase.cs +++ b/tests/Tests/Framework/EndpointTests/RequestResponseApiTestBase.cs @@ -36,7 +36,7 @@ protected RequestResponseApiTestBase(TCluster cluster, EndpointUsage usage) : b UniqueValues = usage.CallUniqueValues; } - public virtual IElasticsearchClient Client => + public virtual ElasticsearchClient Client => TestConfiguration.Instance.RunIntegrationTests ? Cluster.Client : TestClient.DefaultInMemoryClient; public TCluster Cluster { get; } @@ -63,28 +63,28 @@ protected RequestResponseApiTestBase(TCluster cluster, EndpointUsage usage) : b protected void ExtendedValue(string key, T value) where T : class => UniqueValues.ExtendedValue(key, value); - protected virtual void IntegrationSetup(IElasticsearchClient client, CallUniqueValues values) { } + protected virtual void IntegrationSetup(ElasticsearchClient client, CallUniqueValues values) { } - protected virtual void IntegrationTeardown(IElasticsearchClient client, CallUniqueValues values) { } + protected virtual void IntegrationTeardown(ElasticsearchClient client, CallUniqueValues values) { } - protected virtual void OnBeforeCall(IElasticsearchClient client) { } + protected virtual void OnBeforeCall(ElasticsearchClient client) { } - protected virtual void OnAfterCall(IElasticsearchClient client) { } + protected virtual void OnAfterCall(ElasticsearchClient client) { } protected virtual TDescriptor NewDescriptor() => Activator.CreateInstance(); protected abstract LazyResponses ClientUsage(); protected LazyResponses Calls( - Func, TResponse> fluent, - Func, Task> fluentAsync, - Func request, - Func> requestAsync + Func, TResponse> fluent, + Func, Task> fluentAsync, + Func request, + Func> requestAsync ) => new(async () => { var client = Client; - void IntegrateOnly(Action act) + void IntegrateOnly(Action act) { if (!TestClient.Configuration.RunIntegrationTests) return; diff --git a/tests/Tests/Framework/EndpointTests/TestState/EndpointUsage.cs b/tests/Tests/Framework/EndpointTests/TestState/EndpointUsage.cs index 543fa7e683d..7fcaae04205 100644 --- a/tests/Tests/Framework/EndpointTests/TestState/EndpointUsage.cs +++ b/tests/Tests/Framework/EndpointTests/TestState/EndpointUsage.cs @@ -51,16 +51,16 @@ public LazyResponses CallOnce(Func clientUsage, string key) public class SingleEndpointUsage : EndpointUsage where TResponse : class, IResponse { - private readonly Func _fluent; - private readonly Func> _fluentAsync; - private readonly Func _request; - private readonly Func> _requestAsync; + private readonly Func _fluent; + private readonly Func> _fluentAsync; + private readonly Func _request; + private readonly Func> _requestAsync; public SingleEndpointUsage( - Func fluent, - Func> fluentAsync, - Func request, - Func> requestAsync, + Func fluent, + Func> fluentAsync, + Func request, + Func> requestAsync, string valuePrefix = null ) : base(valuePrefix) { @@ -70,17 +70,17 @@ public SingleEndpointUsage( _requestAsync = requestAsync; } - public Action IntegrationSetup { get; set; } - public Action IntegrationTeardown { get; set; } - public Action OnAfterCall { get; set; } - public Action OnBeforeCall { get; set; } + public Action IntegrationSetup { get; set; } + public Action IntegrationTeardown { get; set; } + public Action OnAfterCall { get; set; } + public Action OnBeforeCall { get; set; } // ReSharper disable once StaticMemberInGenericType public static Randomizer Random { get; } = new(TestConfiguration.Instance.Seed); private LazyResponses Responses { get; set; } - public void KickOffOnce(IElasticsearchClient client, bool oneRandomCall = false) => + public void KickOffOnce(ElasticsearchClient client, bool oneRandomCall = false) => Responses = CallOnce(() => new LazyResponses(async () => { if (TestClient.Configuration.RunIntegrationTests) @@ -115,7 +115,7 @@ public void KickOffOnce(IElasticsearchClient client, bool oneRandomCall = false) return dict; })); - private void Call(IElasticsearchClient client, IDictionary dict, ClientMethod method, Func call) + private void Call(ElasticsearchClient client, IDictionary dict, ClientMethod method, Func call) { CallUniqueValues.CurrentView = method; OnBeforeCall?.Invoke(client); @@ -123,7 +123,7 @@ private void Call(IElasticsearchClient client, IDictionary dict, ClientMethod method, + private async Task CallAsync(ElasticsearchClient client, IDictionary dict, ClientMethod method, Func> call ) { diff --git a/tests/Tests/Framework/EndpointTests/UrlTester.cs b/tests/Tests/Framework/EndpointTests/UrlTester.cs index 64441cfe756..8750585bdd3 100644 --- a/tests/Tests/Framework/EndpointTests/UrlTester.cs +++ b/tests/Tests/Framework/EndpointTests/UrlTester.cs @@ -26,7 +26,7 @@ internal UrlTester(HttpMethod method, string expectedUrl, private HttpMethod ExpectedHttpMethod { get; } private string ExpectedUrl { get; } - private IElasticsearchClient Client { get; } + private ElasticsearchClient Client { get; } public static UrlTester ExpectUrl(HttpMethod method, string url, Func settings = null) => @@ -34,17 +34,17 @@ public static UrlTester ExpectUrl(HttpMethod method, string url, public static string EscapeUriString(string s) => Uri.EscapeDataString(s); - public UrlTester Fluent(Func call) where TResponse : IResponse => + public UrlTester Fluent(Func call) where TResponse : IResponse => WhenCalling(call, "fluent"); - public UrlTester Request(Func call) where TResponse : IResponse => + public UrlTester Request(Func call) where TResponse : IResponse => WhenCalling(call, "request"); - public Task FluentAsync(Func> call) + public Task FluentAsync(Func> call) where TResponse : IResponse => WhenCallingAsync(call, "fluent async"); - public Task RequestAsync(Func> call) + public Task RequestAsync(Func> call) where TResponse : IResponse => WhenCallingAsync(call, "request async"); @@ -59,14 +59,14 @@ public Task RequestAsync(Func(Func call, string typeOfCall) + private UrlTester WhenCalling(Func call, string typeOfCall) where TResponse : IResponse { var callDetails = call(Client); return Assert(typeOfCall, callDetails.ApiCall); } - internal async Task WhenCallingAsync(Func> call, + internal async Task WhenCallingAsync(Func> call, string typeOfCall) where TResponse : IResponse { diff --git a/tests/Tests/Framework/EndpointTests/UrlTesterExtensions.cs b/tests/Tests/Framework/EndpointTests/UrlTesterExtensions.cs index dd4955ea52c..34f26a084a2 100644 --- a/tests/Tests/Framework/EndpointTests/UrlTesterExtensions.cs +++ b/tests/Tests/Framework/EndpointTests/UrlTesterExtensions.cs @@ -10,10 +10,10 @@ namespace Tests.Framework.EndpointTests { public static class UrlTesterExtensions { - public static async Task RequestAsync(this Task tester, Func> call) + public static async Task RequestAsync(this Task tester, Func> call) where TResponse : IResponse => await (await tester).WhenCallingAsync(call, "request async"); - public static async Task FluentAsync(this Task tester, Func> call) + public static async Task FluentAsync(this Task tester, Func> call) where TResponse : IResponse => await (await tester).WhenCallingAsync(call, "fluent async"); } }