package Ġat . tu gr az 0 5 . slim cat Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Button Ċ import Ġandroid . widget . Seek Bar Ċ import Ġandroidx . core . os . bundle Of Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions .* Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġjunit . framework . TestCase Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . kotlin . any Ċ import Ġorg . mockito . kotlin . never Ċ import Ġjava . time . LocalDate Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠAdd cat Activity Test Ġ: ĠTestCase () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġtxt ids Ġ= ĠarrayOf ( R . id . txt _ name , ĠR . id . txt _ race , ĠR . id . txt _ size , ĠR . id . txt _ weight ) ĊĠĠĠ Ġprivate Ġval Ġswitch ids Ġ= ĠarrayOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . switch _ o be se , ĠR . id . switch _ over weight , ĠR . id . switch _ hospital ized , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . switch _ ne uter ed , ĠR . id . switch _ gest ation , ĠR . id . switch _ l act ation ĊĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġval Ġids Ġ= ĠarrayOf ( R . id . seek _ gender , ĠR . id . btn _ camera ) Ġ+ Ġtxt ids Ġ+ Ġswitch ids ĊĠĠĠ Ġprivate Ġval Ġrow ids Ġ= ĠarrayOf ( R . id . row _ gest ation , ĠR . id . row _ l act ation ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġhas All Input Fields () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġids . forEach Ġ{ Ġon View ( with Id ( it )) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinput Fields Editable () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġ( txt ids Ġ+ Ġswitch ids ). forEach Ġ{ Ġon View ( with Id ( it )). check ( matches ( is Clickable ())) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmale Label Click Hide Female () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label _ gender _ female )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label _ gender _ male )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġrow ids . forEach Ġ{ Ġid Ġ-> Ġon View ( with Id ( id )). perform ( waitFor < View > Ġ{ Ġit . visibility Ġ== ĠView . GONE Ġ}) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmale Seek er Change Hide Female () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). perform ( scrollTo ()). perform ( call Method < Seek Bar > Ġ{ Ġit . progress Ġ= ĠAdd cat Activity . F EM ALE Ġ}) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). perform ( scrollTo ()). perform ( call Method < Seek Bar > Ġ{ Ġit . progress Ġ= ĠAdd cat Activity . M ALE Ġ}) ĊĠĠĠĠĠĠĠ Ġrow ids . forEach Ġ{ Ġid Ġ-> Ġon View ( with Id ( id )). perform ( waitFor < View > Ġ{ Ġit . visibility Ġ== ĠView . GONE Ġ}) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclicking Gender Labels Changes Seek er () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label _ gender _ female )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label _ gender _ male )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). perform ( waitFor < Seek Bar > Ġ{ Ġit . progress Ġ== ĠAdd cat Activity . M ALE Ġ}) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label _ gender _ female )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). perform ( waitFor < Seek Bar > Ġ{ Ġit . progress Ġ== ĠAdd cat Activity . F EM ALE Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbtn Date picker Is Clickable () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ dob )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbtn Date picker Is Displayed () Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ dob )). perform ( scrollTo ()). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Cat Test On Add () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdb Helper Ġ= ĠMockito . mock ( Database Helper :: class . java ) ĊĠĠĠĠĠĠĠ ĠDatabase Helper . mock ( db Helper ) ĊĠĠĠĠĠĠĠ ĠMockito . do Answer Ġ{ ĠLog . d (" remove Cat Test ", Ġit . arguments [ 0 ] Ġas ĠString ) Ġ}. ` when `( db Helper ). delete Cat (" test ") ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ delete )). perform ( waitFor < Button > Ġ{ Ġit . visibility Ġ== ĠView . GONE Ġ}) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( db Helper , Ġnever ()). delete Cat (" test ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Cat Test On Edit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġdate _ of _ birth Ġ= Ġ" 2 0 1 9 - 5 - 1 2 ", Ġsize Ġ= Ġ 1 2 . 0 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġdb Helper Ġ= ĠMockito . mock ( Database Helper :: class . java ) ĊĠĠĠĠĠĠĠ ĠDatabase Helper . mock ( db Helper ) ĊĠĠĠĠĠĠĠ ĠMockito . do Answer Ġ{ ĠLog . d (" remove Cat Test ", Ġit . arguments [ 0 ] Ġas ĠString ) Ġ}. ` when `( db Helper ). delete Cat (" test ") ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( Application Provider . getApplicationContext (), ĠAdd cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ delete )). perform ( close Soft Keyboard ()). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( db Helper ). delete Cat (" test ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġopen Edit Cat () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġdate _ of _ birth Ġ= Ġ" 2 0 1 9 - 5 - 1 2 ", Ġsize Ġ= Ġ 1 2 . 0 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġdb Helper Ġ= ĠMockito . mock ( Database Helper :: class . java ) ĊĠĠĠĠĠĠĠ ĠDatabase Helper . mock ( db Helper ) ĊĠĠĠĠĠĠĠ ĠMockito . do Answer Ġ{ ĠLog . d (" open Edit Cat ", Ġ"${ it . arguments [ 0 ] Ġas ĠString }: Ġ${ it . arguments [ 1 ] Ġas ĠCat Data Class }") Ġ}. ` when `( db Helper ). edit User ( any (), Ġany ()) ĊĊĠĠĠĠĠĠĠ Ġcat . age Ġ= ĠUtil . calculate Age ( date _ of _ birth Ġ= ĠLocalDate . of ( 2 0 1 9 , Ġ 5 , Ġ 1 2 ), ĠLocalDate . now ()) ĊĠĠĠĠĠĠĠ Ġcat . cal or ie Recommendation Ġ= ĠUtil . calculate Cal ories ( cat ) ĊĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( Application Provider . getApplicationContext (), ĠAdd cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ name )). check ( matches ( with Text ( cat . name ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ race )). check ( matches ( with Text ( cat . race ))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ size )). check ( matches ( with Text ( cat . getSize Str ()))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ weight )). check ( matches ( with Text ( cat . get Weight Str ()))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). check ( assert View < Seek Bar > Ġ{ ĠassertEquals ( Add cat Activity . M ALE , Ġit . progress ) Ġ}) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ save )). perform ( close Soft Keyboard ()). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠLog . d (" open Edit Cat ", Ġ"$ cat ") ĊĠĠĠĠĠĠĠ ĠMockito . verify ( db Helper ). edit User (" test ", Ġcat ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġopen Add Cat () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġsize Ġ= Ġ 1 2 . 0 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġdb Helper Ġ= ĠMockito . mock ( Database Helper :: class . java ) ĊĠĠĠĠĠĠĠ ĠDatabase Helper . mock ( db Helper ) ĊĠĠĠĠĠĠĠ ĠMockito . do Answer Ġ{ ĠLog . d (" open Add Cat ", Ġ( it . arguments [ 0 ] Ġas ĠCat Data Class ). name !! ) Ġ}. ` when `( db Helper ). write New Cat ( any ()) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Add cat Activity :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġcat . cal or ie Recommendation Ġ= ĠUtil . calculate Cal ories ( cat ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġthat Ġempty ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ name )). check ( matches ( with Text (" "))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ race )). check ( matches ( with Text (" "))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ size )). check ( matches ( with Text (" "))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ weight )). check ( matches ( with Text (" "))) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). check ( assert View < Seek Bar > Ġ{ ĠassertEquals ( Add cat Activity . F EM ALE , Ġit . progress ) Ġ}) ĊĊĠĠĠĠĠĠĠ Ġ// Ġfill Ġin Ġcat Ġdata ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ name )). perform ( scrollTo ()). perform ( type Text ( cat . name )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ race )). perform ( scrollTo ()). perform ( type Text ( cat . race )) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ size )). perform ( scrollTo ()). perform ( clear Text ()). perform ( type Text ( cat . getSize Str ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ weight )). perform ( scrollTo ()). perform ( clear Text ()). perform ( type Text ( cat . get Weight Str ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . seek _ gender )). perform ( scrollTo ()). perform ( call Method < Seek Bar > Ġ{ Ġit . progress Ġ= Ġcat . gender Ġ}) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ save )). perform ( close Soft Keyboard ()). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( db Helper ). write New Cat ( cat ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġweight Unit Switch () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġdate _ of _ birth Ġ= Ġ" 0 ", Ġsize Ġ= Ġ 3 . 5 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġin L bs Ġ= ĠUtil . convert Kg To L bs ( cat . weight !! ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġswitch Ġto Ġimp erial Ġsystem ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Settings Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . settings _ unit _ of _ measurement _ l bs )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . setting _ btn _ save )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( Application Provider . getApplicationContext (), ĠAdd cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ weight )). perform ( scrollTo ()). check ( matches ( with Text ( in L bs . toString ()))) ĊĊĠĠĠĠĠĠĠ Ġ// Ġswitch Ġback Ġto Ġmetric Ġsystem ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Settings Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . settings _ unit _ of _ measurement _ kg )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . setting _ btn _ save )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ weight )). perform ( scrollTo ()). check ( matches ( with Text ( cat . get Weight Str ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġafter Ġchanging Ġsize Ġfrom ĠInt Ġdo ĠDouble Ġadjust ĠTest ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsize Unit Switch () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġdate _ of _ birth Ġ= Ġ" 0 ", Ġsize Ġ= Ġ 3 . 5 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġin In ch Ġ= ĠUtil . convert Cm To In ch ( cat . size !! ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġswitch Ġto Ġimp erial Ġsystem ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Settings Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . settings _ unit _ of _ measurement _ l bs )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . setting _ btn _ save )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( Application Provider . getApplicationContext (), ĠAdd cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ size )). perform ( scrollTo ()). check ( matches ( with Text ( in In ch . toInt (). toString ()))) ĊĊĠĠĠĠĠĠĠ Ġ// Ġswitch Ġback Ġto Ġmetric Ġsystem ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch ( Settings Activity :: class . java ). on Activity Ġ{ Ġit . hide Keyboard () Ġ} ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . settings _ unit _ of _ measurement _ kg )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . setting _ btn _ save )). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . txt _ size )). perform ( scrollTo ()). check ( matches ( with Text ( cat . getSize Str ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Cal ories (){ ĊĠĠĠĠĠĠĠ Ġval Ġcat Ġ= ĠCat Data Class ( name Ġ= Ġ" test ", Ġrace Ġ= Ġ" lig er ", Ġdate _ of _ birth Ġ= Ġ" 2 0 1 9 - 5 - 1 2 ", Ġsize Ġ= Ġ 1 2 . 0 , Ġweight Ġ= Ġ 3 . 5 , Ġgender Ġ= ĠAdd cat Activity . M ALE ) ĊĠĠĠĠĠĠĠ Ġval Ġdb Helper Ġ= ĠMockito . mock ( Database Helper :: class . java ) ĊĠĠĠĠĠĠĠ ĠDatabase Helper . mock ( db Helper ) ĊĠĠĠĠĠĠĠ ĠMockito . do Answer Ġ{ ĠLog . d (" open Edit Cat ", Ġ"${ it . arguments [ 0 ] Ġas ĠString }: Ġ${ it . arguments [ 1 ] Ġas ĠCat Data Class }") Ġ}. ` when `( db Helper ). edit User ( any (), Ġany ()) ĊĊĠĠĠĠĠĠĠ Ġcat . age Ġ= ĠUtil . calculate Age ( date _ of _ birth Ġ= ĠLocalDate . of ( 2 0 1 9 , Ġ 5 , Ġ 1 2 ), ĠLocalDate . now ()) ĊĠĠĠĠĠĠĠ Ġcat . cal or ie Recommendation Ġ= ĠUtil . calculate Cal ories ( cat ) Ġ- Ġ 2 0 ĊĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( Application Provider . getApplicationContext (), ĠAdd cat Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle Of ( Constants . CAT _ PARAM Ġto Ġcat )) ĊĠĠĠĠĠĠĠ ĠActivity Scenario . launch < Add cat Activity >( intent ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġthis Ġtriggers Ġa Ġre calculation Ġof Ġthe Ġcal ories ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ save )). perform ( close Soft Keyboard ()). perform ( scrollTo ()). perform ( click ()) ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠLog . d (" open Edit Cat ", Ġ"$ cat ") ĊĠĠĠĠĠĠĠ ĠMockito . verify ( db Helper ). edit User (" test ", Ġcat ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ