Skip to content

Commit

Permalink
fix failing test due to elastic/elasticsearch#31507 which failed due …
Browse files Browse the repository at this point in the history
…to us using IgnoreUnavailable which was basically ignored in previous version
  • Loading branch information
Mpdreamz committed Sep 20, 2018
1 parent 63edd99 commit e0d7e95
Showing 1 changed file with 33 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GetMappingApiTests : ApiIntegrationTestBase<ReadOnlyCluster, IGetMa
{
public GetMappingApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override LazyResponses ClientUsage() => Calls(
protected override LazyResponses ClientUsage() => this.Calls(
fluent: (client, f) => client.GetMapping<Project>(f),
fluentAsync: (client, f) => client.GetMappingAsync<Project>(f),
request: (client, r) => client.GetMapping(r),
Expand Down Expand Up @@ -114,7 +114,7 @@ public class GetMappingNonExistentIndexApiTests : ApiIntegrationTestBase<ReadOnl

public GetMappingNonExistentIndexApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override LazyResponses ClientUsage() => Calls(
protected override LazyResponses ClientUsage() => this.Calls(
fluent: (client, f) => client.GetMapping<Project>(f),
fluentAsync: (client, f) => client.GetMappingAsync<Project>(f),
request: (client, r) => client.GetMapping(r),
Expand All @@ -124,17 +124,13 @@ public class GetMappingNonExistentIndexApiTests : ApiIntegrationTestBase<ReadOnl
protected override bool ExpectIsValid => false;
protected override int ExpectStatusCode => 404;
protected override HttpMethod HttpMethod => HttpMethod.GET;
protected override string UrlPath => $"/{_nonExistentIndex}/_mapping?ignore_unavailable=true";
protected override string UrlPath => $"/{_nonExistentIndex}/_mapping";

protected override Func<GetMappingDescriptor<Project>, IGetMappingRequest> Fluent => d => d
.Index(_nonExistentIndex)
.AllTypes()
.IgnoreUnavailable();
.AllTypes();

protected override GetMappingRequest Initializer => new GetMappingRequest(_nonExistentIndex, AllTypes)
{
IgnoreUnavailable = true
};
protected override GetMappingRequest Initializer => new GetMappingRequest(_nonExistentIndex, AllTypes);

protected override void ExpectResponse(IGetMappingResponse response)
{
Expand All @@ -145,22 +141,20 @@ protected override void ExpectResponse(IGetMappingResponse response)

internal class TestVisitor : IMappingVisitor
{
public TestVisitor()
{
Counts = new Dictionary<string, int>();
}
public TestVisitor() => this.Counts = new Dictionary<string, int>();

public int Depth { get; set; }

public Dictionary<string, int> Counts { get; }

private void Increment(string key)
{
if (!Counts.ContainsKey(key))
if (!this.Counts.ContainsKey(key))
{
Counts.Add(key, 0);
this.Counts.Add(key, 0);
}
Counts[key] += 1;

this.Counts[key] += 1;
}

public void CountsShouldContainKeyAndCountBe(string key, int count)
Expand All @@ -172,119 +166,50 @@ public void CountsShouldContainKeyAndCountBe(string key, int count)
this.Counts[key].Should().Be(count, because);
}

public void Visit(IDateProperty mapping)
{
Increment("date");
}
public void Visit(IDateProperty mapping) => this.Increment("date");

public void Visit(IBinaryProperty mapping)
{
Increment("binary");
}
public void Visit(IBinaryProperty mapping) => this.Increment("binary");

public void Visit(INestedProperty mapping)
{
Increment("nested");
}
public void Visit(INestedProperty mapping) => this.Increment("nested");

public void Visit(IGeoPointProperty mapping)
{
Increment("geo_point");
}
public void Visit(IGeoPointProperty mapping) => this.Increment("geo_point");

public void Visit(ICompletionProperty mapping)
{
Increment("completion");
}
public void Visit(ICompletionProperty mapping) => this.Increment("completion");

public void Visit(ITokenCountProperty mapping)
{
Increment("token_count");
}
public void Visit(ITokenCountProperty mapping) => this.Increment("token_count");

public void Visit(IPercolatorProperty property)
{
Increment("percolator");
}
public void Visit(IPercolatorProperty property) => this.Increment("percolator");

public void Visit(IIntegerRangeProperty property)
{
Increment("integer_range");
}
public void Visit(IIntegerRangeProperty property) => this.Increment("integer_range");

public void Visit(IFloatRangeProperty property)
{
Increment("float_range");
}
public void Visit(IFloatRangeProperty property) => this.Increment("float_range");

public void Visit(ILongRangeProperty property)
{
Increment("long_range");
}
public void Visit(ILongRangeProperty property) => this.Increment("long_range");

public void Visit(IDoubleRangeProperty property)
{
Increment("double_range");
}
public void Visit(IDoubleRangeProperty property) => this.Increment("double_range");

public void Visit(IDateRangeProperty property)
{
Increment("date_range");
}
public void Visit(IDateRangeProperty property) => this.Increment("date_range");

public void Visit(IIpRangeProperty property)
{
Increment("ip_range");
}
public void Visit(IIpRangeProperty property) => this.Increment("ip_range");

public void Visit(IJoinProperty property)
{
Increment("join");
}
public void Visit(IJoinProperty property) => this.Increment("join");

public void Visit(IMurmur3HashProperty mapping)
{
Increment("murmur3");
}
public void Visit(IMurmur3HashProperty mapping) => this.Increment("murmur3");

public void Visit(INumberProperty mapping)
{
Increment("number");
}
public void Visit(INumberProperty mapping) => this.Increment("number");

public void Visit(IGeoShapeProperty mapping)
{
Increment("geo_shape");
}
public void Visit(IGeoShapeProperty mapping) => this.Increment("geo_shape");

public void Visit(IIpProperty mapping)
{
Increment("ip");
}
public void Visit(IIpProperty mapping) => this.Increment("ip");

public void Visit(IObjectProperty mapping)
{
Increment("object");
}
public void Visit(IObjectProperty mapping) => this.Increment("object");

public void Visit(IBooleanProperty mapping)
{
Increment("boolean");
}
public void Visit(IBooleanProperty mapping) => this.Increment("boolean");

public void Visit(ITextProperty mapping)
{
Increment("text");
}
public void Visit(ITextProperty mapping) => this.Increment("text");

public void Visit(IKeywordProperty mapping)
{
Increment("keyword");
}
public void Visit(IKeywordProperty mapping) => this.Increment("keyword");

public void Visit(ITypeMapping mapping)
{
Increment("type");
}
public void Visit(ITypeMapping mapping) => this.Increment("type");
}
}

0 comments on commit e0d7e95

Please sign in to comment.