|
| 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