package Ġcom . real it ix . nect ar Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Large Test Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . real it ix . nect ar . background . Git Repository Synchron izer Ċ import Ġcom . real it ix . nect ar . background . synchron izer . Ali ment Synchron izer Ċ import Ġcom . real it ix . nect ar . background . synchron izer . String Key Synchron izer Ċ import Ġcom . real it ix . nect ar . repository . Git Repo Repository Ċ import Ġcom . real it ix . nect ar . util .* Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . io . File Ċ import Ġjava . lang . Thread . sleep Ċ import Ġjava . nio . file . Files ĊĊ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Large Test Ċ class ĠGit Repository Test Ġ{ ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule Ġ= ĠN ect ar Activity Test Rule () ĊĠĠĠ Ġprivate Ġval Ġapp Context Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĠĠĠ Ġprivate Ġval Ġtest Context Ġ= ĠInstrument ation Registry . get Instrumentation (). context ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Git Repository IsIn Setting () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . settings Fragment )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . fragment Settings Layout )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Text ( N ect ar Util . getProperty ( test Context , Ġ" default Git Repository Name ")) ). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck App Receive Data From Git Repository () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġclone Ġrepo Ġand Ġfill Ġit Ġwith Ġdata ĊĠĠĠĠĠĠĠ Ġval Ġgit Repository Ġ= ĠGit Repo Repository ( app Context ). get ByName ( N ect ar Util . getProperty ( test Context , Ġ" default Git Repository Name ")) !! ĊĠĠĠĠĠĠĠ Ġval Ġrepo Dir Ġ= ĠFile ( File ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Context . files Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠN ect ar Util . getProperty ( test Context , Ġ" repository Name Folder ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgit Repository . name ) ĊĠĠĠĠĠĠĠ Ġval Ġgit Manager Ġ= ĠGit Manager ( repo Dir , Ġgit Repository . url , Ġgit Repository . credentials ) ĊĠĠĠĠĠĠĠ Ġgit Manager . clean () ĊĠĠĠĠĠĠĠ ĠZip Util . unzip From Assets ( test Context , Ġ" test _ repository . zip ", Ġrepo Dir . absolute Path ) ĊĠĠĠĠĠĠĠ Ġgit Manager . addAll () ĊĠĠĠĠĠĠĠ Ġgit Manager . commit () ĊĠĠĠĠĠĠĠ Ġgit Manager . push () ĊĊĠĠĠĠĠĠĠ Ġ// Ġrun Ġsynchronization ĊĠĠĠĠĠĠĠ ĠGit Repository Synchron izer ( app Context ). exec () ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdata Ġsyn ch on ized ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" Re ce ipe ĠFrance ")). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" Re ce ipe Step ĠDescription ĠFrance ")). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" Ali ment ĠFrance ")). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck App Send DataTo Git Repository () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġclone Ġrepo Ġand Ġclean Ġit ĊĠĠĠĠĠĠĠ Ġval Ġgit Repository Ġ= ĠGit Repo Repository ( app Context ). get ByName ( N ect ar Util . getProperty ( test Context , Ġ" default Git Repository Name ")) !! ĊĠĠĠĠĠĠĠ Ġval Ġrepo Dir Ġ= ĠFile ( File ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Context . files Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠN ect ar Util . getProperty ( test Context , Ġ" repository Name Folder ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgit Repository . name ) ĊĠĠĠĠĠĠĠ Ġval Ġgit Manager Ġ= ĠGit Manager ( repo Dir , Ġgit Repository . url , Ġgit Repository . credentials ) ĊĠĠĠĠĠĠĠ Ġgit Manager . clean () ĊĊĠĠĠĠĠĠĠ Ġ// Ġadd Ġan Ġal iment Ġto Ġthe Ġrepository ĊĠĠĠĠĠĠĠ Ġval Ġname Fr Ġ= Ġ" TEST ĠNAME " ĊĠĠĠĠĠĠĠ Ġval Ġname Ġ= ĠString Key Synchron izer . Parse Result ( N ect ar Util . generate Uuid (), Ġmap Of (" fr " Ġto Ġname Fr )) ĊĠĠĠĠĠĠĠ Ġval Ġal iment Ġ= Ġ ĠAli ment Synchron izer . Parse Result ( N ect ar Util . generate Uuid (), Ġname . uuid , ĠlistOf (), ĠlistOf (), Ġmap Of ()) ĊĊĠĠĠĠĠĠĠ ĠN ect ar Util . write ToJson File ( File ( File ( repo Dir , ĠEntityType . STRING _ KEY . folder Name ), Ġname . uuid ), Ġname ) ĊĠĠĠĠĠĠĠ ĠN ect ar Util . write ToJson File ( File ( File ( repo Dir , ĠEntityType . AL IM ENT . folder Name ), Ġal iment . uuid ), Ġal iment ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCommit Ġand Ġpush ĊĠĠĠĠĠĠĠ Ġgit Manager . addAll () ĊĠĠĠĠĠĠĠ Ġgit Manager . commit () ĊĠĠĠĠĠĠĠ Ġgit Manager . push () ĊĊĠĠĠĠĠĠĠ Ġ// Ġrun Ġsynchronization ĊĠĠĠĠĠĠĠ ĠGit Repository Synchron izer ( app Context ). exec () ĊĊĠĠĠĠĠĠĠ Ġ// Ġcreate Ġa Ġrece ipe Ġwith Ġthe Ġal iment ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . fab )). perform ( click ()) ĊĠĠĠ Ġ} Ċ } Ċ