/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 7 - 2 0 1 9 ĠRe ece ĠH . ĠD un n Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġuk . co . re ec ed un n . intellij . plugin . core . tests . http . mime Ċ Ċ import Ġorg . apache . http . Header Ċ import Ġorg . apache . http . message . Basic Header Ċ import Ġorg . hamcrest . Core Matchers .` is ` Ċ import Ġorg . hamcrest . Core Matchers . null Value Ċ import Ġorg . junit . jupiter . api . DisplayName Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġuk . co . re ec ed un n . intellij . plugin . core . http . String Message Ċ import Ġuk . co . re ec ed un n . intellij . plugin . core . http . mime . Mime Response Ċ import Ġuk . co . re ec ed un n . intellij . plugin . core . tests . assertion . assertThat Ċ Ċ @ DisplayName (" Int elli J Ġ- ĠBase ĠPlatform Ġ- ĠRun ĠConfiguration Ġ- ĠX Query ĠProcessor Ġ- ĠMime Response ") Ċ class ĠMime Response Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" empty Ġresponse ") ĊĠĠĠ Ġfun Ġempty Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġ" 0 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 0 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is `( null Value ())) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Length "), Ġ` is ` (" 0 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is ` ("")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" simple Ġresponse Ġcontent ") ĊĠĠĠ Ġfun Ġsimple Response Content () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġ" 5 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" text / plain ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġ" Hello " ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 5 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Length "), Ġ` is ` (" 5 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is `( body )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" multipart Ġwith Ġa Ġsingle Ġpart ") ĊĠĠĠ Ġfun Ġmultipart With AS ingle Part () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġ" 9 8 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" multipart / mixed ; Ġboundary = 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Content - Type : Ġtext / plain ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Primitive : Ġinteger ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 1 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d -- ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"" ĊĠĠĠĠĠĠĠ Ġ). join ToString ("\ r \ n ") ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 9 8 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is ` (" multipart / mixed ; Ġboundary = 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is ` (" integer ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is ` (" 1 5 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" multipart Ġwith Ġa Ġsingle Ġpart Ġwith Ġoverridden ĠContent - Type ") ĊĠĠĠ Ġfun Ġmultipart With AS ingle Part With Over ridden ContentType () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠIf Ġa ĠMark Logic Ġquery Ġsets Ġthe ĠContent - Type Ġheader Ġfor Ġa Ġrequest , Ġthat Ġvalue Ġis Ġplaced ĊĠĠĠĠĠĠĠ Ġ// Ġbefore Ġthe ĠMark Logic Ġset Ġmultipart / mixed ĠContent - Type Ġheader . ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" text / rtf "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġ" 9 8 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" multipart / mixed ; Ġboundary = 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Content - Type : Ġtext / plain ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Primitive : Ġinteger ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 1 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 2 1 2 ab 9 5 a 3 4 6 4 3 c 9 d -- ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"" ĊĠĠĠĠĠĠĠ Ġ). join ToString ("\ r \ n ") ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 9 8 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is ` (" text / rtf ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is ` (" integer ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is ` (" 1 5 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" multipart Ġwith Ġmultiple Ġparts ") ĊĠĠĠ Ġfun Ġmultipart With Multiple Parts () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġ" 2 0 5 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" multipart / mixed ; Ġboundary = 4 7 c 8 1 3 e 0 bb fa 0 9 d 4 ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 4 7 c 8 1 3 e 0 bb fa 0 9 d 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Content - Type : Ġtext / plain ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Primitive : Ġinteger ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 4 7 c 8 1 3 e 0 bb fa 0 9 d 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Content - Type : Ġapplication / json ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Primitive : Ġnumber - node ()", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Path : Ġnumber - node ()", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 4 7 c 8 1 3 e 0 bb fa 0 9 d 4 -- ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"" ĊĠĠĠĠĠĠĠ Ġ). join ToString ("\ r \ n ") ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 2 0 5 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is ` (" multipart / mixed ; Ġboundary = 4 7 c 8 1 3 e 0 bb fa 0 9 d 4 ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is ` (" integer ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is ` (" 1 ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 1 ]. getHeader (" Content - Type "), Ġ` is ` (" application / json ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 1 ]. getHeader (" X - Primitive "), Ġ` is ` (" number - node () ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 1 ]. getHeader (" X - Path "), Ġ` is ` (" number - node () ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 1 ]. body , Ġ` is ` (" 5 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" multipart Ġwith Ġblank Ġline Ġin Ġpart Ġbody ") ĊĠĠĠ Ġfun Ġmultipart With Blank Line In Part Body () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 3 1 c 4 0 6 fa 2 9 f 1 2 0 2 9 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Content - Type : Ġtext / plain ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" X - Primitive : Ġstring ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ prefix Ġp 0 : Ġ< http :// example . co . uk / test > Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ prefix Ġsk os : Ġ< http :// www . w 3 . org / 2 0 0 4 / 0 2 / sk os / core #> Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" p 0 : case Ġa Ġsk os : Concept Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"-- 3 1 c 4 0 6 fa 2 9 f 1 2 0 2 9 -- ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"" ĊĠĠĠĠĠĠĠ Ġ). join ToString ("\ r \ n ") ĊĠĠĠĠĠĠĠ Ġval Ġheaders Ġ= ĠarrayOf < Header >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Length ", Ġbody . length . toString ()), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" Content - Type ", Ġ" multipart / mixed ; Ġboundary = 3 1 c 4 0 6 fa 2 9 f 1 2 0 2 9 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBasic Header (" X - Content - Type ", Ġ" text / tur tle ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠMime Response ( String Message ( headers , Ġbody )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts . size , Ġ` is `( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Length "), Ġ` is ` (" 2 2 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . getHeader (" Content - Type "), Ġ` is ` (" multipart / mixed ; Ġboundary = 3 1 c 4 0 6 fa 2 9 f 1 2 0 2 9 ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġpart 1 Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ prefix Ġp 0 : Ġ< http :// example . co . uk / test > Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ prefix Ġsk os : Ġ< http :// www . w 3 . org / 2 0 0 4 / 0 2 / sk os / core #> Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" p 0 : case Ġa Ġsk os : Concept Ġ. ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"" ĊĠĠĠĠĠĠĠ Ġ). join ToString ("\ r \ n ") ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" Content - Type "), Ġ` is ` (" text / plain ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Primitive "), Ġ` is ` (" string ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. getHeader (" X - Path "), Ġ` is `( null Value ())) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . parts [ 0 ]. body , Ġ` is `( part 1 )) ĊĠĠĠ Ġ} Ċ } Ċ