/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 4 Ġy vol k Ġ( Y uri ĠVol kov ), Ġhttp :// y ur iv olk ov . com Ċ Ġ* Ċ Ġ* Ġ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 . and status . app . data Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . provider . Base Columns Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġorg . and status . app . account . My Account Ċ import Ġorg . and status . app . actor . Group Type Ċ import Ġorg . and status . app . context . Demo Data Ċ import Ġorg . and status . app . context . My Context Ċ import Ġorg . and status . app . context . TestSuite Ċ import Ġorg . and status . app . database . table . Activity Table Ċ import Ġorg . and status . app . database . table . Actor Table Ċ import Ġorg . and status . app . database . table . Note Table Ċ import Ġorg . and status . app . net . social . A Activity Ċ import Ġorg . and status . app . net . social . Activity Type Ċ import Ġorg . and status . app . net . social . Actor Ċ import Ġorg . and status . app . net . social . Actor Endpoints Ċ import Ġorg . and status . app . net . social . Attachment Ċ import Ġorg . and status . app . net . social . Audience Ċ import Ġorg . and status . app . net . social . Audience . Companion . from Note Id Ċ import Ġorg . and status . app . net . social . Connection G nu Social Test Ċ import Ġorg . and status . app . net . social . Note Ċ import Ġorg . and status . app . net . social . Visibility Ċ import Ġorg . and status . app . note . Note Editor Data Ċ import Ġorg . and status . app . notification . Notification EventType Ċ import Ġorg . and status . app . origin . Origin Ċ import Ġorg . and status . app . origin . Origin Pump io Ċ import Ġorg . and status . app . service . Attachment Downloader Test Ċ import Ġorg . and status . app . service . Command Data Ċ import Ġorg . and status . app . service . Command Enum Ċ import Ġorg . and status . app . service . Command ExecutionContext Ċ import Ġorg . and status . app . timeline . meta . Timeline Type Ċ import Ġorg . and status . app . util . My Log Ċ import Ġorg . and status . app . util . Relative Time Ċ import Ġorg . and status . app . util . Selection And Args Ċ import Ġorg . and status . app . util . Tri State Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠData Updater Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġmy Context : ĠMy Context Ġ= ĠTest Suite . initialize With Accounts ( this ) ĊĠĠĠ Ġprivate Ġval Ġcontext : ĠContext Ġ= Ġmy Context . context ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠDemo Data . demo Data . check Data Path () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Friends () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . getP ump io Conversation Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġnote Oid Ġ= Ġ" https :// ident i . ca / api / comment / das dj fd ask d jl k ew jz 1 Eh Sr TR B " ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . delete Old Note ( account Actor . origin , Ġnote Oid ) ĊĠĠĠĠĠĠĠ Ġval Ġexecution Context Ġ= ĠCommand ExecutionContext ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmy Context , ĠCommand Data . Companion . new Account Command ( Command Enum . EMPTY , Ġma )) ĊĠĠĠĠĠĠĠ Ġval Ġdata Updater Ġ= ĠData Updater ( executionContext ) ĊĠĠĠĠĠĠĠ Ġval Ġusername Ġ= Ġ" some body " Ġ+ ĠDemo Data . demo Data . test Run Uid Ġ+ Ġ"@ ident i . ca " ĊĠĠĠĠĠĠĠ Ġval Ġactor Oid : ĠString Ġ= ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġusername ĊĠĠĠĠĠĠĠ Ġval Ġsome body : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , Ġactor Oid ) ĊĠĠĠĠĠĠĠ Ġsome body . set Username ( username ) ĊĠĠĠĠĠĠĠ Ġsome body . is My Friend Ġ= ĠTri State . FALSE ĊĠĠĠĠĠĠĠ Ġsome body . set Profile Url (" http :// ident i . ca / some body ") ĊĠĠĠĠĠĠĠ Ġsome body . build () ĊĠĠĠĠĠĠĠ Ġdata Updater . on Activity ( account Actor . update ( some body )) ĊĠĠĠĠĠĠĠ Ġsome body . actor Id Ġ= ĠMy Query . oid To Id ( Oid Enum . ACT OR _ OID , Ġaccount Actor . origin . id , Ġactor Oid ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Actor Ġ$ username Ġadded ", Ġsome body . actor Id Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠDemo Conversation Inser ter . Companion . assert If Actor Is My Friend ( some body , Ġfalse , Ġma ) ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġsome body , Ġnote Oid , ĠSystem . currentTimeMillis (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ Ġnote . setContent Posted (" The Ġtest Ġnote Ġby ĠSome body Ġat Ġrun Ġ" Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" My Cool Client " ĊĠĠĠĠĠĠĠ Ġnote . url Ġ= Ġ" http :// ident i . ca / some body / comment / das dj fd ask d jl k ew jz 1 Eh Sr TR B " ĊĠĠĠĠĠĠĠ ĠTest Suite . clear Assertions () ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= Ġdata Updater . on Activity ( activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded ", Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġadded ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTest Suite . get My Context For Test (). get Assertion Data ( Data Updater . Companion . MSG _ ASSERT ION _ KEY ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Data Ġput ", Ġdata . non Empty ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note ĠO id ", Ġnote Oid , Ġdata . values ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. get AsString ( Note Table . NOTE _ OID )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġis Ġloaded ", ĠDownload Status . LOADED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDownload Status . Companion . load ( data . values . getAs Integer ( Note Table . NOTE _ STATUS ). to Long ())) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġper malink Ġbefore Ġstorage ", Ġnote . url , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdata . values . get AsString ( Note Table . URL )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġper malink ", Ġnote . url , Ġaccount Actor . origin . get Note Permalink ( note Id )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġstored Ġas Ġloaded ", ĠDownload Status . LOADED , ĠDownload Status . Companion . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Long Column Value ( Note Table . NOTE _ STATUS , Ġnote Id ))) ĊĠĠĠĠĠĠĠ Ġval Ġauthor Id Ġ= ĠMy Query . note Id To Long Column Value ( Activity Table . AUTHOR _ ID , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Author Ġof Ġthe Ġnote ", Ġsome body . actor Id , Ġauthor Id ) ĊĠĠĠĠĠĠĠ Ġvar Ġurl Ġ= ĠMy Query . note Id ToString Column Value ( Note Table . URL , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Url Ġof Ġthe Ġnote ", Ġnote . url , Ġurl ) ĊĠĠĠĠĠĠĠ Ġval Ġsender Id Ġ= ĠMy Query . note Id To Long Column Value ( Activity Table . ACT OR _ ID , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Sender Ġof Ġthe Ġnote ", Ġsome body . actor Id , Ġsender Id ) ĊĠĠĠĠĠĠĠ Ġurl Ġ= ĠMy Query . actor Id ToString Column Value ( Actor Table . PROFILE _ PAGE , Ġsender Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Url Ġof Ġthe Ġauthor Ġ" Ġ+ Ġsome body . getUsername (), Ġsome body . get Profile Url (), Ġurl ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Latest Ġactivity Ġof Ġ$ some body ", Ġactivity . getId (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . ACT OR _ ACTIVITY _ ID , Ġsome body . actor Id )) ĊĠĠĠĠĠĠĠ Ġval Ġcontent Uri Ġ= Ġmy Context . time lines [ Timeline Type . FR I END S , Ġma . actor , Ġ ĠOrigin . EMPTY ]. get Uri () ĊĠĠĠĠĠĠĠ Ġval Ġsa Ġ= ĠSelection And Args () ĊĠĠĠĠĠĠĠ Ġval Ġsort Order Ġ= ĠActivity Table . getTime line SortOrder ( Timeline Type . FR I END S , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġsa . add Selection ( Activity Table . ACT OR _ ID Ġ+ Ġ"= ?", Ġjava . lang . Long . toString ( some body . actor Id )) ĊĠĠĠĠĠĠĠ Ġval Ġprojection Ġ= ĠarrayOf < String ? >( Base Columns ._ ID ) ĊĠĠĠĠĠĠĠ Ġvar Ġcursor Ġ= Ġcontext . getContent Resolver (). query ( content Uri , Ġprojection , Ġsa . selection , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsa . selection Args , Ġsort Order ) Ġ Ġ?: Ġthrow ĠIllegalStateException (" No Ġcursor Ġof ĠF riends Ġtimeline ") ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Should Ġbe Ġno Ġnotes Ġof Ġthis Ġactor Ġin Ġthe ĠF riends Ġtimeline ", Ġ 0 , Ġcursor . getCount (). to Long ()) ĊĠĠĠĠĠĠĠ Ġcursor . close () ĊĠĠĠĠĠĠĠ Ġsome body . is My Friend Ġ= ĠTri State . TRUE ĊĠĠĠĠĠĠĠ Ġsome body . set Updated Date ( My Log . unique Current Time MS ) ĊĠĠĠĠĠĠĠ Ġdata Updater . on Activity ( account Actor . update ( some body )) ĊĠĠĠĠĠĠĠ ĠDemo Conversation Inser ter . Companion . assert If Actor Is My Friend ( some body , Ġtrue , Ġma ) ĊĠĠĠĠĠĠĠ Ġcursor Ġ= Ġcontext . getContent Resolver (). query ( content Uri , Ġprojection , Ġsa . selection , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsa . selection Args , Ġsort Order ) Ġ?: Ġthrow ĠIllegalStateException (" No Ġcursor ") ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġby Ġactor =$ some body Ġis Ġnot Ġin Ġthe ĠF riends Ġtimeline Ġof Ġ$ ma ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcursor . count Ġ> Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġcursor . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Private Note To My Account () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . getP ump io Conversation Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġnote Oid Ġ= Ġ" https :// pump ity . net / api / comment / sa 2 3 w di 7 8 dh gj er df dd aj DS Q -" Ġ+ ĠDemo Data . demo Data . test Run Uid ĊĠĠĠĠĠĠĠ Ġval Ġusername Ġ= Ġ" t 1 3 1 t @ pump ity . net " ĊĠĠĠĠĠĠĠ Ġval Ġauthor : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġusername ) ĊĠĠĠĠĠĠĠ Ġauthor . set Username ( username ) ĊĠĠĠĠĠĠĠ Ġauthor . build () ĊĠĠĠĠĠĠĠ Ġval Ġnote Name Ġ= Ġ" For ĠYou Ġonly " ĊĠĠĠĠĠĠĠ Ġval Ġactivity Ġ= ĠDemo Note Inser ter ( account Actor ). build Activity ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnote Name , Ġ" Hello , Ġthis Ġis Ġa Ġtest ĠPrivate Ġnote Ġby Ġyour Ġnames ake Ġfrom Ġhttp :// pump ity . net ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull , Ġnote Oid , ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" Any Other Client " ĊĠĠĠĠĠĠĠ Ġnote . audience (). add ( account Actor ) ĊĠĠĠĠĠĠĠ Ġnote . audience (). visibility Ġ= ĠVisibility . PRIVATE ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded ", Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġadded ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġshould Ġbe Ġprivate Ġ$ note ", ĠVisibility . PRIVATE , ĠVisibility . Companion . from Note Id ( note Id )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġname Ġ$ note ", Ġnote Name , ĠMy Query . note Id ToString Column Value ( Note Table . NAME , Ġnote Id )) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Interaction ( activity , ĠNotification EventType . PRIVATE , ĠTri State . TRUE ) ĊĠĠĠĠĠĠĠ Ġval Ġaudience : ĠAud ience Ġ= Ġfrom Note Id ( account Actor . origin , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" No Ġaudience Ġfor Ġ$ activity ", Ġ 0 , Ġaudience . get Non Special Act ors (). size . to Long ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Recipient Ġ" Ġ+ Ġma . get AccountName () Ġ+ Ġ"; Ġ" Ġ+ Ġaudience . get Non Special Act ors (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġma . actor Id , Ġaudience . getFirst Non Special (). actor Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Number Ġof Ġaudience Ġfor Ġ$ activity ", Ġ 1 , Ġaudience . get Non Special Act ors (). size . to Long ()) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Visibility ( audience , ĠVisibility . PRIVATE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnote F avor ited By Other Actor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . getP ump io Conversation Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġauthor Username Ġ= Ġ" any body @ pump ity . net " ĊĠĠĠĠĠĠĠ Ġval Ġauthor : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġauthor Username ) ĊĠĠĠĠĠĠĠ Ġauthor . set Username ( author Username ) ĊĠĠĠĠĠĠĠ Ġauthor . build () ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthor , Ġ" https :// pump ity . net / api / comment / sda j kl sdk iew wp ds ld k fs das dj W ED " Ġ+ ĠDemo Data . demo Data . test Run Uid , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 3 3 1 2 6 9 7 0 0 0 L , ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ Ġnote . setContent Posted (" This Ġtest Ġnote Ġwill Ġbe Ġfavor ited Ġby ĠFirst ĠReader Ġfrom Ġhttp :// pump ity . net ") ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" Some Other Client " ĊĠĠĠĠĠĠĠ Ġnote . audience (). visibility Ġ= ĠVisibility . PUBLIC _ AND _ TO _ FOLLOW ERS ĊĠĠĠĠĠĠĠ Ġval Ġother Username Ġ= Ġ" first reader @ ident i . ca " ĊĠĠĠĠĠĠĠ Ġval Ġother Actor : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġother Username ) ĊĠĠĠĠĠĠĠ Ġother Actor . set Username ( other Username ) ĊĠĠĠĠĠĠĠ Ġother Actor . build () ĊĠĠĠĠĠĠĠ Ġval Ġlike Activity : ĠA Activity Ġ= ĠA Activity . Companion . from Inner ( other Actor , ĠActivity Type . LIKE , Ġactivity ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( like Activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded ", Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" First Ġactivity Ġadded ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" LIKE Ġactivity Ġadded ", Ġ 0 , Ġlike Activity . getId ()) ĊĠĠĠĠĠĠĠ Ġval Ġst arg az ers Ġ= ĠMy Query . get St arg az ers ( my Context . database , Ġaccount Actor . origin , Ġnote . note Id ) ĊĠĠĠĠĠĠĠ Ġvar Ġfavor ited By Other Actor Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġfor Ġ( actor Ġin Ġst arg az ers ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( actor Ġ== Ġaccount Actor ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . fail (" Note Ġis Ġfavor ited Ġby Ġmy Ġaccount Ġ$ ma Ġ- Ġ$ note ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( actor Ġ== Ġauthor ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . fail (" Note Ġis Ġfavor ited Ġby Ġmy Ġauthor Ġ$ note ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( actor Ġ== Ġother Actor ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfavor ited By Other Actor Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . fail (" Note Ġis Ġfavor ited Ġby Ġunexpected Ġactor Ġ$ actor Ġ- Ġ$ note ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġis Ġnot Ġfavor ited Ġby Ġ$ other Actor : Ġ$ st arg az ers ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , Ġfavor ited By Other Actor ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġis Ġfavor ited Ġ( by Ġsome Ġmy Ġaccount )", ĠTri State . TRUE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Tri State ( Note Table . FA V OR IT ED , Ġnote Id )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Activity Ġis Ġsubscribed Ġ$ like Activity ", ĠTri State . UNKNOWN , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . activity Id To Tri State ( Activity Table . SUB SCR IB ED , Ġlike Activity . getId ())) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Interaction ( like Activity , ĠNotification EventType . EMPTY , ĠTri State . FALSE ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġis Ġre blog ged ", ĠTri State . UNKNOWN , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Tri State ( Note Table . RE B LOG GED , Ġnote Id )) ĊĠĠĠĠĠĠĠ Ġval Ġaudience : ĠAud ience Ġ= Ġfrom Note Id ( account Actor . origin , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Visibility ( audience , ĠVisibility . PUBLIC _ AND _ TO _ FOLLOW ERS ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTODO : ĠBelow Ġis Ġactually Ġa Ġtimeline Ġquery Ġtest , Ġso Ġmaybe Ġexpand Ġ/ Ġmove ... ĊĠĠĠĠĠĠĠ Ġval Ġcontent Uri Ġ= Ġmy Context . time lines [ Timeline Type . E VERY TH ING , ĠActor . EMPTY , Ġma . origin ]. get Uri () ĊĠĠĠĠĠĠĠ Ġval Ġsa Ġ= ĠSelection And Args () ĊĠĠĠĠĠĠĠ Ġval Ġsort Order Ġ= ĠActivity Table . getTime line SortOrder ( Timeline Type . E VERY TH ING , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġsa . add Selection ( Note Table . NOTE _ ID Ġ+ Ġ" Ġ= Ġ?", Ġjava . lang . Long . toString ( note Id )) ĊĠĠĠĠĠĠĠ Ġval ĠPRO JECTION Ġ= ĠarrayOf < String ? >( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Table . ACTIVITY _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Table . ACT OR _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Table . SUB SCR IB ED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Table . INS _ DATE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNote Table . NOTE _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNote Table . FA V OR IT ED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNote Table . UPDATED _ DATE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Table . ACCOUNT _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġcursor Ġ= Ġcontext . getContent Resolver (). query ( content Uri , ĠPRO JECTION , Ġsa . selection , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsa . selection Args , Ġsort Order ) Ġ?: Ġthrow ĠIllegalStateException (" No Ġcursor ") ĊĠĠĠĠĠĠĠ Ġvar Ġnote Found Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġwhile Ġ( cursor . moveTo Next ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġwith Ġother Ġid Ġreturned ", Ġnote Id , ĠDb Utils . getLong ( cursor , ĠNote Table . NOTE _ ID )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnote Found Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġis Ġfavor ited ", ĠTri State . TRUE , ĠDb Utils . get Tri State ( cursor , ĠNote Table . FA V OR IT ED )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġis Ġsubscribed ", ĠTri State . TRUE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDb Utils . get Tri State ( cursor , ĠActivity Table . SUB SCR IB ED )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcursor . close () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġis Ġnot Ġin ĠEverything Ġtimeline , Ġnote Id =$ note Id ", Ġnote Found ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Reply Note F avor ited By My Actor () Ġ{ ĊĠĠĠĠĠĠĠ Ġone Reply Note F avor ited By My Actor ("_ it 1 ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġone Reply Note F avor ited By My Actor ("_ it 2 ", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġone Reply Note F avor ited By My Actor ("_ it 2 ", Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġone Reply Note F avor ited By My Actor ( iteration Id : ĠString ?, Ġfavor ited : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . getP ump io Conversation Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġauthor Username Ġ= Ġ" example @ pump ity . net " ĊĠĠĠĠĠĠĠ Ġval Ġauthor : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġauthor Username ) ĊĠĠĠĠĠĠĠ Ġauthor . set Username ( author Username ) ĊĠĠĠĠĠĠĠ Ġauthor . build () ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġauthor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" https :// pump ity . net / api / comment / j hl k jh 3 sd ff pm nh fd 1 2 3 " Ġ+ Ġiteration Id Ġ+ ĠDemo Data . demo Data . test Run Uid , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 3 3 1 2 7 9 5 0 0 0 L , ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ Ġnote . setContent Posted (" The Ġtest Ġnote Ġby ĠExample \ n Ġfrom Ġthe Ġhttp :// pump ity . net Ġ$ iteration Id ") ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" Unknown Client " ĊĠĠĠĠĠĠĠ Ġif Ġ( f avor ited ) Ġnote . add Favorite By ( account Actor , ĠTri State . TRUE ) ĊĠĠĠĠĠĠĠ Ġval Ġin Reply To Oid Ġ= Ġ" https :// ident i . ca / api / comment / df j kl z df Sf 2 8 sk dk fg lox WB " Ġ+ Ġiteration Id Ġ+ ĠDemo Data . demo Data . test Run Uid ĊĠĠĠĠĠĠĠ Ġval Ġin Reply To : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActor . Companion . from Oid ( account Actor . origin , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" irt User " Ġ+ Ġiteration Id Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" irt $ author Username $ iteration Id ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġin Reply To Oid , ĠRelative Time . DATETIME _ M ILL IS _ NE VER , ĠDownload Status . UNKNOWN ) ĊĠĠĠĠĠĠĠ Ġnote . set In Reply To ( in Reply To ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded Ġ" Ġ+ Ġactivity . get Note (), Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġadded Ġ$ account Actor ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ Ġif Ġ(! f avor ited ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" In Ġreply Ġto Ġnote Ġadded Ġ" Ġ+ Ġin Reply To . get Note (), Ġ 0 , Ġin Reply To . get Note (). note Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" In Ġreply Ġto Ġactivity Ġadded Ġ$ in Reply To ", Ġ 0 , Ġin Reply To . getId ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġst arg az ers Ġ= ĠMy Query . get St arg az ers ( my Context . database , Ġaccount Actor . origin , Ġnote . note Id ) ĊĠĠĠĠĠĠĠ Ġvar Ġfavor ited By Me Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġfor Ġ( actor Ġin Ġst arg az ers ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( actor Ġ== Ġaccount Actor ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfavor ited By Me Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( actor Ġ== Ġauthor ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . fail (" Note Ġis Ġfavor ited Ġby Ġmy Ġauthor Ġ$ note ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . fail (" Note Ġis Ġfavor ited Ġby Ġunexpected Ġactor Ġ$ actor Ġ- Ġ$ note ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( f avor ited ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals (""" Note Ġ${ note . note Id } Ġis Ġnot Ġfavor ited Ġby Ġ$ account Actor : Ġ$ st arg az ers Ċ $ activity """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , Ġfavor ited By Me ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġshould Ġbe Ġfavor ited Ġ( by Ġsome Ġmy Ġaccount ) Ġ$ activity ", ĠTri State . TRUE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Tri State ( Note Table . FA V OR IT ED , Ġnote Id )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Activity Ġis Ġsubscribed ", ĠTri State . UNKNOWN , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . activity Id To Tri State ( Activity Table . SUB SCR IB ED , Ġactivity . getId ())) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Interaction ( activity , ĠNotification EventType . EMPTY , ĠTri State . FALSE ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġis Ġre blog ged ", ĠTri State . UNKNOWN , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Tri State ( Note Table . RE B LOG GED , Ġnote Id )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġstored Ġas Ġloaded ", ĠDownload Status . LOADED , ĠDownload Status . Companion . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Long Column Value ( Note Table . NOTE _ STATUS , Ġnote Id ))) ĊĠĠĠĠĠĠĠ Ġval Ġin Reply To Id Ġ= ĠMy Query . oid To Id ( Oid Enum . NOTE _ OID , Ġaccount Actor . origin . id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġin Reply To Oid ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" In Ġreply Ġto Ġnote Ġadded ", Ġin Reply To Id Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġreply Ġstatus Ġis Ġunknown ", ĠDownload Status . UNKNOWN , ĠDownload Status . Companion . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Long Column Value ( Note Table . NOTE _ STATUS , Ġin Reply To Id ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Note With Attachment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠConnection G nu Social Test . get Note With Attachment ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠInstrument ation Registry . get Instrumentation (). context ) ĊĠĠĠĠĠĠĠ Ġval Ġma Ġ= Ġmy Context . accounts . getFirst Prefer ably Succeeded For Origin ( activity . get Actor (). origin ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Account Ġis Ġvalid Ġ$ ma ", Ġma . isValid ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded Ġ" Ġ+ Ġactivity . get Note (), Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġadded Ġ$ activity ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ Ġval Ġdd : ĠDownload Data Ġ= ĠDownload Data . Companion . get Single Attachment ( note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Image ĠURI Ġstored ", Ġactivity . get Note (). attachments . list [ 0 ]. uri , Ġdd . get Uri ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Un sent Note With Attachment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmethod Ġ= Ġ" test Un sent Note With Attachment " ĊĠĠĠĠĠĠĠ Ġval Ġma Ġ= Ġmy Context . accounts . getFirst Succeeded () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġaccount Actor , Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . SEND ING ) ĊĠĠĠĠĠĠĠ Ġactivity . get Note (). setContent Posted (" Un sent Ġnote Ġwith Ġan Ġattachment Ġ" Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġactivity . add Attachment ( Attachment . Companion . from Uri And MimeType ( Demo Data . demo Data . local Image Test Uri , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy ContentType . VIDEO . general MimeType )) ĊĠĠĠĠĠĠĠ ĠData Updater ( ma ). on Activity ( activity ) ĊĠĠĠĠĠĠĠ Ġval Ġnote 1 Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded Ġ$ activity ", Ġ 0 , Ġnote 1 . note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Activity Ġadded Ġ$ activity ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Status Ġof Ġun sent Ġnote ", ĠDownload Status . SEND ING , ĠDownload Status . Companion . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Long Column Value ( Note Table . NOTE _ STATUS , Ġnote 1 . note Id ))) ĊĠĠĠĠĠĠĠ ĠDb Utils . wait Ms ( method , Ġ 1 0 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdd : ĠDownload Data Ġ= ĠDownload Data . Companion . get Single Attachment ( note 1 . note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Image ĠURI Ġstored ", Ġnote 1 . attachments . list [ 0 ]. uri , Ġdd . get Uri ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Local Ġimage Ġimmediately Ġloaded Ġ$ dd ", ĠDownload Status . LOADED , Ġdd . getStatus ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠEm ulate Ġreceiving Ġof Ġnote ĊĠĠĠĠĠĠĠ Ġval Ġoid Ġ= Ġ" sent Msg Oid " Ġ+ ĠDemo Data . demo Data . test Run Uid ĊĠĠĠĠĠĠĠ Ġval Ġactivity 2 : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġactivity . get Author (), Ġoid , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . get Note (). setContent Posted (" Just Ġsent : Ġ" Ġ+ Ġnote 1 . content ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . get Note (). note Id Ġ= Ġnote 1 . note Id ĊĠĠĠĠĠĠĠ Ġactivity 2 . add Attachment ( Attachment . Companion . from Uri ( Demo Data . demo Data . image 1 Url )) ĊĠĠĠĠĠĠĠ ĠData Updater ( ma ). on Activity ( activity 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġnote 2 Ġ= Ġactivity 2 . get Note () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Row Ġid Ġdidn 't Ġchange ", Ġnote 1 . note Id , Ġnote 2 . note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġcontent Ġupdated ", Ġnote 2 . content , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id ToString Column Value ( Note Table . CONTENT , Ġnote 1 . note Id )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Status Ġof Ġloaded Ġnote ", ĠDownload Status . LOADED , ĠDownload Status . Companion . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . note Id To Long Column Value ( Note Table . NOTE _ STATUS , Ġnote 1 . note Id ))) ĊĠĠĠĠĠĠĠ Ġval Ġdd 2 : ĠDownload Data Ġ= ĠDownload Data . Companion . get Single Attachment ( note 2 . note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" New Ġimage ĠURI Ġstored ", Ġnote 2 . attachments . list [ 0 ]. uri , Ġdd 2 . get Uri ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Not Ġloaded Ġyet . Ġ$ dd 2 ", ĠDownload Status . AB SENT , Ġdd 2 . getStatus ()) ĊĠĠĠĠĠĠĠ ĠAttachment Downloader Test . load And Assert Status For Row ( method , Ġdd 2 , ĠDownload Status . LOADED , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Username Changed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get G nu Social Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġusername Ġ= Ġ" pe ter " Ġ+ ĠDemo Data . demo Data . test Run Uid ĊĠĠĠĠĠĠĠ Ġval Ġactor 1 Ġ= ĠDemo Note Inser ter ( ma ). build Actor From Oid (" 3 4 8 0 4 " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġactor 1 . set Username ( username ) ĊĠĠĠĠĠĠĠ Ġactor 1 . set Profile Url (" https ://" Ġ+ ĠDemo Data . demo Data . gn us ocial Test Origin Name Ġ+ Ġ". example . com /") ĊĠĠĠĠĠĠĠ Ġactor 1 . build () ĊĠĠĠĠĠĠĠ Ġval Ġdata Updater Ġ= ĠData Updater ( ma ) ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 1 Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 1 )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Actor Ġadded ", Ġactor Id 1 Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" username Ġstored ", Ġactor 1 . getUsername (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ Ġval Ġactor 1 partial : ĠActor Ġ= ĠActor . Companion . from Oid ( actor 1 . origin , Ġactor 1 . oid ) ĊĠĠĠĠĠĠĠ ĠAssert . assertFalse (" Should Ġbe Ġpartially Ġdefined ", Ġactor 1 partial . is Fully Defined ()) ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 1 partial Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 1 partial )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Same ĠActor ", Ġactor Id 1 , Ġactor Id 1 partial ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Part ially Ġdefined ĠActor Ġshouldn 't Ġchange ĠUsername ", Ġactor 1 . getUsername (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Part ially Ġdefined ĠActor Ġshouldn 't Ġchange ĠWeb f inger Id ", Ġactor 1 . get Web F inger Id (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . WE BF ING ER _ ID , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Part ially Ġdefined ĠActor Ġshouldn 't Ġchange ĠReal Ġname ", Ġactor 1 . get Real Name (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . REAL _ NAME , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ Ġactor 1 . set Username ( actor 1 . getUsername () Ġ+ Ġ" re named ") ĊĠĠĠĠĠĠĠ Ġactor 1 . build () ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 1 Rename d Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 1 )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Same ĠActor Ġrenamed ", Ġactor Id 1 , Ġactor Id 1 Rename d ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Actor Ġshould Ġnot Ġbe Ġrenamed , Ġif Ġupdated Date Ġdidn 't Ġchange ", Ġusername , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ Ġactor 1 . set Updated Date ( My Log . unique Current Time MS ) ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 2 Rename d Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 1 )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Same ĠActor Ġrenamed ", Ġactor Id 1 , Ġactor Id 2 Rename d ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Same ĠActor Ġrenamed ", Ġactor 1 . getUsername (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 1 )) ĊĠĠĠĠĠĠĠ Ġval Ġactor 2 Same Old Username Ġ= ĠDemo Note Inser ter ( ma ). build Actor From Oid (" 3 4 8 0 5 " ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġactor 2 Same Old Username . set Username ( username ) ĊĠĠĠĠĠĠĠ Ġactor 2 Same Old Username . build () ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 2 Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 2 Same Old Username )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Other ĠActor Ġwith Ġthe Ġsame ĠActor Ġname Ġas Ġold Ġname Ġof ĠActor ", Ġactor Id 1 Ġ!= Ġactor Id 2 ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Username Ġstored ", Ġactor 2 Same Old Username . getUsername (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 2 )) ĊĠĠĠĠĠĠĠ Ġval Ġactor 3 Same New Username Ġ= ĠDemo Note Inser ter ( ma ). build Actor From Oid (" 3 4 8 0 6 " ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġactor 3 Same New Username . set Username ( actor 1 . getUsername ()) ĊĠĠĠĠĠĠĠ Ġactor 3 Same New Username . set Profile Url (" https ://" Ġ+ ĠDemo Data . demo Data . gn us ocial Test Origin Name Ġ+ Ġ". other . example . com /") ĊĠĠĠĠĠĠĠ Ġactor 3 Same New Username . build () ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 3 Ġ= Ġdata Updater . on Activity ( account Actor . update ( actor 3 Same New Username )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Actor Ġadded Ġ$ actor 3 Same New Username ", Ġactor Id 3 Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Other ĠActor Ġwith Ġthe Ġsame Ġusername Ġas Ġthe Ġnew Ġname Ġof Ġactor 1 , Ġbut Ġdifferent ĠWeb F inger Id ", Ġactor Id 1 Ġ!= Ġactor Id 3 ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" username Ġstored Ġfor Ġactor Id =$ actor Id 3 ", Ġactor 3 Same New Username . getUsername (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . USERNAME , Ġactor Id 3 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdemo Insert G nu Social Actor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get G nu Social Account () ĊĠĠĠĠĠĠĠ Ġval Ġactor 1 Ġ= ĠDemo Note Inser ter ( ma ). build Actor From Oid (" 3 4 8 0 7 " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġupdate Actor ( ma , Ġactor 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġactor 2 : ĠActor Ġ= ĠActor . Companion . from Oid ( ma . origin , Ġ" 9 8 0 2 3 4 9 3 " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" some user " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġupdate Actor ( ma , Ġactor 2 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Activity Pub Actor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . activity Pub Test AccountName ) ĊĠĠĠĠĠĠĠ Ġval Ġactor : ĠActor Ġ= ĠActor . Companion . from Oid ( ma . origin , Ġ" https :// example . com / users / Ap Tester " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġupdate Actor ( ma , Ġactor ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate Actor ( ma : ĠMy Account , Ġactor : ĠActor ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= ĠData Updater ( ma ). on Activity ( account Actor . update ( actor )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Actor Ġadded ", Ġid Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . check Stored Actor ( actor ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Location ", Ġactor . location , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . LOCATION , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" profile Ġimage ĠURL ", Ġactor . get Avatar Url (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . AV AT AR _ URL , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" profile ĠURL ", Ġactor . get Profile Url (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . PROFILE _ PAGE , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Endpoints ", Ġactor . endpoints , ĠActor Endpoints . Companion . from ( my Context , Ġid ). initialize ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Homepage ", Ġactor . get Homepage (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . HOME PAGE , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Description ", Ġactor . get Summary (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id ToString Column Value ( Actor Table . SUM MARY , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Notes Ġcount ", Ġactor . notes Count , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . NOTES _ COUNT , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" F avorites Ġcount ", Ġactor . favorites Count , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . FA V OR ITES _ COUNT , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Following Ġ( friends ) Ġcount ", Ġactor . following Count , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . FOLLOW ING _ COUNT , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Follow ers Ġcount ", Ġactor . followers Count , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . FOLLOW ERS _ COUNT , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Created Ġat ", Ġactor . get Created Date (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . CREATED _ DATE , Ġid )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Created Ġat ", Ġactor . get Updated Date (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . actor Id To Long Column Value ( Actor Table . UPDATED _ DATE , Ġid )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Reply In Body () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . getP ump io Conversation Account () ĊĠĠĠĠĠĠĠ Ġval Ġbu ddy Name Ġ= Ġ" buddy " Ġ+ ĠDemo Data . demo Data . test Run Uid Ġ+ Ġ"@ example . com " ĊĠĠĠĠĠĠĠ Ġval Ġcontent Ġ= Ġ(" @" Ġ+ Ġbu ddy Name Ġ+ Ġ" ĠI 'm Ġreply ing Ġto Ġyou Ġin Ġa Ġnote 's Ġbody ." ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ+ Ġ" ĠHope Ġyou Ġwill Ġsee Ġthis Ġas Ġa Ġreal Ġreply !") ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name , Ġcontent , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name , Ġ" Oh , Ġ$ content ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 1 Ġ= ĠMy Query . web F inger Id To Id ( my Context , Ġma . origin Id , Ġbu ddy Name , Ġfalse ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Actor Ġshould Ġhave Ġtemp ĠO id ", ĠActor . Companion . to Temp Oid ( buddy Name , Ġ""), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . id To Oid ( my Context , ĠO id Enum . ACT OR _ OID , Ġactor Id 1 , Ġ 0 )) ĊĠĠĠĠĠĠĠ Ġval Ġreal Bu ddy Oid Ġ= Ġ" acc :$ buddy Name " ĊĠĠĠĠĠĠĠ Ġval Ġactor : ĠActor Ġ= ĠActor . Companion . from Oid ( ma . origin , Ġreal Bu ddy Oid ) ĊĠĠĠĠĠĠĠ Ġactor . with Unique Name ( buddy Name ) ĊĠĠĠĠĠĠĠ Ġval Ġactor Id 2 Ġ= ĠData Updater ( ma ). on Activity ( ma . actor . update ( actor )) ?. get Obj Actor ()?. actor Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( actor Id 1 , Ġactor Id 2 ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Temp Oid Ġshould Ġbe Ġreplaced Ġwith Ġreal ", Ġreal Bu ddy Oid , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMy Query . id To Oid ( my Context , ĠO id Enum . ACT OR _ OID , Ġactor Id 1 , Ġ 0 )) ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name , Ġ"< a Ġhref =\" http :// example . com / a \"> @" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbu ddy Name Ġ+ Ġ"</ a >, Ġthis Ġis Ġan ĠHTML Ġ< i > formatted </ i > Ġnote ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġbu ddy Name 3 : ĠString Ġ= ĠDemo Data . demo Data . conversation Author Third Unique Name ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name 3 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ $ buddy Name 3 ĠI Ġknow Ġyou Ġare Ġalready Ġin Ġour Ġcache ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġbu ddy Name 4 Ġ= Ġma . actor . unique Name ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name 4 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Reply Ġto Ġmy account Ġ@$ buddy Name 4 Ġshould Ġadd Ġme Ġas Ġa Ġrecipient ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , Ġbu ddy Name 3 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Reply Ġto Ġmy account Ġ@$ buddy Name 4 Ġshould Ġnot Ġadd Ġother Ġbu ddy Ġas Ġa Ġrecipient ", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġval ĠgroupName 1 Ġ= Ġ" gn ut est group " ĊĠĠĠĠĠĠĠ Ġadd One Note 4 test Reply In Content ( ma , ĠgroupName 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Sending Ġa Ġnote Ġto Ġthe Ġ!$ groupName 1 Ġgroup ", Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġadd One Note 4 test Reply In Content ( ma : ĠMy Account , Ġbu ddy Unique Name : ĠString ?, Ġcontent : ĠString ?, Ġis Reply : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġactor Unique Name Ġ= Ġ" some body " Ġ+ ĠDemo Data . demo Data . test Run Uid Ġ+ Ġ"@ some where . net " ĊĠĠĠĠĠĠĠ Ġval Ġactor : ĠActor Ġ= ĠActor . Companion . from Oid ( ma . origin , ĠOrigin Pump io . Companion . ACCOUNT _ PREFIX Ġ+ Ġactor Unique Name ) ĊĠĠĠĠĠĠĠ Ġactor . with Unique Name ( actor Unique Name ) ĊĠĠĠĠĠĠĠ Ġactor . set Profile Url (" https :// some where . net /$ actor Unique Name ") ĊĠĠĠĠĠĠĠ Ġval Ġactivity In : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( ma . actor , Ġactor , ĠSystem . nano Time (). toString (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote In Ġ= Ġactivity In . get Note () ĊĠĠĠĠĠĠĠ Ġnote In . setContent Posted ( content ) ĊĠĠĠĠĠĠĠ Ġnote In . via Ġ= Ġ" My Cool Client " ĊĠĠĠĠĠĠĠ ĠNote Editor Data . Companion . re create Known Audience ( activity In ) ĊĠĠĠĠĠĠĠ Ġval Ġactivity Ġ= ĠData Updater ( ma ). on Activity ( activity In ) Ġ?: ĠA Activity . EMPTY ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġwas Ġnot Ġadded : Ġ$ activity ", Ġnote . note Id Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ Ġvar Ġbu ddy : ĠActor Ġ= ĠActor . EMPTY ĊĠĠĠĠĠĠĠ Ġfor Ġ( recipient Ġin Ġactivity . audience (). get Non Special Act ors ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertFalse (" Audience Ġmember Ġis Ġempty : Ġ$ recipient ,\ n $ note ", Ġrecipient . isEmpty ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( recipient . unique Name Ġ== Ġbu ddy Unique Name ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbu ddy Ġ= Ġrecipient ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbreak ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( is Reply ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals ("'" Ġ+ Ġbu ddy Unique Name Ġ+ Ġ"' Ġshould Ġbe Ġa Ġrecipient Ġ" Ġ+ Ġactivity . audience (). get Non Special Act ors (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠActor . EMPTY , Ġbu ddy ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertNot Equals ("' $ buddy Unique Name ' Ġis Ġnot Ġadded Ġ$ buddy ", Ġ 0 , Ġbu ddy . actor Id ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġis Ġa Ġreply Ġto Ġ'$ buddy Unique Name ': Ġ$ note ", Ġbu ddy . isEmpty ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest G nu Social Mention () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get G nu Social Account () ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġmy Mention ed Account : ĠMy Account Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . gn us ocial Test Account 2 Name ) ĊĠĠĠĠĠĠĠ Ġval Ġmy Mention ed Actor Ġ= Ġmy Mention ed Account . actor ĊĠĠĠĠĠĠĠ Ġval Ġauthor 1 : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , Ġ" sam " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġauthor 1 . set Username (" sam Bro ok ") ĊĠĠĠĠĠĠĠ Ġauthor 1 . build () ĊĠĠĠĠĠĠĠ Ġval Ġgroup name Ġ= Ġ" gn ut est group " ĊĠĠĠĠĠĠĠ Ġval Ġactivity 1 Ġ= Ġnew Loaded Note ( account Actor , Ġauthor 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ " Ġ+ Ġmy Mention ed Actor . getUsername () Ġ+ Ġ" ĠI 'm Ġmention ing Ġyour Ġanother Ġaccount " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġand Ġsending Ġthe Ġcontent Ġto Ġ! " Ġ+ Ġgroup name Ġ+ Ġ" Ġgroup " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠBut ĠHello ! Ġis Ġnot Ġa Ġgroup Ġname " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġand ! this is not Ġalso " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ" Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġval Ġactivity 2 : ĠA Activity Ġ= ĠA Activity . Companion . from ( account Actor , ĠActivity Type . UPDATE ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . set Actor ( author 1 ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . set Activity ( activity 1 ) ĊĠĠĠĠĠĠĠ ĠNote Editor Data . Companion . re create Known Audience ( activity 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( activity 2 )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġshould Ġbe Ġadded ", Ġnote Id Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ Ġval Ġaudience Ġ= Ġactivity 1 . audience () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Audience Ġshould Ġcontain Ġtwo Ġactors : Ġ$ audience ", Ġ 2 , Ġaudience . get Non Special Act ors (). size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġgroup Ġ= Ġaudience . get Non Special Act ors (). stream (). filter Ġ{ Ġa : ĠActor Ġ-> Ġgroup name Ġ== Ġa . getUsername () Ġ}. find Any () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Group Ġshould Ġbe Ġin Ġaudience : Ġ$ audience ", Ġgroup . isPresent ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Group Ġtype : Ġ$ group ", ĠGroup Type . GENERIC , Ġgroup . get (). group Type ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Group Ġid : Ġ$ group ", Ġ 0 , Ġgroup . get (). actor Id ) ĊĠĠĠĠĠĠĠ Ġval Ġsaved Group : ĠActor Ġ= ĠActor . Companion . load From Database ( my Context , Ġgroup . get (). actor Id , Ġ{ ĠActor . EMPTY Ġ}, Ġfalse ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Saved Ġgroup : Ġ$ saved Group ", Ġgroup name , Ġsaved Group . getUsername ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Saved Ġgroup Ġtype : Ġ$ saved Group ", ĠGroup Type . GENERIC , Ġsaved Group . group Type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreply ToOne Of My Act ors With The Same Username () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . gn us ocial Test Account 2 Name ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Updater Ġ= ĠData Updater ( ma ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġactor From Another Origin : ĠActor Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . twitter Test AccountName ). actor ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Demo Data . demo Data . t 1 3 1 t Username , Ġactor From Another Origin . getUsername ()) ĊĠĠĠĠĠĠĠ Ġval Ġmy Author 1 : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , Ġactor From Another Origin . oid Ġ+ Ġ" 2 2 ") ĊĠĠĠĠĠĠĠ Ġmy Author 1 . set Username ( actor From Another Origin . getUsername ()) ĊĠĠĠĠĠĠĠ Ġmy Author 1 . set Web F inger Id ( actor From Another Origin . get Web F inger Id ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Should Ġbe Ġunknown Ġif Ġit 's Ġmine $ my Author 1 ", Ġmy Author 1 . user . is My User . unknown ) ĊĠĠĠĠĠĠĠ Ġmy Author 1 . build () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" After Ġbuild Ġshould Ġbe Ġunknown Ġif Ġit 's Ġmine $ my Author 1 ", Ġmy Author 1 . user . is My User . unknown ) ĊĠĠĠĠĠĠĠ Ġval Ġactivity 1 Ġ= Ġnew Loaded Note ( account Actor , Ġmy Author 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" My Ġaccount 's Ġfirst Ġnote Ġfrom Ġanother ĠSocial ĠNetwork Ġ" Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Activity Ġshould Ġbe Ġadded ", Ġdata Updater . on Activity ( activity 1 )?. getId () Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Author Ġshould Ġbe Ġmine Ġ" Ġ+ Ġactivity 1 . get Author (), Ġactivity 1 . get Author (). user . is My User . isTrue ) ĊĠĠĠĠĠĠĠ Ġval Ġauthor 2 : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , Ġ" rep lier " Ġ+ ĠDemo Data . demo Data . test Run Uid ) ĊĠĠĠĠĠĠĠ Ġauthor 2 . set Username (" rep lier @ another dom an . com ") ĊĠĠĠĠĠĠĠ Ġauthor 2 . build () ĊĠĠĠĠĠĠĠ Ġval Ġactivity 2 Ġ= Ġnew Loaded Note ( account Actor , Ġauthor 2 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"@ " Ġ+ ĠDemo Data . demo Data . t 1 3 1 t Username Ġ+ Ġ" ĠReply ing Ġto Ġmy Ġuser Ġfrom Ġanother Ġinstance ") ĊĠĠĠĠĠĠĠ Ġactivity 2 . get Note (). set In Reply To ( activity 1 ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Activity Ġshould Ġbe Ġadded ", Ġdata Updater . on Activity ( activity 2 )?. getId () Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Audience Ġshould Ġcontain Ġone Ġactor Ġ" Ġ+ Ġactivity 2 . get Note (). audience (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 , Ġactivity 2 . get Note (). audience (). get Non Special Act ors (). size . to Long ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Audience ", Ġmy Author 1 , Ġactivity 2 . get Note (). audience (). getFirst Non Special ()) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Not ified Ġactor Ġ$ activity 2 ", Ġactor From Another Origin , Ġactivity 2 . get Not ified Actor ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġnew Loaded Note ( account Actor : ĠActor , Ġauthor : ĠActor , Ġcontent : ĠString ?): ĠA Activity Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġactivity 1 : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġauthor , ĠSystem . nano Time (). toString (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity 1 . get Note () ĊĠĠĠĠĠĠĠ Ġnote . setContent Posted ( content ) ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" And Status " ĊĠĠĠĠĠĠĠ Ġreturn Ġactivity 1 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsending Note Activity Pub () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . activity Pub Test AccountName ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Updater Ġ= ĠData Updater ( ma ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġcontent Ġ= Ġ" My Ġnote Ġfrom ĠActivity Pub Ġ" Ġ+ ĠDemo Data . demo Data . test Run Uid ĊĠĠĠĠĠĠĠ Ġval Ġactivity 0 : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , Ġaccount Actor , Ġ"", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . SEND ING ) ĊĠĠĠĠĠĠĠ Ġactivity 0 . get Note (). setContent Posted ( content ) ĊĠĠĠĠĠĠĠ Ġval Ġactivity 1 Ġ= Ġdata Updater . on Activity ( activity 0 ) Ġ?: ĠA Activity . EMPTY ĊĠĠĠĠĠĠĠ Ġval Ġnote 1 Ġ= Ġactivity 1 . get Note () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Note Ġshould Ġbe Ġadded Ġ$ activity 1 ", Ġnote 1 . note Id Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Activity Ġshould Ġbe Ġadded Ġ$ activity 1 ", Ġactivity 1 . getId () Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġ$ note 1 ", ĠDownload Status . SEND ING , Ġnote 1 . getStatus ()) ĊĠĠĠĠĠĠĠ Ġval Ġaudience : ĠAud ience Ġ= Ġfrom Note Id ( account Actor . origin , Ġnote 1 . note Id ) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Visibility ( audience , ĠVisibility . PRIVATE ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠResponse Ġfrom Ġa Ġserver ĊĠĠĠĠĠĠĠ Ġval Ġactivity 2 : ĠA Activity Ġ= ĠA Activity . Companion . from ( account Actor , ĠActivity Type . CREATE ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . setId ( activity 1 . getId ()) ĊĠĠĠĠĠĠĠ Ġactivity 2 . set Oid (" https ://" Ġ+ ĠDemo Data . demo Data . activity Pub Main Host Ġ+ Ġ"/ activities /" Ġ+ ĠMy Log . unique Current Time MS ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . set Updated Date ( My Log . unique Current Time MS ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠNo Ġcontent Ġin Ġthe Ġresponse , Ġjust Ġoid Ġof Ġthe Ġnote ĊĠĠĠĠĠĠĠ Ġval Ġnote 2 : ĠNote Ġ= ĠNote . Companion . from Origin And Oid ( account Actor . origin , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" https ://" Ġ+ ĠDemo Data . demo Data . activity Pub Main Host Ġ+ Ġ"/ objects /" Ġ+ ĠMy Log . unique Current Time MS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDownload Status . UNKNOWN ) ĊĠĠĠĠĠĠĠ Ġactivity 2 . set Note ( note 2 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠThis Ġis Ġwhat Ġis Ġdone Ġin Ġorg . and status . app . service . Command Executor Other . update Note Ġto Ġlink Ġthe Ġnotes ĊĠĠĠĠĠĠĠ Ġactivity 2 . setId ( activity 1 . getId ()) ĊĠĠĠĠĠĠĠ Ġactivity 2 . get Note (). note Id Ġ= Ġnote 1 . note Id ĊĠĠĠĠĠĠĠ Ġval Ġactivity 3 Ġ= Ġdata Updater . on Activity ( activity 2 ) Ġ?: ĠA Activity . EMPTY ĊĠĠĠĠĠĠĠ Ġval Ġnote 3 Ġ= Ġactivity 3 . get Note () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" The Ġsame Ġnote Ġshould Ġbe Ġupdated Ġ$ activity 3 ", Ġnote 1 . note Id , Ġnote 3 . note Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġoid Ġ$ activity 3 ", Ġnote 2 . oid , ĠMy Query . id To Oid ( my Context , ĠO id Enum . NOTE _ OID , Ġnote 3 . note Id , Ġ 0 )) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue (" Activity Ġshould Ġbe Ġadded Ġ$ activity 3 ", Ġactivity 3 . getId () Ġ!= Ġ 0 L ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Note Ġ$ note 3 ", ĠDownload Status . SENT , Ġnote 3 . getStatus ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnote To Follow ers Only () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġma : ĠMy Account Ġ= ĠDemo Data . demo Data . get My Account ( Demo Data . demo Data . activity Pub Test AccountName ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Actor Ġ= Ġma . actor ĊĠĠĠĠĠĠĠ Ġval Ġauthor Username Ġ= Ġ" author 1 0 1 " ĊĠĠĠĠĠĠĠ Ġval Ġauthor : ĠActor Ġ= ĠActor . Companion . from Oid ( account Actor . origin , Ġ" https :// activity pub . org / users /$ author Username ") ĊĠĠĠĠĠĠĠ Ġauthor . set Username ( author Username ) ĊĠĠĠĠĠĠĠ Ġauthor . build () ĊĠĠĠĠĠĠĠ Ġval Ġactivity : ĠA Activity Ġ= ĠA Activity . Companion . new Partial Note ( account Actor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthor , Ġ" https :// activity pub . org / note / sda j kl sdk iew wp ds ld k fs das dj W ED " Ġ+ ĠDemo Data . demo Data . test Run Uid , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSystem . currentTimeMillis (), ĠDownload Status . LOADED ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Ġ= Ġactivity . get Note () ĊĠĠĠĠĠĠĠ Ġnote . setContent Posted (" This Ġtest Ġnote Ġwas Ġsent Ġto ĠFollow ers Ġonly ") ĊĠĠĠĠĠĠĠ Ġnote . via Ġ= Ġ" Some Ap Client " ĊĠĠĠĠĠĠĠ Ġnote . audience (). with Visibility ( Visibility . TO _ FOLLOW ERS ) ĊĠĠĠĠĠĠĠ Ġval Ġnote Id Ġ= ĠData Updater ( ma ). on Activity ( activity )?. get Note ()?. note Id Ġ?: Ġ 0 ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" Note Ġadded ", Ġ 0 , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNot Equals (" First Ġactivity Ġadded ", Ġ 0 , Ġactivity . getId ()) ĊĠĠĠĠĠĠĠ Ġval Ġaudience : ĠAud ience Ġ= Ġfrom Note Id ( account Actor . origin , Ġnote Id ) ĊĠĠĠĠĠĠĠ ĠDemo Note Inser ter . Companion . assert Visibility ( audience , ĠVisibility . TO _ FOLLOW ERS ) ĊĠĠĠ Ġ} Ċ } Ċ