package Ġnet . cod inux . log . elasticsearch . util Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . github . tom ake hur st . wire mock . Wire Mock Server Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock .* Ċ import Ġcom . github . tom ake hur st . wire mock . http . Http Header Ċ import Ġcom . github . tom ake hur st . wire mock . http . HttpHeaders Ċ import Ġcom . github . tom ake hur st . wire mock . matching . EqualTo Pattern Ċ import Ġnet . cod inux . log . elasticsearch . es _ model .* ĊĊ Ċ class ĠTest Data Creator Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠIndex Name Ġ= Ġ" test - index " ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠExcept ed Elasticsearch Url Ġ= Ġ"/ _ bulk " ĊĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠElasticsearch Info ResponseBody Ġ= Ġ" {\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ\" name \" Ġ: Ġ\" 1 0 bfd 6 ace 8 bc \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ\" cluster _ name \" Ġ: Ġ\" docker - cluster \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ\" cluster _ uuid \" Ġ: Ġ\" m SO q 8 WK CT dig Sc Tr Q Ex A ig \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ\" version \" Ġ: Ġ{\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" number \" Ġ: Ġ\" 7 . 1 4 . 0 \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" build _ flavor \" Ġ: Ġ\" default \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" build _ type \" Ġ: Ġ\" docker \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" build _ hash \" Ġ: Ġ\" dd 5 a 0 a 2 ac aa 2 0 4 5 ff 9 6 2 4 f 3 7 2 9 fc 8 a 6 f 4 0 8 3 5 aa 1 \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" build _ date \" Ġ: Ġ\" 2 0 2 1 - 0 7 - 2 9 T 2 0 : 4 9 : 3 2 . 8 6 4 1 3 5 0 6 3 Z \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" build _ snapshot \" Ġ: Ġfalse ,\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" lucene _ version \" Ġ: Ġ\" 8 . 9 . 0 \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" minimum _ wire _ compatibility _ version \" Ġ: Ġ\" 6 . 8 . 0 \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" minimum _ index _ compatibility _ version \" Ġ: Ġ\" 6 . 0 . 0 - beta 1 \"\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ},\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ\" tag line \" Ġ: Ġ\" You ĠK now , Ġfor ĠSearch \"\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" }\ n " ĊĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠElasticsearch Response Headers Ġ= ĠHttp Headers ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHttp Header (" X - elastic - product ", Ġ" Elasticsearch "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHttp Header (" content - type ", Ġ" application / json ; Ġcharset = UTF - 8 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠIndex ing Failed Type Ġ= Ġ" es _ rejected _ execution _ exception " ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠIndex ing Failed Reason Ġ= Ġ" rejected Ġexecution Ġof Ġorg . elasticsearch . transport . Transport Service \$ 7 @ 2 2 7 3 4 9 ba Ġon ĠEs ThreadPoolExecutor " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"[ bulk , Ġqueue Ġcapacity Ġ= Ġ 2 0 0 , Ġorg . elasticsearch . common . util . concurrent . Es ThreadPoolExecutor @ 4 d 3 e 4 d 9 1 [ Running , Ġpool Ġsize Ġ= Ġ 4 , Ġactive Ġthreads Ġ= Ġ 4 , Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" queued Ġtasks Ġ= Ġ 2 0 2 , Ġcompleted Ġtasks Ġ= Ġ 2 1 0 0 4 0 ]] " ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġmapper Ġ= ĠObjectMapper () ĊĊĊĠĠĠ Ġfun Ġmock Indexing Success Response ( es Mock : ĠWire Mock Server ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Indexing Response ( es Mock , Ġcreate Indexing Success Response ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmock Indexing Failure Response ( es Mock : ĠWire Mock Server ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Indexing Response ( es Mock , Ġcreate Indexing Failure Response ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmock Indexing Response ( es Mock : ĠWire Mock Server , Ġbody : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġes Mock . stub For ( post ( urlPath EqualTo ( Except ed Elasticsearch Url )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Header (" content - type ", ĠEqual To Pattern (" application / json ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ok (). with Headers ( Elasticsearch Response Headers ). with Body ( body ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmock Elasticsearch Info Request ( es Mock : ĠWire Mock Server ) Ġ{ ĊĠĠĠĠĠĠĠ Ġes Mock . stub For ( get ( urlPath EqualTo ("/ ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ok (). with Headers ( Elasticsearch Response Headers ). with Body ( Elasticsearch Info ResponseBody ))) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġprivate Ġfun Ġcreate Indexing Success Response (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠBulk Response ( 8 , Ġfalse , ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Container Item ( Response Item Base ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIndex Name , Ġ 2 0 1 , Ġ" 7 r I 3 f 3 s B zy 2 3 N 1 EW gj PP ", Ġ" created ", Ġ 1 , Ġ"_ doc ", Ġ 2 , Ġ 9 , Ġcreate Shard Statistics () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠ Ġ)) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġmap ToJson ( response ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Indexing Failure Response (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠBulk Response ( 8 , Ġtrue , ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Container Item ( Response Item Base ( Index Name , Ġ 4 2 9 , Ġ" 7 r I 3 f 3 s B zy 2 3 N 1 EW gj PP ", Ġerror Ġ= Ġcreate Error Cause ())) ĊĠĠĠĠĠĠĠ Ġ)) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġmap ToJson ( response ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Error Cause () Ġ= ĠError Cause ( Indexing Failed Type , ĠIndex ing Failed Reason ) ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Shard Statistics () Ġ= ĠSh ard Statistics ( 2 , Ġ 1 , Ġ 0 ) ĊĊĠĠĠ Ġprivate Ġfun Ġmap ToJson ( response : ĠBulk Response ) Ġ= Ġmapper . writeValue AsString ( response ) Ċ Ċ }