package Ġcom . netflix . spin n aker . k ork . plugins . remote . extension . transport Ċ Ċ import Ġcom . fasterxml . jackson . annotation . Json TypeName Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . fasterxml . jackson . module . kotlin . jackson ObjectMapper Ċ import Ġcom . netflix . spin n aker . k ork . api . plugins . remote . Remote Extension Config Ċ import Ġcom . netflix . spin n aker . k ork . jackson . ObjectMapper Subtype Configurer Ċ import Ġcom . netflix . spin n aker . k ork . plugins . remote . extension . transport . http . Ok Http Remote Extension Transport Ċ import Ġdev . min ut est . junit . JUnit 5 Min ut ests Ċ import Ġdev . min ut est . root Context Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġokhttp 3 . MediaType Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . Protocol Ċ import Ġokhttp 3 . Response Ċ import Ġokhttp 3 . ResponseBody Ċ import Ġstri kt . api . expect That Ċ import Ġstri kt . assertions . is A Ċ Ċ class ĠOk Http Remote Extension Transport Test Ġ: ĠJ Unit 5 Min ut ests Ġ{ ĊĠ Ġfun Ġtests () Ġ= Ġroot Context < Fixture > Ġ{ ĊĠĠĠ Ġfixture Ġ{ ĊĠĠĠĠĠ ĠFix ture () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest Ġ(" Read Ġresponse Ġtype ") Ġ{ ĊĠĠĠĠĠ Ġval Ġresponse Ġ= ĠResponse . Builder () ĊĠĠĠĠĠĠĠ Ġ. request ( mock k ( relax ed Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġ. protocol ( Protocol . HTTP _ 1 _ 1 ) ĊĠĠĠĠĠĠĠ Ġ. code ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġ. message (" OK ") ĊĠĠĠĠĠĠĠ Ġ. header (" Content - Type ", Ġ" application / json ") ĊĠĠĠĠĠĠĠ Ġ. body ( ResponseBody . create ( MediaType . parse (" application / json "), Ġ"{\" type \": Ġ\" read Response \", Ġ\" foo \": Ġ\" bar \" } ")) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠ Ġevery Ġ{ Ġclient . new Call ( any ()). execute () Ġ} Ġreturns Ġresponse ĊĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . read ( read Query ) ĊĊĠĠĠĠĠ Ġexpect That ( result ). is A < Read Response >() ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest Ġ(" Write Ġresponse Ġtype ") Ġ{ ĊĠĠĠĠĠ Ġval Ġresponse Ġ= ĠResponse . Builder () ĊĠĠĠĠĠĠĠ Ġ. request ( mock k ( relax ed Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġ. protocol ( Protocol . HTTP _ 1 _ 1 ) ĊĠĠĠĠĠĠĠ Ġ. code ( 2 0 1 ) ĊĠĠĠĠĠĠĠ Ġ. message (" OK ") ĊĠĠĠĠĠĠĠ Ġ. header (" Content - Type ", Ġ" application / json ") ĊĠĠĠĠĠĠĠ Ġ. body ( ResponseBody . create ( MediaType . parse (" application / json "), Ġ"{\" type \": Ġ\" write Response \", Ġ\" foo \": Ġ\" bar \" } ")) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠ Ġevery Ġ{ Ġclient . new Call ( any ()). execute () Ġ} Ġreturns Ġresponse ĊĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . write ( payload ) ĊĊĠĠĠĠĠ Ġexpect That ( result ). is A < Write Response >() ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġclass ĠFix ture Ġ{ ĊĠĠĠ Ġval Ġread Query Ġ= ĠQuery () ĊĠĠĠ Ġval Ġpayload Ġ= ĠPayload () ĊĠĠĠ Ġval ĠobjectMapper : ĠObjectMapper Ġ= Ġj ack son ObjectMapper () ĊĠĠĠ Ġval Ġsub Type Locator Ġ= ĠObjectMapper Subtype Configurer . Class Subtype Locator ( ĊĠĠĠĠĠ ĠRemote Extension Response :: class . java , ĠlistOf (" com . netflix . spin n aker . k ork . plugins . remote . extension . transport ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġclient : ĠOk HttpClient Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġhttp Config : ĠRemote Extension Config . Remote Extension Transport Config . Http Ġ= ĊĠĠĠĠĠ ĠRemote Extension Config . Remote Extension Transport Config . Http ( ĊĠĠĠĠĠĠĠ Ġ" https :// example . com ", ĊĠĠĠĠĠĠĠ Ġmutable Map Of (), ĊĠĠĠĠĠĠĠ Ġmutable Map Of (), ĊĠĠĠĠĠĠĠ ĠRemote Extension Config . Remote Extension Transport Config . Http . Headers ( ĊĠĠĠĠĠĠĠĠĠ Ġmutable Map Of (), Ġmutable Map Of (), Ġmutable Map Of () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġsubject : ĠOk Http Remote Extension Transport Ġ= ĠOk Http Remote Extension Transport ( ĊĠĠĠĠĠ ĠobjectMapper , ĊĠĠĠĠĠ Ġclient , ĊĠĠĠĠĠ Ġhttp Config ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠ ĠObjectMapper Subtype Configurer ( true ). register Sub types ( object Mapper , ĠlistOf ( sub Type Locator )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġclass ĠPayload : ĠRemote Extension Payload ĊĠ Ġprivate Ġclass ĠQuery : ĠRemote Extension Query ĊĊĠ Ġ@ Json TypeName (" write Response ") ĊĠ Ġprivate Ġclass ĠWrite Response ( ĊĠĠĠ Ġval Ġfoo : ĠString ĊĠ Ġ): ĠRemote Extension Response ĊĊĠ Ġ@ Json TypeName (" read Response ") ĊĠ Ġdata Ġclass ĠRead Response ( ĊĠĠĠ Ġval Ġfoo : ĠString ĊĠ Ġ): ĠRemote Extension Response Ċ } Ċ