package Ġcom . and res . ny uz uk . data . datasource . remote . api Ċ Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġcom . and res . ny uz uk . data . UnitTest Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . eq Ċ import Ġokhttp 3 . Interceptor Ċ import Ġokhttp 3 . Request Ċ import Ġokhttp 3 . Response Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Argument Matchers Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . verify Ċ Ċ class ĠArticle ApiService Headers Test : ĠUnit Test () Ġ{ ĊĠĠĠ Ġprivate Ġval ĠSO ME _ API _ KEY Ġ= Ġ" qw erty 1 2 3 4 5 " ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġarticle ApiService Headers : ĠArticle ApiService Headers ĊĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġchain Mock : ĠInter ceptor . Chain ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġrequest Mock : ĠRequest ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġrequest Builder Mock : ĠRequest . Builder ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġother Request Mock : ĠRequest ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġresponse Mock : ĠResponse ĊĊĠĠĠ Ġoverride Ġfun Ġon Setup () Ġ{ ĊĠĠĠĠĠĠĠ Ġarticle ApiService Headers Ġ= ĠArticle ApiService Headers ( SO ME _ API _ KEY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġget Ġresponse Ġwith Ġheaders Ġwhen Ġintercept `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( chain Mock . proceed ( other Request Mock )). thenReturn ( response Mock ) ĊĠĠĠĠĠĠĠ Ġ` when `( request Builder Mock . build ()). thenReturn ( other Request Mock ) ĊĠĠĠĠĠĠĠ Ġ` when `( request Builder Mock . header ( Argument Matchers . any String (), ĠArgument Matchers . any String ())). thenReturn ( request Builder Mock ) ĊĠĠĠĠĠĠĠ Ġ` when `( request Mock . newBuilder ()). thenReturn ( request Builder Mock ) ĊĠĠĠĠĠĠĠ Ġ` when `( chain Mock . request ()). thenReturn ( request Mock ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġarticle ApiService Headers . intercept ( chain Mock ) ĊĊĠĠĠĠĠĠĠ Ġverify ( request Builder Mock ). header ( eq (" X - Api - Key "), Ġeq ( SO ME _ API _ KEY )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response ). isEqualTo ( response Mock ) ĊĠĠĠ Ġ} Ċ }