package Ġcom . next breakpoint . flink . k 8 s . controller . action Ċ Ċ import Ġcom . next breakpoint . flink . common . F link Options Ċ import Ġcom . next breakpoint . flink . k 8 s . common . F link Client Ċ import Ġcom . next breakpoint . flink . k 8 s . common . Kube Client Ċ import Ġcom . next breakpoint . flink . k 8 s . controller . core . Result Status Ċ import Ġcom . next breakpoint . flink . testing . Kotlin Mockito . any Ċ import Ġcom . next breakpoint . flink . testing . Kotlin Mockito . eq Ċ import Ġcom . next breakpoint . flink . testing . Kotlin Mockito . given Ċ import Ġio . kubernetes . client . openapi . models . V 1 Service Ċ import Ġio . kubernetes . client . openapi . models . V 1 Service Builder Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Mockito . mock Ċ import Ġorg . mockito . Mockito . times Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . Mockito . verify No More Interactions Ċ Ċ class ĠService Create Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġservice Ġ= Ġmock ( V 1 Service :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġf link Options Ġ= ĠF link Options ( hostname Ġ= Ġ" localhost ", Ġport Forward Ġ= Ġnull , Ġuse Node Port Ġ= Ġfalse ) ĊĠĠĠ Ġprivate Ġval Ġf link Client Ġ= Ġmock ( F link Client :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġkube Client Ġ= Ġmock ( Kube Client :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġcommand Ġ= ĠService Create ( flink Options , Ġf link Client , Ġkube Client ) ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġconfigure () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= ĠV 1 Service Builder (). with New Metadata (). with Name (" xxx "). end Metadata (). build () ĊĠĠĠĠĠĠĠ Ġgiven ( kube Client . create Service ( eq (" flink "), Ġany ())). thenReturn ( service ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġfail Ġwhen Ġkube Client Ġthrows Ġexception `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven ( kube Client . create Service ( eq (" flink "), Ġany ())). then Throw ( RuntimeException :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġcommand . execute (" flink ", Ġ" test ", Ġservice ) ĊĠĠĠĠĠĠĠ Ġverify ( kube Client , Ġtimes ( 1 )). create Service ( eq (" flink "), Ġany ()) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( kube Client ) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( flink Client ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isNotNull () ĊĠĠĠĠĠĠĠ ĠassertThat ( result . status ). isEqualTo ( Result Status . ERROR ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . output ). isNull () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġservice `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġcommand . execute (" flink ", Ġ" test ", Ġservice ) ĊĠĠĠĠĠĠĠ Ġverify ( kube Client , Ġtimes ( 1 )). create Service ( eq (" flink "), Ġany ()) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( kube Client ) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( flink Client ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isNotNull () ĊĠĠĠĠĠĠĠ ĠassertThat ( result . status ). isEqualTo ( Result Status . OK ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . output ). isEqualTo (" xxx ") ĊĠĠĠ Ġ} Ċ }