package Ġorg . http 4 k . traffic Ċ Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġcom . nat pr y ce . ham k rest . equalTo Ċ import Ġorg . http 4 k . core . Method Ċ import Ġorg . http 4 k . core . Request Ċ import Ġorg . http 4 k . core . Response Ċ import Ġorg . http 4 k . core . Status Ċ import Ġorg . http 4 k . core . Status . Companion . SERVICE _ UN AVAILABLE Ċ import Ġorg . http 4 k . ham k rest . has Status Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠRes pon der Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġrequest Ġ= ĠRequest ( Method . GET , Ġ"/ bob ") ĊĠĠĠ Ġprivate Ġval Ġrequest 2 Ġ= ĠRequest ( Method . GET , Ġ"/ bob 2 ") ĊĠĠĠ Ġprivate Ġval Ġresponse Ġ= ĠResponse ( Status . OK ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Responder Ġfrom ĠSource Ġreplay s Ġstored Ġresponses Ġor Ġfalls Ġback Ġto ĠService ĠUn available `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcache Ġ= ĠRead Write Cache . Memory () ĊĠĠĠĠĠĠĠ Ġcache [ request ] Ġ= Ġresponse ĊĊĠĠĠĠĠĠĠ Ġval Ġresponder Ġ= ĠRes pon der . from ( cache ) ĊĠĠĠĠĠĠĠ ĠassertThat ( responder ( request ), ĠequalTo ( response )) ĊĠĠĠĠĠĠĠ ĠassertThat ( responder ( Request ( Method . GET , Ġ"/ rit a ")), Ġhas Status ( SERVICE _ UN AVAILABLE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Responder Ġfrom ĠRe play Ġreplay s Ġstored Ġresponses Ġor Ġfalls Ġback Ġto ĠService ĠUn available `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstream Ġ= ĠRead Write Stream . Memory () ĊĠĠĠĠĠĠĠ Ġstream [ request ] Ġ= Ġresponse ĊĠĠĠĠĠĠĠ Ġstream [ request 2 ] Ġ= Ġresponse ĊĊĠĠĠĠĠĠĠ Ġval Ġresponder Ġ= ĠRes pon der . from ( stream ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( responder ( request ), ĠequalTo ( response )) ĊĠĠĠĠĠĠĠ ĠassertThat ( responder ( request 2 ), ĠequalTo ( response )) ĊĠĠĠĠĠĠĠ ĠassertThat ( responder ( Request ( Method . GET , Ġ"/ rit a ")), Ġhas Status ( SERVICE _ UN AVAILABLE )) ĊĠĠĠ Ġ} Ċ Ċ }