package Ġorg . wikipedia . feed . announcement Ċ Ċ import Ġorg . hamcrest . Matcher Assert Ċ import Ġorg . hamcrest . Matchers Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . wikipedia . json . Json Util Ċ import Ġorg . wikipedia . test . Mock Ret rofit Test Ċ import Ġorg . wikipedia . test . Test File Util Ċ import Ġjava . text . SimpleDateFormat Ċ import Ġjava . util .* Ċ Ċ class ĠAnno uncement Client Test Ġ: ĠMock Ret rofit Test () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġanno uncement List : ĠAnno uncement List ĊĠĠĠ Ġprivate Ġval ĠdateFormat Ġ= ĠSimpleDateFormat (" yyyy - MM - dd ", ĠLocale . ROOT ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ Ġval Ġjson Ġ= ĠTest File Util . read Raw File ( AN NOUN CE MENT _ JSON _ FILE ) ĊĠĠĠĠĠĠĠ Ġanno uncement List Ġ= ĠJson Util . decode FromString ( json ) !! ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Request Success () Ġ{ ĊĠĠĠĠĠĠĠ Ġenqueue FromFile ( AN NOUN CE MENT _ JSON _ FILE ) ĊĠĠĠĠĠĠĠ Ġrest Service . announce ments . test (). await () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Complete () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert No Errors () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Value Ġ{ Ġit . items . size Ġ== Ġ 8 Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Request Malformed () Ġ{ ĊĠĠĠĠĠĠĠ Ġenqueue Malformed () ĊĠĠĠĠĠĠĠ Ġrest Service . announce ments . test (). await () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Error ( Exception :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Request NotFound () Ġ{ ĊĠĠĠĠĠĠĠ Ġenqueue 4 0 4 () ĊĠĠĠĠĠĠĠ Ġrest Service . announce ments . test (). await () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Error ( Exception :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Fund ra ising Params () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ FUN DR A ISING _ ANDROID ] ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( announcement . has Action (), ĠMatch ers .` is `( true )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( announcement . has Footer Caption (), ĠMatch ers .` is `( true )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( announcement . has ImageUrl (), ĠMatch ers .` is `( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Should Show By Country () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ SUR VE Y _ ANDROID ] ĊĠĠĠĠĠĠĠ Ġval Ġdate During Ġ= ĠdateFormat . parse (" 2 0 1 6 - 1 1 - 2 0 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate During ), ĠMatch ers .` is `( true )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" FI ", Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġnull , Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Should Show By Date () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ SUR VE Y _ ANDROID ] ĊĠĠĠĠĠĠĠ Ġval Ġdate Before Ġ= ĠdateFormat . parse (" 2 0 1 6 - 0 8 - 0 1 ") !! ĊĠĠĠĠĠĠĠ Ġval Ġdate After Ġ= ĠdateFormat . parse (" 2 0 1 7 - 0 1 - 0 5 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate Before ), ĠMatch ers .` is `( false )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate After ), ĠMatch ers .` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Should Show By Platform () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement IOS Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ IOS ] ĊĠĠĠĠĠĠĠ Ġval Ġdate During Ġ= ĠdateFormat . parse (" 2 0 1 6 - 1 1 - 2 0 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAnno uncement Client . should Show ( announcement IOS , Ġ" US ", Ġdate During ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMatch ers .` is `( false ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Should Show For Invalid Dates () Ġ{ ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( announcement List . items [ AN NOUN CE MENT _ INVALID _ DAT ES ], ĠMatch ers .` is `( Matchers . notNull Value ())) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( announcement List . items [ AN NOUN CE MENT _ NO _ DAT ES ], ĠMatch ers .` is `( Matchers . notNull Value ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Should Show For Invalid Countries () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ NO _ COUN TR IES ] ĊĠĠĠĠĠĠĠ Ġval Ġdate During Ġ= ĠdateFormat . parse (" 2 0 1 6 - 1 1 - 2 0 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" FI ", Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ"", Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest Beta With Version () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ B ETA _ WITH _ VERSION ] ĊĠĠĠĠĠĠĠ Ġval Ġdate During Ġ= ĠdateFormat . parse (" 2 0 1 6 - 1 1 - 2 0 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate During ), ĠMatch ers .` is `( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Throwable :: class ) ĊĠĠĠ Ġfun Ġtest For Old Version () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanno uncement Ġ= Ġanno uncement List . items [ AN NOUN CE MENT _ FOR _ OLD _ VERSION ] ĊĠĠĠĠĠĠĠ Ġval Ġdate During Ġ= ĠdateFormat . parse (" 2 0 1 6 - 1 1 - 2 0 ") !! ĊĠĠĠĠĠĠĠ ĠMatcher Assert . assertThat ( Anno uncement Client . should Show ( announcement , Ġ" US ", Ġdate During ), ĠMatch ers .` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ IOS Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ SUR VE Y _ ANDROID Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ FUN DR A ISING _ ANDROID Ġ= Ġ 2 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ INVALID _ DAT ES Ġ= Ġ 3 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ NO _ DAT ES Ġ= Ġ 4 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ NO _ COUN TR IES Ġ= Ġ 5 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ B ETA _ WITH _ VERSION Ġ= Ġ 6 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ FOR _ OLD _ VERSION Ġ= Ġ 7 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠAN NOUN CE MENT _ JSON _ FILE Ġ= Ġ" announce _ 2 0 1 6 _ 1 1 _ 2 1 . json " ĊĠĠĠ Ġ} Ċ } Ċ