package Ġme . pro xer . library . internal . interceptor Ċ Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . slot Ċ import Ġme . pro xer . library . Build Config . VERSION Ċ import Ġme . pro xer . library . Pro xer Api Ċ import Ġme . pro xer . library . Pro xer Test Ċ import Ġme . pro xer . library . run Request Ċ import Ġme . pro xer . library . util . Pro xer Urls Ċ import Ġokhttp 3 . Interceptor Ċ import Ġokhttp 3 . Request Ċ import Ġorg . am sh ove . k lu ent . inv oking Ċ import Ġorg . am sh ove . k lu ent . shouldBe Ċ import Ġorg . am sh ove . k lu ent . shouldBe EqualTo Ċ import Ġorg . am sh ove . k lu ent . shouldBe Null Ċ import Ġorg . am sh ove . k lu ent . should Throw Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ /** Ċ Ġ* Ġ@ author ĠRub en ĠGe es Ċ Ġ*/ Ċ class ĠHeader Interceptor Test Ġ: ĠPro xer Test () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġinterceptor Ġ= ĠHeader Interceptor (" mock - key ", Ġ" mock - user - agent ") ĊĠĠĠ Ġprivate Ġval Ġrequest Slot Ġ= Ġslot < Request >() ĊĊĠĠĠ Ġprivate Ġval Ġchain Ġ= Ġmock k < Interceptor . Chain >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġproceed ( capture ( request Slot )) Ġ} Ġreturns Ġmock k () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest ApiKey () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġrequest ) Ġ= Ġserver . run Request (" news . json ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapi . notifications . news (). build (). execute () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġrequest . headers [" pro xer - api - key "] ĠshouldBe EqualTo Ġ" mock - key " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Default UserAgent () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġrequest ) Ġ= Ġserver . run Request (" news . json ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapi . notifications . news (). build (). execute () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġrequest . headers [" User - Agent "] ĠshouldBe EqualTo Ġ" Pro xer Lib Java /$ VERSION " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest ApiKey Header Not Set For Other Url () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url ( Pro xer Urls . cdn Base ). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" pro xer - api - key "). shouldBe Null () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For Test Mode () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url ( Pro xer Urls . api Base ). build () ĊĊĠĠĠĠĠĠĠ ĠHeader Interceptor ( Pro xer Api . TEST _ KEY , Ġ" mock - user - agent "). intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" pro xer - api - key "). shouldBe Null () ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" pro xer - api - test mode ") ĠshouldBe EqualTo Ġ" 1 " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Test Mode Header Not Ser For Other Url () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url ( Pro xer Urls . cdn Base ). build () ĊĊĠĠĠĠĠĠĠ ĠHeader Interceptor ( Pro xer Api . TEST _ KEY , Ġ" mock - user - agent "). intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" pro xer - api - test mode "). shouldBe Null () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For C dn () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url ( Pro xer Urls . cdn Base ). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" User - Agent "). toString () ĠshouldBe EqualTo Ġ" mock - user - agent " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For Stream Server () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url ( Pro xer Urls . stream Base ). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" User - Agent "). toString () ĠshouldBe EqualTo Ġ" mock - user - agent " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For Specific Stream Server () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url (" https :// s 3 - ps . pro xer . me "). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" User - Agent "). toString () ĠshouldBe EqualTo Ġ" mock - user - agent " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For M anga Server () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url (" https :// manga 0 . pro xer . me "). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" User - Agent "). toString () ĠshouldBe EqualTo Ġ" mock - user - agent " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Correct Headers For Proxy () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url (" https :// proxy . pro xer . me "). build () ĊĊĠĠĠĠĠĠĠ Ġinterceptor . intercept ( chain ) ĊĊĠĠĠĠĠĠĠ Ġrequest Slot . is Capt ured ĠshouldBe Ġtrue ĊĠĠĠĠĠĠĠ Ġrequest Slot . captured . header (" User - Agent "). toString () ĠshouldBe EqualTo Ġ" mock - user - agent " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Other Host Throws () Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġchain . request () Ġ} Ġreturns ĠRequest . Builder (). url (" https :// example . com "). build () ĊĊĠĠĠĠĠĠĠ Ġinvoking Ġ{ Ġinterceptor . intercept ( chain ) Ġ} Ġshould Throw ĠIllegalArgumentException :: class ĊĠĠĠ Ġ} Ċ } Ċ