// ĠCopyright Ġ 2 0 2 1 ĠThe ĠCross - Media ĠMeasurement ĠAuthors Ċ // Ċ // Ġ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 Ġorg . wf an et . panel match . client . launcher Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . google . protobuf . kotlin . to ByteString Utf 8 Ċ import Ġjava . time . LocalDate Ċ import Ġkotlin . test . assert Fails With Ċ import Ġkotlinx . coroutines . Cancellation Exception Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġorg . mockito . kotlin . mock Ċ import Ġorg . wf an et . measurement . api . v 2 alpha . Exchange Step Attempt Key Ċ import Ġorg . wf an et . measurement . api . v 2 alpha . Exchange Workflow Kt . Step Kt . com mut ative Determin istic Encrypt Step Ċ import Ġorg . wf an et . measurement . api . v 2 alpha . Exchange Workflow Kt . step Ċ import Ġorg . wf an et . measurement . api . v 2 alpha . exchange Workflow Ċ import Ġorg . wf an et . measurement . common . as Buffered Flow Ċ import Ġorg . wf an et . panel match . client . ex chan get ask s . testing . Fake Exchange Task Mapper Ċ import Ġorg . wf an et . panel match . client . launcher . Exchange Step Validator . Validated Exchange Step Ċ import Ġorg . wf an et . panel match . client . launcher . testing . Fake Timeout Ċ import Ġorg . wf an et . panel match . client . storage . Storage Details Ċ import Ġorg . wf an et . panel match . client . storage . Storage Details Kt Ċ import Ġorg . wf an et . panel match . client . storage . storage Details Ċ import Ġorg . wf an et . panel match . client . storage . testing . Test Private Storage Selector Ċ import Ġorg . wf an et . panel match . common . storage . toString Utf 8 Ċ import Ġorg . wf an et . panel match . common . testing . run Blocking Test Ċ Ċ private Ġconst Ġval ĠRE CUR RING _ EX CHANGE _ ID Ġ= Ġ" some - recurring - exchange - id " Ċ private Ġval ĠAT TEMP T _ KEY Ġ= ĠExchange Step Attempt Key ( REC UR RING _ EX CHANGE _ ID , Ġ" x ", Ġ" y ", Ġ" z ") Ċ Ċ private Ġval ĠDATE Ġ= ĠLocalDate . of ( 2 0 2 1 , Ġ 1 1 , Ġ 3 ) Ċ Ċ private Ġval ĠWORK FLOW Ġ= Ġexchange Workflow Ġ{ ĊĠ Ġsteps Ġ+= ĊĠĠĠ Ġstep Ġ{ ĊĠĠĠĠĠ Ġthis . com mut ative Determin istic Encrypt Step Ġ= Ġcom mut ative Determin istic Encrypt Step Ġ{} ĊĠĠĠĠĠ Ġinput Labels [" a "] Ġ= Ġ" b " ĊĠĠĠĠĠ Ġoutput Labels [" Out : a "] Ġ= Ġ" c " ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġval ĠVALID ATED _ EX CHANGE _ STEP Ġ= ĠValid ated Exchange Step ( WORK FLOW , ĠWORK FLOW . get Steps ( 0 ), ĠDATE ) Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠExchange Task Executor Test Ġ{ ĊĠ Ġprivate Ġval Ġtest Private Storage Selector Ġ= ĠTest Private Storage Selector () ĊĠ Ġprivate Ġval ĠapiClient : ĠApi Client Ġ= Ġmock () ĊĠ Ġprivate Ġval Ġtimeout Ġ= ĠFake Timeout () ĊĊĠ Ġprivate Ġval Ġstorage Details Ġ= Ġstorage Details Ġ{ ĊĠĠĠ Ġg cs Ġ= ĠStorage Details Kt . g cs Storage Ġ{} ĊĠĠĠ Ġvisibility Ġ= ĠStorage Details . Visibility . PRIVATE ĊĠ Ġ} ĊĊĠ Ġprivate Ġval Ġexchange Task Mapper Ġ= ĠFake Exchange Task Mapper () ĊĊĠ Ġprivate Ġval Ġexchange Task Executor Ġ= ĊĠĠĠ ĠExchange Task Executor ( ĊĠĠĠĠĠ ĠapiClient , ĊĠĠĠĠĠ Ġtimeout , ĊĠĠĠĠĠ Ġtest Private Storage Selector . selector , ĊĠĠĠĠĠ Ġexchange Task Mapper ĊĠĠĠ Ġ) ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp Storage () Ġ{ ĊĠĠĠ Ġtest Private Storage Selector . storage Details . underlying Map [ REC UR RING _ EX CHANGE _ ID ] Ġ= ĊĠĠĠĠĠ Ġstorage Details . to ByteString () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` reads Ġinputs Ġand Ġwrites Ġoutputs `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠ Ġval Ġblob Ġ= Ġ" some - blob ". to ByteString Utf 8 () ĊĊĠĠĠ Ġtest Private Storage Selector . storage Client . create Blob (" b ", Ġblob . as Buffered Flow ( 1 0 2 4 )) ĊĊĠĠĠ Ġexchange Task Executor . execute ( VALID ATED _ EX CHANGE _ STEP , ĠAT TEMP T _ KEY ) ĊĊĠĠĠ ĠassertThat ( test Private Storage Selector . storage Client . get Blob (" c ") ?. toString Utf 8 ()) ĊĠĠĠĠĠ Ġ. isEqualTo (" Out : com mut ative - determin istic - encrypt - some - blob ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtimeout () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠ Ġtimeout . expired Ġ= Ġtrue ĊĊĠĠĠ Ġassert Fails With < Cancellation Exception > Ġ{ ĊĠĠĠĠĠ Ġexchange Task Executor . execute ( VALID ATED _ EX CHANGE _ STEP , ĠAT TEMP T _ KEY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠassertThat ( test Private Storage Selector . storage Client . get Blob (" c ")). isNull () ĊĠ Ġ} Ċ } Ċ