package Ġio . github . dl le w el lyn . saf et or un . off device Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġio . github . dl le w el lyn . saf et or un . api . Safe To Run Api Ċ import Ġio . github . dl le w el lyn . saf et or un . models . builders . Device Information Dto Builder Ċ import Ġio . github . dl le w el lyn . saf et or un . models . models . Device Signature Dto Ċ import Ġio . github . dl le w el lyn . saf et or un . models . builders . device Information Builder Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġjunit . framework . TestCase Ċ Ċ internal Ġclass ĠAndroid Safe To Run Off Device Test Ġ: ĠTestCase () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġsafe To Run Api Ġ= Ġmock k < Safe To Run Api >() ĊĠĠĠ Ġprivate Ġval Ġoff Device Result Builder Ġ= Ġmock k < Off Device Result Builder >() ĊĠĠĠ Ġprivate Ġval Ġapi : ĠString Ġ= Ġ" Api k key " ĊĠĠĠ Ġprivate Ġval ĠdeviceId : ĠString Ġ= Ġ" DeviceId " ĊĊĠĠĠ Ġprivate Ġval Ġandroid Safe To Run Off Device Ġ= ĊĠĠĠĠĠĠĠ ĠAndroid Safe To Run Off Device ( safe To Run Api , Ġoff Device Result Builder , Ġapi , ĠdeviceId ) ĊĊĠĠĠ Ġfun Ġ` test Ġthat Ġwhen Ġwe Ġcall Ġandroid Ġsafe Ġto Ġrun Ġit Ġreturns Ġresult Ġfrom Ġclient `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠGiven ĊĠĠĠĠĠĠĠ Ġval Ġexpected Result Ġ= ĠDevice Signature Dto (" signed Ġresult ") ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġoff Device Result Builder . build Off Device Result Builder ( any ()) Ġ} Ġanswers Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( args [ 0 ] Ġas ĠDevice Information Dto Builder ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdto Result () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġsafe To Run Api . post New Device ( any ()) Ġ} Ġreturns Ġexpected Result ĊĊĠĠĠĠĠĠĠ Ġ// ĠWhen ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġandroid Safe To Run Off Device . is Safe To Run () ĊĊĠĠĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isEqualTo ( Safe To Run Off Device Result ( expected Result . signature )) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġsafe To Run Api . post New Device ( matching Dto ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmatching Dto () Ġ= Ġdevice Information Builder ( api ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdto Result () ĊĠĠĠĠĠĠĠ ĠdeviceId ( deviceId ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠDevice Information Dto Builder . dto Result () Ġ{ ĊĠĠĠĠĠĠĠ Ġinstall Origin (" install ") ĊĠĠĠĠĠĠĠ Ġinstalled Application (" packag ename ") ĊĠĠĠĠĠĠĠ Ġos Version (" os version ") ĊĠĠĠĠĠĠĠ Ġmanufacturer (" manufacturer ") ĊĠĠĠĠĠĠĠ Ġsignature (" signature ") ĊĠĠĠĠĠĠĠ Ġmodel (" model ") ĊĠĠĠĠĠĠĠ Ġboard (" board ") ĊĠĠĠĠĠĠĠ Ġboot loader (" boot loader ") ĊĠĠĠĠĠĠĠ Ġdevice (" device ") ĊĠĠĠĠĠĠĠ Ġhardware (" hardware ") ĊĠĠĠĠĠĠĠ Ġhost (" host ") ĊĠĠĠĠĠĠĠ Ġcpu Ab i (" cpu ") ĊĠĠĠĠĠĠĠ Ġcpu Ab i (" cpu Ab i ") ĊĠĠĠ Ġ} Ċ } Ċ