package Ġio . dot an uki . demos . nor ris Ċ Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . ade vint a . android . bar ista . interaction . Bar ista Click Interactions . click On Ċ import Ġcom . ade vint a . android . bar ista . rule . fl aky . Fl aky Test Rule Ċ import Ġcom . ade vint a . android . bar ista . rule . fl aky . Repeat Ċ import Ġio . dot an uki . nor ris . facts . ui . Fact s Activity Ċ import Ġio . dot an uki . testing . pers istance . Pers istance Helper Ċ import Ġio . dot an uki . testing . rest . Rest Data Builder Ċ import Ġio . dot an uki . testing . rest . Rest Infrastructure Rule Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Rule Chain Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠNor ris Accept ance Tests Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġrest Infrastructure Ġ= ĠRest Infrastructure Rule ( custom Port Ġ= Ġ 4 2 4 2 ) ĊĠĠĠ Ġprivate Ġval Ġst ressed Execution Ġ= ĠFl aky Test Rule () ĊĊĠĠĠ Ġ@ get : Rule Ġval Ġrules : ĠRule Chain Ġ= ĊĠĠĠĠĠĠĠ ĠRule Chain . outer Rule ( st ressed Execution ). around ( rest Infrastructure ) ĊĊĠĠĠ Ġ@ Before Ġfun ĠbeforeEach Test () Ġ{ ĊĠĠĠĠĠĠĠ ĠPers istance Helper . clear Storage () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Repeat Ġ@ Test Ġfun Ġshould Perform First Search _ After First L unch _ By Typing AT erm () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġsearch Term Ġ= Ġ" math " ĊĠĠĠĠĠĠĠ Ġval Ġsuggestions Ġ= ĠlistOf (" care er ", Ġ" dev ", Ġ" hum or ") ĊĠĠĠĠĠĠĠ Ġval Ġfact Ġ= Ġ" Ch uck ĠNor ris Ġcan Ġdivide Ġby Ġzero " ĊĊĠĠĠĠĠĠĠ Ġval Ġsuggestions Payload Ġ= ĠRest Data Builder . suggestions Payload ( suggestions ) ĊĠĠĠĠĠĠĠ Ġval Ġfacts Payload Ġ= ĠRest Data Builder . facts Payload ( search Term , Ġfact ) ĊĊĠĠĠĠĠĠĠ Ġrest Infrastructure . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrest Scenario ( 2 0 0 , Ġsuggestions Payload ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrest Scenario ( 2 0 0 , Ġfacts Payload ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġstarting From < Fact s Activity > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck Empty State () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick On Search Icon () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġawait Transition () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck Suggestions ( suggestions ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġperform Search ( search Term ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġawait Transition () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck Displayed ( fact ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Repeat Ġ@ Test Ġfun Ġshould Perform A Second Search _ By Ch osing AS uggest ion () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġsearches Ġ= ĠlistOf (" math ", Ġ" code "). on Each Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPers istance Helper . register New Search ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsuggestions Ġ= ĠlistOf (" care er ", Ġ" dev ", Ġ" hum or ") ĊĠĠĠĠĠĠĠ Ġval Ġmath Fact Ġ= Ġ" Ch uck ĠNor ris Ġcan Ġdivide Ġby Ġzero " ĊĠĠĠĠĠĠĠ Ġval Ġcode Fact Ġ= Ġ" Null Ġpointer Ġwill Ġbreak Ġwith ĠCh uck Nor ris Exception " ĊĊĠĠĠĠĠĠĠ Ġval Ġmath Fact Payload Ġ= ĠRest Data Builder . facts Payload (" math ", Ġmath Fact ) ĊĠĠĠĠĠĠĠ Ġval Ġsuggestions Payload Ġ= ĠRest Data Builder . suggestions Payload ( suggestions ) ĊĠĠĠĠĠĠĠ Ġval Ġcode Fact Payload Ġ= ĠRest Data Builder . facts Payload (" code ", Ġcode Fact ) ĊĊĠĠĠĠĠĠĠ Ġrest Infrastructure . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrest Scenario ( 2 0 0 , Ġmath Fact Payload ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrest Scenario ( 2 0 0 , Ġsuggestions Payload ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrest Scenario ( 2 0 0 , Ġcode Fact Payload ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġstarting From < Fact s Activity > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck Displayed ( math Fact ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick On Search Icon () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġawait Transition () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck History ( sear ches ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick On (" code ") ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġawait Transition () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck Displayed ( code Fact ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ