package Ġex po . modules . updates . manifest Ċ Ċ import Ġandroid . net . Uri Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . internal . runner . junit 4 . Android JUnit 4 Class Runner Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġex po . modules . manifest s . core . New Manifest Ċ import Ġex po . modules . updates . Updates Configuration Ċ import Ġex po . modules . updates . db . Updates Database Ċ import Ġorg . json . JSONException Ċ import Ġorg . json . JSONObject Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 Class Runner :: class ) Ċ class ĠUpdate Manifest Metadata Test Ġ{ ĊĠ Ġprivate Ġlateinit Ġvar Ġdb : ĠUpdates Database ĊĠ Ġprivate Ġlateinit Ġvar Ġconfig : ĠUpdates Configuration ĊĠ Ġprivate Ġlateinit Ġvar Ġmanifest : ĠNew Manifest ĊĊĠ Ġ@ Before ĊĠ Ġ@ Throws ( JSONException :: class ) ĊĠ Ġfun Ġsetup Manifest () Ġ{ ĊĠĠĠ Ġval Ġmanifest String Ġ= ĊĠĠĠĠĠ Ġ"{\" runtime Version \":\" 1 \",\" id \":\" 0 eef 8 2 1 4 - 4 8 3 3 - 4 0 8 9 - 9 dff - b 4 1 3 8 a 1 4 f 1 9 6 \",\" createdAt \":\" 2 0 2 0 - 1 1 - 1 1 T 0 0 : 1 7 : 5 4 . 7 9 7 Z \",\" launch Asset \":{\" url \":\" https :// url . to / bundle . js \",\" contentType \":\" application / javascript \" }}" ĊĠĠĠ Ġmanifest Ġ= ĠNew Manifest ( JSONObject ( manifest String )) ĊĠĠĠ Ġconfig Ġ= Ġcreate Config () ĊĠ Ġ} ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġcreate Db () Ġ{ ĊĠĠĠ Ġval Ġcontext Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĠĠĠ Ġdb Ġ= ĠRoom . in Memory Database Builder ( context , ĠUpdates Database :: class . java ). build () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun Ġclose Db () Ġ{ ĊĠĠĠ Ġdb . close () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Throws ( JSONException :: class ) ĊĠ Ġfun Ġtest Manifest Filters _ Overwrite All Fields () Ġ{ ĊĠĠĠ Ġval Ġheaders 1 Ġ= ĠManifest Header Data ( manifest Filters Ġ= Ġ" branch - name =\" rol lout - 1 \", test =\" value \" ") ĊĠĠĠ Ġval Ġupdate Manifest 1 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 1 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 1 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġheaders 2 Ġ= ĠManifest Header Data ( manifest Filters Ġ= Ġ" branch - name =\" rol lout - 2 \" ") ĊĠĠĠ Ġval Ġupdate Manifest 2 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 2 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 2 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġactual Ġ= ĠManifest Metadata . get Manifest Filters ( db , Ġconfig ) ĊĠĠĠ ĠAssert . assertNotNull ( actual ) ĊĠĠĠ ĠAssert . assertEquals ( 1 , Ġactual !!. length (). to Long ()) ĊĠĠĠ ĠAssert . assertEquals (" rol lout - 2 ", Ġactual . getString (" branch - name ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Throws ( JSONException :: class ) ĊĠ Ġfun Ġtest Manifest Filters _ Overwrite Empty () Ġ{ ĊĠĠĠ Ġval Ġheaders 1 Ġ= ĠManifest Header Data ( manifest Filters Ġ= Ġ" branch - name =\" rol lout - 1 \" ") ĊĠĠĠ Ġval Ġupdate Manifest 1 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 1 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 1 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġheaders 2 Ġ= ĠManifest Header Data ( manifest Filters Ġ= Ġ"") ĊĠĠĠ Ġval Ġupdate Manifest 2 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 2 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 2 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġactual Ġ= ĠManifest Metadata . get Manifest Filters ( db , Ġconfig ) ĊĠĠĠ ĠAssert . assertNotNull ( actual ) ĊĠĠĠ ĠAssert . assertEquals ( 0 , Ġactual !!. length (). to Long ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Throws ( JSONException :: class ) ĊĠ Ġfun Ġtest Manifest Filters _ Overwrite Null () Ġ{ ĊĠĠĠ Ġval Ġheaders 1 Ġ= ĠManifest Header Data ( manifest Filters Ġ= Ġ" branch - name =\" rol lout - 1 \" ") ĊĠĠĠ Ġval Ġupdate Manifest 1 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 1 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 1 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġheaders 2 Ġ= ĠManifest Header Data () ĊĠĠĠ Ġval Ġupdate Manifest 2 : ĠUpdate Manifest Ġ= ĠNew Update Manifest . from New Manifest ( manifest , Ġheaders 2 , Ġnull , Ġconfig ) ĊĠĠĠ ĠManifest Metadata . save Metadata ( update Manifest 2 , Ġdb , Ġconfig ) ĊĊĠĠĠ Ġval Ġactual Ġ= ĠManifest Metadata . get Manifest Filters ( db , Ġconfig ) ĊĠĠĠ ĠAssert . assertNotNull ( actual ) ĊĠĠĠ ĠAssert . assertEquals ( 1 , Ġactual !!. length (). to Long ()) ĊĠĠĠ ĠAssert . assertEquals (" rol lout - 1 ", Ġactual . getString (" branch - name ")) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Config (): ĠUpdates Configuration Ġ{ ĊĠĠĠ Ġreturn ĠUpdates Configuration (). load Values From Map ( ĊĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠ Ġ" update Url " Ġto ĠUri . parse (" https :// exp . host /@ test / test ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ