1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using Elasticsearch . Net ;
4
+ using FluentAssertions ;
4
5
using Nest ;
5
6
using Tests . Framework ;
6
7
using Tests . Framework . Integration ;
10
11
namespace Tests . Indices . IndexSettings . IndexTemplates . PutIndexTemplate
11
12
{
12
13
public class PutIndexTemplateApiTests
13
- : ApiTestBase < WritableCluster , IPutIndexTemplateResponse , IPutIndexTemplateRequest , PutIndexTemplateDescriptor , PutIndexTemplateRequest >
14
+ : ApiIntegrationTestBase < WritableCluster , IPutIndexTemplateResponse , IPutIndexTemplateRequest , PutIndexTemplateDescriptor , PutIndexTemplateRequest >
14
15
{
15
16
public PutIndexTemplateApiTests ( WritableCluster cluster , EndpointUsage usage ) : base ( cluster , usage )
16
17
{
@@ -24,14 +25,15 @@ protected override LazyResponses ClientUsage() => Calls(
24
25
) ;
25
26
26
27
protected override HttpMethod HttpMethod => HttpMethod . PUT ;
27
-
28
28
protected override string UrlPath => $ "/_template/{ CallIsolatedValue } ?create=false";
29
-
30
29
protected override bool SupportsDeserialization => false ;
30
+ protected override int ExpectStatusCode => 200 ;
31
+ protected override bool ExpectIsValid => true ;
31
32
32
33
protected override object ExpectJson { get ; } = new
33
34
{
34
35
order = 1 ,
36
+ version = 2 ,
35
37
index_patterns = new [ ] { "nestx-*" } ,
36
38
settings = new Dictionary < string , object > { { "index.number_of_shards" , 1 } } ,
37
39
mappings = new
@@ -61,6 +63,7 @@ protected override LazyResponses ClientUsage() => Calls(
61
63
62
64
protected override Func < PutIndexTemplateDescriptor , IPutIndexTemplateRequest > Fluent => d => d
63
65
. Order ( 1 )
66
+ . Version ( 2 )
64
67
. IndexPatterns ( "nestx-*" )
65
68
. Create ( false )
66
69
. Settings ( p=> p . NumberOfShards ( 1 ) )
@@ -80,9 +83,12 @@ protected override LazyResponses ClientUsage() => Calls(
80
83
)
81
84
) ;
82
85
86
+
87
+
83
88
protected override PutIndexTemplateRequest Initializer => new PutIndexTemplateRequest ( CallIsolatedValue )
84
89
{
85
90
Order = 1 ,
91
+ Version = 2 ,
86
92
IndexPatterns = new [ ] { "nestx-*" } ,
87
93
Create = false ,
88
94
Settings = new Nest . IndexSettings
@@ -110,5 +116,11 @@ protected override LazyResponses ClientUsage() => Calls(
110
116
}
111
117
}
112
118
} ;
119
+
120
+ protected override void ExpectResponse ( IPutIndexTemplateResponse response )
121
+ {
122
+ response . ShouldBeValid ( ) ;
123
+ response . Acknowledged . Should ( ) . BeTrue ( ) ;
124
+ }
113
125
}
114
126
}
0 commit comments