package Ġcom . alf ons os ote lo . express gift . vendor . ui Ċ Ċ import Ġcom . alf ons os ote lo . express gift . data . entities . Gift Ċ import Ġcom . alf ons os ote lo . express gift . vendor . Base Test Ċ import Ġcom . alf ons os ote lo . express gift . vendor . ui . Shared ViewModel . Companion . G IFT _ SELECTED Ċ import Ġcom . alf ons os ote lo . express gift . vendor . ui . Shared ViewModel . Companion . QR _ SCAN N ED _ AUTHORIZ ED Ċ import Ġcom . alf ons os ote lo . express gift . vendor . ui . Shared ViewModel . Companion . QR _ SCAN N ED _ DECL IN ED Ċ import Ġcom . alf ons os ote lo . express gift . vendor . ui . Shared ViewModel . Companion . SCAN _ STATUS Ċ import Ġcom . google . android . gms . near by . messages . Message Ċ import Ġcom . google . gson . Gson Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito Ċ Ċ class ĠShared ViewModel Test : ĠBaseTest () Ġ{ ĊĊĠĠĠ Ġlateinit Ġvar ĠviewModel : ĠShared ViewModel ĊĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠMockito . spy ( Shared ViewModel ( application Mock )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnotify Received Qr Auth () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMockito . mock ( Message :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . type ). thenReturn ( SCAN _ STATUS ) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . content ). thenReturn ( QR _ SCAN N ED _ AUTHORIZ ED . toByteArray ()) ĊĊĠĠĠĠĠĠĠ ĠviewModel . notify Received ( message ) ĊĊĠĠĠĠĠĠĠ Ġassert ( viewModel . qr Auth Status . value Ġ== ĠQR _ SCAN N ED _ AUTHORIZ ED ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . content ). thenReturn ( QR _ SCAN N ED _ DECL IN ED . toByteArray ()) ĊĊĠĠĠĠĠĠĠ ĠviewModel . notify Received ( message ) ĊĊĠĠĠĠĠĠĠ Ġassert ( viewModel . qr Auth Status . value Ġ== ĠQR _ SCAN N ED _ DECL IN ED ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnotify Received Gift Selected () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMockito . mock ( Message :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġgift Ġ= ĠMockito . spy ( Gift ()) ĊĠĠĠĠĠĠĠ Ġgift . id Ġ= Ġ 1 2 ĊĠĠĠĠĠĠĠ Ġgift . name Ġ= Ġ" Gift Ġ# 1 2 " ĊĊĠĠĠĠĠĠĠ Ġvar Ġgift Json Ġ= ĠGson (). toJson ( gift ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . type ). thenReturn ( G IFT _ SELECTED ) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . content ). thenReturn ( gift Json . toByteArray ()) ĊĊĠĠĠĠĠĠĠ ĠviewModel . notify Received ( message ) ĊĊĠĠĠĠĠĠĠ Ġassert ( viewModel . gift Selected . value Ġ!= Ġnull ) ĊĠĠĠĠĠĠĠ Ġassert ( gift . id Ġ== ĠviewModel . gift Selected . value ?. id ) ĊĠĠĠĠĠĠĠ Ġassert ( Gson (). toJson ( viewModel . gift Selected . value ) Ġ== Ġgift Json ) ĊĊĠĠĠĠĠĠĠ Ġgift . id Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġgift Json Ġ= ĠGson (). toJson ( gift ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( message . content ). thenReturn ( gift Json . toByteArray ()) ĊĊĠĠĠĠĠĠĠ ĠviewModel . notify Received ( message ) ĊĊĠĠĠĠĠĠĠ Ġassert ( viewModel . gift Selected . value Ġ== Ġnull ) ĊĠĠĠ Ġ} Ċ }