package Ġde . br ing me ister . connect . product . application . shop Ċ Ċ import Ġch . qos . log back . classic . Logger Ċ import Ġch . qos . log back . classic . spi . I Logging Event Ċ import Ġch . qos . log back . core . Appender Ċ import Ġde . br ing me ister . connect . product . domain . product . Product Number Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Argument Captor Ċ import Ġorg . mockito . Captor Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ import Ġorg . slf 4 j . LoggerFactory Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠShop Service Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġapp ender : ĠApp ender < I Logging Event > ĊĊĠĠĠ Ġ@ Captor ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcapt or : ĠArgument Captor < I Logging Event > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlogger Ġ= ĠLoggerFactory . getLogger ( Logger . ROOT _ LOGGER _ NAME ) Ġas ĠLogger ĊĠĠĠĠĠĠĠ Ġlogger . add Appender ( appender ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlogger Ġ= ĠLoggerFactory . getLogger ( Logger . ROOT _ LOGGER _ NAME ) Ġas ĠLogger ĊĠĠĠĠĠĠĠ Ġlogger . detach Appender ( appender ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġupdate ĠImage ĠCDN `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= ĠUpdate Shop Command ( Product Number (" P - 0 0 0 0 0 1 ")) ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= ĠShop Service () ĊĠĠĠĠĠĠĠ Ġservice . handle ( command ) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( appender ). do Append ( capt or . capture ()) ĊĠĠĠĠĠĠĠ Ġval Ġlogging Event Ġ= Ġcapt or . value ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( logging Event . formatted Message , Ġ" Shop Ġhas Ġbeen Ġupdated . Ġ[ product Number = P - 0 0 0 0 0 1 ]"); ĊĠĠĠ Ġ} Ċ }