package Ġru . rom ang r . cat bot . handler Ċ Ċ import Ġorg . assertj . core . api . Assertions Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Argument Matchers Ċ import Ġorg . mockito . BDD Mockito Ċ import Ġorg . mockito . Mockito Ċ import Ġru . rom ang r . cat bot . executor . action . Telegram Action Ċ import Ġru . rom ang r . cat bot . executor . action . Telegram Action Factory Ċ import Ġru . rom ang r . cat bot . statistic . Statistic Service Ċ import Ġru . rom ang r . cat bot . subscription . Message To Sub scribers Ċ import Ġru . rom ang r . cat bot . subscription . Sub scribers Service Ċ import Ġru . rom ang r . cat bot . telegram . dto . Document Ċ import Ġru . rom ang r . cat bot . telegram . model . Chat Ċ import Ġru . rom ang r . cat bot . telegram . model . Message Ċ import Ġru . rom ang r . cat bot . telegram . model . User Ċ import Ġru . rom ang r . cat bot . test . utils . any Chat Ċ Ċ internal Ġclass ĠDocument Handler Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġsubscribers Service : ĠSub scribers Service Ġ= ĠMockito . mock ( Sub scribers Service :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġaction Factory : ĠTelegram Action Factory Ġ= ĠMockito . mock ( Telegram Action Factory :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġstatistic Service : ĠStat istic Service Ġ= ĠMockito . mock ( Statistic Service :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġhandler Ġ= ĠDocument Handler ( action Factory , Ġsubscribers Service , Ġ 1 , Ġstatistic Service ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġinternal Ġfun Ġvalid Argument () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Ġ= ĠChat ( 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġuser Ġ= ĠUser . builder (). id ( 1 ). build () ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( action Factory . new SendMessage Action ( any Chat (), ĠArgument Matchers . any String ())) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( Mockito . mock ( Telegram Action :: class . java )) ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( subscribers Service . message Queue Length ). willReturn ( 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMessage ( document Ġ= ĠDocument (" id "), Ġchat Ġ= Ġchat , Ġfrom Ġ= Ġuser , Ġid Ġ= Ġ 2 1 3 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġhandler . handle ( chat , Ġmessage ) ĊĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . is Value Present ). isTrue () ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . status ). isEqualTo ( Handling Status . HAND LED ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . actions ). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( action Factory ). new SendMessage Action ( chat , Ġ" Document Ġis Ġadded Ġto Ġthe Ġqueue , Ġthere Ġare Ġ 1 Ġmessage ( s )") ĊĠĠĠĠĠĠĠ ĠMockito . verify ( subscribers Service ). addMessage To Sub scribers ( Message To Sub scribers . document Message (" id ")) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( subscribers Service ). message Queue Length ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( subscribers Service , Ġaction Factory ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġinternal Ġfun Ġnot Admin () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Ġ= ĠChat ( 1 0 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġuser Ġ= ĠUser . builder (). id ( 1 0 1 ). build () ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMessage ( document Ġ= ĠDocument (" id "), Ġchat Ġ= Ġchat , Ġfrom Ġ= Ġuser , Ġid Ġ= Ġ 2 1 3 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġhandler . handle ( chat , Ġmessage ) ĊĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . is Value Present ). isTrue () ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . status ). isEqualTo ( Handling Status . HAND LED ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . actions ). has Size ( 0 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( subscribers Service , Ġaction Factory ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġinternal Ġfun Ġnot Applicable () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Ġ= ĠChat ( 1 0 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġuser Ġ= ĠUser . builder (). id ( 1 0 1 ). build () ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMessage ( text Ġ= Ġ"/ some - command Ġtest ", Ġchat Ġ= Ġchat , Ġfrom Ġ= Ġuser , Ġid Ġ= Ġ 2 1 3 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġhandler . handle ( chat , Ġmessage ) ĊĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . is Value Present ). isTrue () ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . status ). isEqualTo ( Handling Status . SKIP PED ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( result . value . actions ). has Size ( 0 ) ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( subscribers Service , Ġaction Factory ) ĊĠĠĠ Ġ} Ċ } Ċ