22using NUnit . Framework ;
33using System ;
44using System . Collections . Generic ;
5+ using System . IO ;
56using System . Linq ;
67using System . Text ;
78using System . Threading . Tasks ;
@@ -12,12 +13,56 @@ namespace Nest.Tests.Unit.Cluster
1213 public class PendingTasksTests : BaseJsonTests
1314 {
1415 [ Test ]
15- public void Url ( )
16+ public void RequestUrlTest ( )
1617 {
1718 var r = this . _client . ClusterPendingTasks ( ) ;
1819 var status = r . ConnectionStatus ;
1920 var url = new Uri ( status . RequestUrl ) ;
2021 url . AbsolutePath . Should ( ) . StartWith ( "/_cluster/pending_tasks" ) ;
2122 }
23+
24+ [ Test ]
25+ public void ResponseBodyJsonTest ( )
26+ {
27+ var json = @"{
28+ tasks: [
29+ {
30+ insert_order: 101,
31+ priority: ""URGENT"",
32+ source: ""create-index [foo_9], cause [api]"",
33+ time_in_queue_millis: 86,
34+ time_in_queue: ""86ms""
35+ },
36+ {
37+ insert_order: 46,
38+ priority: ""HIGH"",
39+ source: ""shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from gateway]"",
40+ time_in_queue_millis: 842,
41+ time_in_queue: ""842ms""
42+ }
43+ ]
44+ }" ;
45+
46+ var bytes = System . Text . Encoding . UTF8 . GetBytes ( json ) ;
47+ var stream = new MemoryStream ( bytes ) ;
48+
49+ var response = _client . Serializer . Deserialize < ClusterPendingTasksResponse > ( stream ) ;
50+ response . Should ( ) . NotBeNull ( ) ;
51+ response . Tasks . Count ( ) . ShouldBeEquivalentTo ( 2 ) ;
52+
53+ var task1 = response . Tasks . ElementAt ( 0 ) ;
54+ task1 . InsertOrder . ShouldBeEquivalentTo ( 101 ) ;
55+ task1 . Priority . ShouldBeEquivalentTo ( "URGENT" ) ;
56+ task1 . Source . ShouldBeEquivalentTo ( "create-index [foo_9], cause [api]" ) ;
57+ task1 . TimeInQueueMilliseconds . ShouldBeEquivalentTo ( 86 ) ;
58+ task1 . TimeInQueue . ShouldBeEquivalentTo ( "86ms" ) ;
59+
60+ var task2 = response . Tasks . ElementAt ( 1 ) ;
61+ task2 . InsertOrder . ShouldBeEquivalentTo ( 46 ) ;
62+ task2 . Priority . ShouldBeEquivalentTo ( "HIGH" ) ;
63+ task2 . Source . ShouldBeEquivalentTo ( "shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from gateway]" ) ;
64+ task2 . TimeInQueueMilliseconds . ShouldBeEquivalentTo ( 842 ) ;
65+ task2 . TimeInQueue . ShouldBeEquivalentTo ( "842ms" ) ;
66+ }
2267 }
23- }
68+ }
0 commit comments