package Ġcom . example . ni j ata hm ad li . blockchain wallet . presentation . transactions . viewModel Ċ Ċ import Ġcom . example . ni j ata hm ad li . blockchain wallet . domain . model . Transaction Ċ import Ġcom . example . ni j ata hm ad li . blockchain wallet . presentation . util . Converter Util Ċ import Ġcom . example . ni j ata hm ad li . blockchain wallet . presentation . util . Date Util Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Inject Mocks Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġjava . math . BigDecimal Ċ import Ġjava . math . BigInteger Ċ Ċ class ĠB c Transaction Item ViewModel Test Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠTIME _ M ILL IS Ġ= Ġ 1 2 3 4 5 6 7 L ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDATE Ġ= Ġ" 0 6 - 1 1 - 2 0 1 8 " ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠTS X _ RESULT Ġ= ĠBigInteger . valueOf ( 1 2 3 4 5 6 7 ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠA MOUNT _ BTC Ġ= ĠBigDecimal ( 1 2 3 4 5 6 7 8 9 ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠA MOUNT _ BTC _ NEGATIVE Ġ= ĠBigDecimal (- 1 2 3 4 5 6 7 8 9 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdate Util : ĠDate Util ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconverter Util : ĠConverter Util ĊĊĠĠĠ Ġ@ Inject Mocks ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsut : ĠB c Transaction Item ViewModel ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtransaction : ĠTransaction ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġ` when `( transaction . time ). thenReturn ( TIME _ M ILL IS ) ĊĠĠĠĠĠĠĠ Ġ` when `( transaction . result ). thenReturn ( TS X _ RESULT ) ĊĠĠĠĠĠĠĠ Ġ` when `( date Util . getDate ( TIME _ M ILL IS )). thenReturn ( DATE ) ĊĠĠĠĠĠĠĠ Ġ` when `( converter Util . sat oshi To Btc ( TS X _ RESULT )). thenReturn ( AMOUNT _ BTC ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Model _ should _ setDate () Ġ{ ĊĠĠĠĠĠĠĠ Ġsut . setModel ( transaction ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( sut . date . get ()). isEqualTo ( DATE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Model _ should _ set Amount () Ġ{ ĊĠĠĠĠĠĠĠ Ġsut . setModel ( transaction ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( sut . amount . get ()). isEqualTo ( AMOUNT _ BTC . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Model _ should _ setIs Negative To True _ when _ amount Is Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( converter Util . sat oshi To Btc ( TS X _ RESULT )). thenReturn ( AMOUNT _ BTC _ NEGATIVE ) ĊĊĠĠĠĠĠĠĠ Ġsut . setModel ( transaction ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( sut . is Negative . get ()). isTrue () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Model _ should _ setIs Negative To False _ when _ amount IsNot Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( converter Util . sat oshi To Btc ( TS X _ RESULT )). thenReturn ( AMOUNT _ BTC ) ĊĊĠĠĠĠĠĠĠ Ġsut . setModel ( transaction ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( sut . is Negative . get ()). isFalse () ĊĠĠĠ Ġ} Ċ }