package Ġmicro services . book . multip lication . service . impl Ċ Ċ import Ġmicro services . book . multip lication . service . Multip lication Service Ċ import Ġmicro services . book . multip lication . service . Random Generator Service Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . BDD Mockito . given Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ SpringBootTest Ċ class ĠMultip lication ServiceImpl Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġlateinit Ġvar Ġrandom Generator Service : ĠRandom Generator Service ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġmultiplication Service : ĠMultip lication Service ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Random Multip lication Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġgiven Ġ-> Ġour Ġmocked ĠRandom ĠGenerator Ġrandom Generator Service Ġwill Ġreturn Ġfirst Ġ 5 0 , Ġthen Ġ 3 0 ĊĠĠĠĠĠĠĠ Ġgiven ( random Generator Service . generate Random Factor ()). willReturn ( 5 0 , Ġ 3 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġwhen Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġmultiplication Ġ= Ġmultiplication Service . create Random Multip lication () ĊĊĠĠĠĠĠĠĠ Ġ// Ġassert Ġ-> ĊĠĠĠĠĠĠĠ ĠassertThat ( multip lication . factor A ). isEqualTo ( 5 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( multip lication . factor B ). isEqualTo ( 3 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( multip lication . result ). isEqualTo ( 1 5 0 0 ) ĊĠĠĠ Ġ} Ċ }