|
2 | 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3 | 3 | // See the LICENSE file in the project root for more information
|
4 | 4 |
|
5 |
| -using System; |
| 5 | +using System; |
6 | 6 | using System.Linq;
|
| 7 | +using Elastic.Elasticsearch.Xunit.XunitPlumbing; |
7 | 8 | using Elasticsearch.Net;
|
8 | 9 | using FluentAssertions;
|
9 | 10 | using Nest;
|
@@ -69,4 +70,64 @@ protected override void ExpectResponse(FieldCapabilitiesResponse response)
|
69 | 70 | jobTitleCapabilities.Searchable.Should().BeTrue();
|
70 | 71 | }
|
71 | 72 | }
|
| 73 | + |
| 74 | + [SkipVersion("<7.9.0", "index filter introduced in 7.9.0")] |
| 75 | + public class FieldCapabilitiesIndexFilterApiTests |
| 76 | + : ApiIntegrationTestBase<ReadOnlyCluster, FieldCapabilitiesResponse, IFieldCapabilitiesRequest, FieldCapabilitiesDescriptor, |
| 77 | + FieldCapabilitiesRequest> |
| 78 | + { |
| 79 | + public FieldCapabilitiesIndexFilterApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
| 80 | + |
| 81 | + protected override object ExpectJson => new |
| 82 | + { |
| 83 | + index_filter = new |
| 84 | + { |
| 85 | + term = new |
| 86 | + { |
| 87 | + versionControl = new |
| 88 | + { |
| 89 | + value = "git" |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + }; |
| 94 | + |
| 95 | + protected override bool SupportsDeserialization { get; } = false; |
| 96 | + |
| 97 | + protected override bool ExpectIsValid => true; |
| 98 | + |
| 99 | + protected override int ExpectStatusCode => 200; |
| 100 | + |
| 101 | + protected override Func<FieldCapabilitiesDescriptor, IFieldCapabilitiesRequest> Fluent => d => d |
| 102 | + .Fields("*") |
| 103 | + .IndexFilter<Project>(q => q |
| 104 | + .Term(t => t |
| 105 | + .Field(f => f.VersionControl) |
| 106 | + .Value(Project.VersionControlConstant) |
| 107 | + ) |
| 108 | + ); |
| 109 | + |
| 110 | + protected override HttpMethod HttpMethod => HttpMethod.POST; |
| 111 | + |
| 112 | + protected override FieldCapabilitiesRequest Initializer => new FieldCapabilitiesRequest(Index<Project>().And<Developer>()) |
| 113 | + { |
| 114 | + Fields = "*", |
| 115 | + IndexFilter = new TermQuery |
| 116 | + { |
| 117 | + Field = Field<Project>(f => f.VersionControl), |
| 118 | + Value = Project.VersionControlConstant |
| 119 | + } |
| 120 | + }; |
| 121 | + |
| 122 | + protected override string UrlPath => "/project%2Cdevs/_field_caps?fields=%2A"; |
| 123 | + |
| 124 | + protected override LazyResponses ClientUsage() => Calls( |
| 125 | + (c, f) => c.FieldCapabilities(Index<Project>().And<Developer>(), f), |
| 126 | + (c, f) => c.FieldCapabilitiesAsync(Index<Project>().And<Developer>(), f), |
| 127 | + (c, r) => c.FieldCapabilities(r), |
| 128 | + (c, r) => c.FieldCapabilitiesAsync(r) |
| 129 | + ); |
| 130 | + |
| 131 | + protected override void ExpectResponse(FieldCapabilitiesResponse response) => response.ShouldBeValid(); |
| 132 | + } |
72 | 133 | }
|
0 commit comments