@@ -32,7 +32,7 @@ protected override LazyResponses ClientUsage() => Calls(
3232
3333 protected override bool SupportsDeserialization => false ;
3434
35- protected override object ExpectJson => new
35+ protected override object ExpectJson => new
3636 {
3737 ids = this . _ids
3838 } ;
@@ -53,7 +53,7 @@ protected override void ExpectResponse(IMultiGetResponse response)
5353 . Index < Developer > ( )
5454 . Type < Developer > ( )
5555 . GetMany < Developer > ( this . _ids ) ;
56-
56+
5757
5858 protected override MultiGetRequest Initializer => new MultiGetRequest ( Index < Developer > ( ) , Type < Developer > ( ) )
5959 {
@@ -82,7 +82,7 @@ protected override LazyResponses ClientUsage() => Calls(
8282
8383 protected override bool SupportsDeserialization => false ;
8484
85- protected override object ExpectJson { get ; } = new
85+ protected override object ExpectJson { get ; } = new
8686 {
8787 docs = Developer . Developers . Select ( p => new { _type = "developer" , _id = p . Id , _routing = p . Id . ToString ( ) , _source = false } ) . Take ( 10 )
8888 } ;
@@ -109,4 +109,109 @@ protected override void ExpectResponse(IMultiGetResponse response)
109109 }
110110 }
111111 }
112+
113+ [ Collection ( IntegrationContext . ReadOnly ) ]
114+ public class MultiGetMetadataApiTests : ApiIntegrationTestBase < IMultiGetResponse , IMultiGetRequest , MultiGetDescriptor , MultiGetRequest >
115+ {
116+ public MultiGetMetadataApiTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
117+ protected override LazyResponses ClientUsage ( ) => Calls (
118+ fluent : ( client , f ) => client . MultiGet ( f ) ,
119+ fluentAsync : ( client , f ) => client . MultiGetAsync ( f ) ,
120+ request : ( client , r ) => client . MultiGet ( r ) ,
121+ requestAsync : ( client , r ) => client . MultiGetAsync ( r )
122+ ) ;
123+
124+ private IEnumerable < string > _ids = Project . Projects . Select ( d => d . Name ) . Take ( 10 ) ;
125+
126+ protected override bool ExpectIsValid => true ;
127+ protected override int ExpectStatusCode => 200 ;
128+ protected override HttpMethod HttpMethod => HttpMethod . POST ;
129+ protected override string UrlPath => $ "/project/project/_mget";
130+
131+ protected override bool SupportsDeserialization => false ;
132+
133+ protected override object ExpectJson => new
134+ {
135+ ids = this . _ids
136+ } ;
137+
138+ protected override Func < MultiGetDescriptor , IMultiGetRequest > Fluent => d => d
139+ . Index < Project > ( )
140+ . Type < Project > ( )
141+ . GetMany < Project > ( this . _ids ) ;
142+
143+ protected override MultiGetRequest Initializer => new MultiGetRequest ( Index < Project > ( ) , Type < Project > ( ) )
144+ {
145+ Documents = this . _ids . Select ( n => new MultiGetOperation < Project > ( n ) )
146+ } ;
147+
148+ protected override void ExpectResponse ( IMultiGetResponse response )
149+ {
150+ response . Documents . Should ( ) . NotBeEmpty ( ) . And . HaveCount ( 10 ) ;
151+
152+ foreach ( var hit in response . GetMany < Project > ( _ids ) )
153+ {
154+ hit . Index . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
155+ hit . Type . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
156+ hit . Id . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
157+ hit . Found . Should ( ) . BeTrue ( ) ;
158+ hit . Version . Should ( ) . Be ( 1 ) ;
159+ hit . Timestamp . HasValue . Should ( ) . BeTrue ( ) ;
160+ hit . Ttl . HasValue . Should ( ) . BeTrue ( ) ;
161+ }
162+ }
163+ }
164+
165+ [ Collection ( IntegrationContext . ReadOnly ) ]
166+ public class MultiGetParentApiTests : ApiIntegrationTestBase < IMultiGetResponse , IMultiGetRequest , MultiGetDescriptor , MultiGetRequest >
167+ {
168+ public MultiGetParentApiTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
169+ protected override LazyResponses ClientUsage ( ) => Calls (
170+ fluent : ( client , f ) => client . MultiGet ( f ) ,
171+ fluentAsync : ( client , f ) => client . MultiGetAsync ( f ) ,
172+ request : ( client , r ) => client . MultiGet ( r ) ,
173+ requestAsync : ( client , r ) => client . MultiGetAsync ( r )
174+ ) ;
175+
176+ private IEnumerable < CommitActivity > _activities = CommitActivity . CommitActivities . Take ( 10 ) ;
177+
178+ protected override bool ExpectIsValid => true ;
179+ protected override int ExpectStatusCode => 200 ;
180+ protected override HttpMethod HttpMethod => HttpMethod . POST ;
181+ protected override string UrlPath => $ "/project/commits/_mget";
182+
183+ protected override bool SupportsDeserialization => false ;
184+
185+ protected override object ExpectJson => new
186+ {
187+ docs = _activities . Select ( p => new { _id = p . Id , _routing = p . ProjectName } )
188+ } ;
189+
190+ protected override Func < MultiGetDescriptor , IMultiGetRequest > Fluent => d => d
191+ . Index < Project > ( )
192+ . Type < CommitActivity > ( )
193+ . GetMany < CommitActivity > ( this . _activities . Select ( c => c . Id ) , ( m , id ) => m . Routing ( _activities . Single ( a => a . Id == id ) . ProjectName ) ) ;
194+
195+ protected override MultiGetRequest Initializer => new MultiGetRequest ( Index < Project > ( ) , Type < CommitActivity > ( ) )
196+ {
197+ Documents = this . _activities . Select ( n => new MultiGetOperation < CommitActivity > ( n . Id ) { Routing = n . ProjectName } )
198+ } ;
199+
200+ protected override void ExpectResponse ( IMultiGetResponse response )
201+ {
202+ response . Documents . Should ( ) . NotBeEmpty ( ) . And . HaveCount ( 10 ) ;
203+
204+ foreach ( var hit in response . GetMany < CommitActivity > ( _activities . Select ( c => c . Id ) ) )
205+ {
206+ hit . Index . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
207+ hit . Type . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
208+ hit . Id . Should ( ) . NotBeNullOrWhiteSpace ( ) ;
209+ hit . Found . Should ( ) . BeTrue ( ) ;
210+ hit . Version . Should ( ) . Be ( 1 ) ;
211+ hit . Timestamp . HasValue . Should ( ) . BeTrue ( ) ;
212+ hit . Parent . Should ( ) . NotBeNullOrEmpty ( ) ;
213+ hit . Routing . Should ( ) . NotBeNullOrEmpty ( ) ;
214+ }
215+ }
216+ }
112217}
0 commit comments