Skip to content

Commit dfc31c0

Browse files
committed
added tests to reproduce #1435
1 parent acf39c4 commit dfc31c0

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@
408408
<Compile Include="Reproduce\Reproduce1187Tests.cs" />
409409
<Compile Include="Reproduce\Reproduce901Tests.cs" />
410410
<Compile Include="Reproduce\Reproduce1320Tests.cs" />
411+
<Compile Include="Reproduce\Reproduce1435Tests.cs" />
411412
<Compile Include="Reproduce\Reproduce990Tests.cs" />
412413
<Compile Include="Reproduce\Reproduce974Tests.cs" />
413414
<Compile Include="Reproduce\Reproduce928Tests.cs" />
@@ -833,6 +834,9 @@
833834
<None Include="QueryParsers\Filter\Term.json">
834835
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
835836
</None>
837+
<None Include="Reproduce\OISAggs.json">
838+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
839+
</None>
836840
<None Include="Reproduce\Issue1199Index.json">
837841
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
838842
</None>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"aggs": {
3+
"my_aggregation": {
4+
"filter": {
5+
"fquery": {
6+
"query": {
7+
"query_string": {
8+
"query": "Just an example"
9+
}
10+
}
11+
}
12+
}
13+
}
14+
}
15+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Nest.Tests.MockData.Domain;
6+
using NUnit.Framework;
7+
8+
namespace Nest.Tests.Unit.Reproduce
9+
{
10+
/// <summary>
11+
/// tests to reproduce reported errors
12+
/// </summary>
13+
[TestFixture]
14+
public class Reproduce1435Tests : BaseJsonTests
15+
{
16+
[Test]
17+
public void UsingExplicitCasts()
18+
{
19+
var aggregations = new Dictionary<string, IAggregationContainer>
20+
{
21+
{
22+
//Aggregators missing implicit casts to AggregationContainer
23+
"my_aggregation", new AggregationContainer
24+
{
25+
Filter = new FilterAggregator
26+
{
27+
Filter = (FilterContainer)new QueryFilter
28+
{
29+
Query = (QueryContainer)new QueryStringQuery
30+
{
31+
Query = "Just an example"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
};
38+
39+
var result = this._client.Search<ElasticsearchProject>(new SearchRequest<ElasticsearchProject>
40+
{
41+
Aggregations = aggregations
42+
});
43+
44+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod(), "OISAggs");
45+
}
46+
47+
[Test]
48+
public void UsingConstructor()
49+
{
50+
var aggregations = new Dictionary<string, IAggregationContainer>
51+
{
52+
{
53+
//AggregationContaner should accept aggregators in constructor
54+
"my_aggregation", new AggregationContainer
55+
{
56+
Filter = new FilterAggregator
57+
{
58+
Filter = new FilterContainer(new QueryFilter
59+
{
60+
Query = new QueryContainer(new QueryStringQuery
61+
{
62+
Query = "Just an example"
63+
})
64+
})
65+
}
66+
}
67+
}
68+
};
69+
70+
var result = this._client.Search<ElasticsearchProject>(new SearchRequest<ElasticsearchProject>
71+
{
72+
Aggregations = aggregations
73+
});
74+
75+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod(), "OISAggs");
76+
}
77+
78+
[Test]
79+
public void UsingToContainer()
80+
{
81+
var aggregations = new Dictionary<string, IAggregationContainer>
82+
{
83+
{
84+
"my_aggregation", new AggregationContainer
85+
{
86+
Filter = new FilterAggregator
87+
{
88+
Filter = new QueryFilter
89+
{
90+
Query = new QueryStringQuery
91+
{
92+
Query = "Just an example"
93+
}.ToContainer()
94+
}.ToContainer()
95+
} //Aggregator is missing ToContainer()
96+
}
97+
}
98+
};
99+
100+
var result = this._client.Search<ElasticsearchProject>(new SearchRequest<ElasticsearchProject>
101+
{
102+
Aggregations = aggregations
103+
});
104+
105+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod(), "OISAggs");
106+
}
107+
108+
[Test]
109+
public void Using()
110+
{
111+
var aggregations = new Dictionary<string, IAggregationContainer>
112+
{
113+
{
114+
"my_aggregation", new AggregationContainer
115+
{
116+
Filter = new FilterAggregator
117+
{
118+
Filter = new QueryFilter
119+
{
120+
Query = new QueryStringQuery
121+
{
122+
Query = "Just an example"
123+
}.ToContainer()
124+
}.ToContainer()
125+
} //Aggregator is missing ToContainer()
126+
}
127+
}
128+
};
129+
130+
var result = this._client.Search<ElasticsearchProject>(new SearchRequest<ElasticsearchProject>
131+
{
132+
Aggregations = aggregations
133+
});
134+
135+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod(), "OISAggs");
136+
}
137+
138+
139+
}
140+
}

0 commit comments

Comments
 (0)