package Ġcom . example . android Ċ Ċ import Ġcom . example . android . data . remote . Ch ief Inspector Api Ċ import Ġcom . example . android . factory . Multi Part Factory Ċ import Ġcom . jak ew h art on . ret rofit 2 . adapter . rx java 2 . Rx Java 2 Call Adapter Factory Ċ import Ġcom . squareup . mos hi . M oshi Ċ Ċ import Ġio . reactivex . ob servers . Test Observer Ċ import Ġokhttp 3 . MediaType Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . mockito . runners . Mockito JUnit Runner Ċ import Ġretrofit 2 . Response Ċ import Ġretrofit 2 . Ret rofit Ċ Ċ import Ġjava . io . File Ċ import Ġokhttp 3 . RequestBody Ċ import Ġokhttp 3 . Multipart Body Ċ import Ġretrofit 2 . converter . scal ars . Scalars Converter Factory Ċ import Ġjava . util . concurrent . TimeUnit Ċ import Ġjavax . xml . datatype . Datatype Constants . SECONDS ĊĊĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠCh ief Inspector Test Ġ{ ĊĠ Ġinternal Ġlateinit Ġvar Ġapi : ĠCh ief Inspector Api ĊĠ Ġprivate Ġvar Ġretrofit : ĠRet rofit ? Ġ= Ġnull ĊĠ Ġprivate Ġval Ġok HttpClient : ĠOk HttpClient ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġm oshi : ĠM oshi ? Ġ= Ġnull ĊĠ Ġlateinit Ġvar Ġsession i D : ĠString ĊĊĊĠ Ġprivate Ġfun Ġsetup Ret rofit () Ġ{ ĊĠĠĠ Ġval Ġclient Ġ= ĠOk HttpClient . Builder () ĊĠĠĠĠĠ Ġ. connect Timeout ( 1 0 0 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠ Ġ. read Timeout ( 1 0 0 , ĠTimeUnit . SECONDS ). build () ĊĊĠĠĠ Ġretrofit Ġ= ĠRet rofit . Builder (). client ( client ) ĊĠĠĠĠĠ Ġ. add Call Adapter Factory ( Rx Java 2 Call Adapter Factory . create ()) ĊĠĠĠĠĠ Ġ. add Converter Factory ( Scalars Converter Factory . create ()) ĊĠĠĠĠĠ Ġ. baseUrl (" http :// pe ge ld aten . west e urope . cloud app . azure . com : 5 0 0 0 /") ĊĠĠĠĠĠ Ġ. build () ĊĠ Ġ} ĊĊĊĊĠ Ġ@ Before ĊĠ Ġ@ Throws ( Exception :: class ) ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠ Ġsetup Ret rofit () ĊĊĠĠĠ Ġapi Ġ= Ġretrofit !!. create ( Ch ief Inspector Api :: class . java ) ĊĊĠ Ġ} ĊĊĊĠ Ġ@ Test ĊĠ Ġfun Ġupload () Ġ{ ĊĠĠĠ Ġval Ġclass Loader Ġ= Ġjava Class . class Loader ĊĠĠĠ Ġval Ġfile Ġ= ĠFile ("/ Users / j ens k ling en berg / Git / Ch ief Inspector App / Application / src / test Debug / java / com / example / android / Container . jpg ") ĊĠĠĠ Ġval Ġbody Ġ= ĠMulti Part Factory . create Image Multipart ( file ) ĊĠĠĠ Ġval Ġname Ġ= ĠRequest Body . create ( MediaType . parse (" text / plain "), Ġ" upload ") ĊĠĠĠ Ġval Ġobserver Ġ= Ġapi . upload Image ( body , name ). test () ĊĠĠĠ Ġval Ġresponse Ġ= Ġobserver . assert No Errors () ĊĊĠĠ ĠAssert . assertNot Equals ("", response ) ĊĊĊĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġrequest New () Ġ{ ĊĊĠĠĠ Ġval Ġobserver Ġ= Ġapi . request New (). test () ĊĠĠĠ Ġval Ġresponse Ġ= Ġobserver . assert No Errors () ĊĊ Ċ // ĊĊĠ Ġ} ĊĊĊĊĊĊ Ċ } ĊĊ