|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using Nest.Tests.MockData; |
| 5 | +using Nest.Tests.MockData.Domain; |
| 6 | +using NUnit.Framework; |
| 7 | +using System.Diagnostics; |
| 8 | +using FluentAssertions; |
| 9 | + |
| 10 | +namespace Nest.Tests.Integration.Reproduce |
| 11 | +{ |
| 12 | + /// <summary> |
| 13 | + /// tests to reproduce reported errors |
| 14 | + /// </summary> |
| 15 | + [TestFixture] |
| 16 | + public class Reproduce319Tests : IntegrationTests |
| 17 | + { |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// https://github.com/Mpdreamz/NEST/issues/319 |
| 21 | + /// </summary> |
| 22 | + [Test] |
| 23 | + public void CreateIndexShouldNotThrowNullReference() |
| 24 | + { |
| 25 | + var settings = new IndexSettings(); |
| 26 | + settings.Similarity = new SimilaritySettings(); |
| 27 | + settings.NumberOfReplicas = 1; |
| 28 | + settings.NumberOfShards = 5; |
| 29 | + settings.Add("index.refresh_interval", "10s"); |
| 30 | + settings.Add("merge.policy.merge_factor", "10"); |
| 31 | + settings.Add("search.slowlog.threshold.fetch.warn", "1s"); |
| 32 | + settings.Analysis.Analyzers.Add(new KeyValuePair<string, AnalyzerBase>("keyword", new KeywordAnalyzer())); |
| 33 | + settings.Analysis.Analyzers.Add(new KeyValuePair<string, AnalyzerBase>("simple", new SimpleAnalyzer())); |
| 34 | + settings.Mappings.Add(new RootObjectMapping |
| 35 | + { |
| 36 | + Name = "my_root_object", |
| 37 | + Properties = new Dictionary<string, IElasticType> |
| 38 | + { |
| 39 | + {"my_field", new StringMapping() { Name = "my_string_field "}} |
| 40 | + } |
| 41 | + }); |
| 42 | + |
| 43 | + Assert.DoesNotThrow(() => |
| 44 | + { |
| 45 | + var idxRsp = this._client.CreateIndex(ElasticsearchConfiguration.NewUniqueIndexName(), settings); |
| 46 | + Assert.IsTrue(idxRsp.IsValid, idxRsp.ConnectionStatus.ToString()); |
| 47 | + }); |
| 48 | + } |
| 49 | + |
| 50 | + } |
| 51 | +} |
0 commit comments