package Ġno . sk at te et aten . aur ora . b oo ber . unit Ċ Ċ import Ġassert k . all Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . has Message Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġassert k . assertions . is Failure Ċ import Ġassert k . assertions . isInstanceOf Ċ import Ġassert k . assertions . isTrue Ċ import Ġcom . fasterxml . jackson . databind . JsonNode Ċ import Ġcom . fasterxml . jackson . databind . node . Null Node Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġno . sk at te et aten . aur ora . b oo ber . feature . Template Type Ċ import Ġno . sk at te et aten . aur ora . b oo ber . service . Re deploy Service Ċ import Ġno . sk at te et aten . aur ora . b oo ber . service . openshift . Open Shift Client Ċ import Ġno . sk at te et aten . aur ora . b oo ber . service . openshift . Open Shift Response Ċ import Ġno . sk at te et aten . aur ora . b oo ber . service . openshift . Open shift Command Ċ import Ġno . sk at te et aten . aur ora . b oo ber . service . openshift . Operation Type Ċ import Ġno . sk at te et aten . aur ora . b oo ber . utils . Open Shift TestData Builders . deployment Config Ċ import Ġno . sk at te et aten . aur ora . b oo ber . utils . Open Shift TestData Builders . image Stream Ċ import Ġno . sk at te et aten . aur ora . b oo ber . utils . Open Shift TestData Builders . image Stream Import Response Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠRe deploy Service Test Ġ{ ĊĊĠĠĠ Ġval Ġval ault Image Hash Ġ= Ġ" 1 2 3 " ĊĠĠĠ Ġval Ġempty JsonNode Ġ= ĠNull Node . getInstance () ĊĊĠĠĠ Ġval Ġimage Stream Ġ= Ġimage Stream () ĊĠĠĠ Ġval Ġdeployment Config Ġ= Ġdeployment Config () ĊĊĠĠĠ Ġval Ġopen Shift Client Ġ= Ġmock k < Open Shift Client >() ĊĊĠĠĠ Ġval Ġre deploy Service Ġ= ĊĠĠĠĠĠĠĠ ĠRe deploy Service ( open Shift Client ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġnot Ġrun Ġexplicit Ġdeploy Ġfor Ġdevelopment Ġtype `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( listOf ( deployment Config ), ĠTemplate Type . development ) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . message ). isEqualTo (" No Ġdeploy Ġmade Ġsince Ġtype = development , Ġdeploy Ġvia Ġoc Ġstart - build .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġthrow Ġerror Ġif Ġdc Ġis Ġnull `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġopen Shift Response () ĊĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġre deploy Service . trigger Re deploy ( listOf (), ĠTemplate Type . deploy ) ĊĠĠĠĠĠĠĠ Ġ}. is Failure (). all Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhas Message (" Missing ĠDeployment Config ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġgiven Ġnull ĠImage Stream Ġreturn Ġsuccess `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġopen Shift Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( listOf ( deployment Config ), ĠTemplate Type . deploy ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġwith Ġpaused Ġdeploy Ġwill Ġrun Ġmanual Ġdeploy `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġimage Stream Import Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġre deploy Service . trigger Re deploy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( deployment Config (" Image Change ", Ġ 0 ), Ġimage Stream ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTemplate Type . deploy ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . message ). isEqualTo (" No Ġnew Ġapplication Ġversion Ġfound . ĠConfig Ġchanges Ġdeployment Ġsucceeded .") ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġwith Ġnewly Ġcreated Ġimage stream Ġwill Ġnot Ġimport `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġimage Stream Import Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( deployment Config , Ġimage Stream (" docker Url ", ĠOperation Type . CREATE )), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTemplate Type . deploy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . message ). isEqualTo (" New Ġapplication Ġversion Ġfound .") ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġgiven Ġimage Ġis Ġalready Ġimported Ġreturn Ġsuccess `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġimage Stream Import Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( listOf ( deployment Config , Ġimage Stream ), ĠTemplate Type . deploy ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġgiven Ġimage Ġis Ġnot Ġimported Ġreturn Ġsuccess `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġimage Stream Import Response (" 2 3 4 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( listOf ( deployment Config , Ġimage Stream ), ĠTemplate Type . deploy ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġgiven Ġno Ġtype Ġin ĠDeployment Config Ġperform Ġdeployment Ġrequest Ġand Ġreturn Ġsuccess `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġdeployment Config Without Type Ġ= Ġdeployment Config ( null ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġopen Shift Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġre deploy Service . trigger Re deploy ( listOf ( deployment Config Without Type , Ġimage Stream ), ĠTemplate Type . deploy ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġwith Ġsame Ġimage Ġwill Ġrun Ġexplicit Ġdeploy `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen Shift Client . perform Open Shift Command ( any ()) ĊĠĠĠĠĠĠĠ Ġ} Ġreturns Ġopen Shift Response () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( deployment Config , Ġimage Stream , Ġimage Stream Import Response ( val ault Image Hash )), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTemplate Type . deploy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . message ). isEqualTo (" No Ġnew Ġapplication Ġversion Ġfound . ĠConfig Ġchanges Ġdeployment Ġsucceeded .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re deploy Ġwith Ġdifferent Ġimage Ġwill Ġnot Ġrun Ġexplicit Ġdeploy `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġre deploy Service . trigger Re deploy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( deployment Config , Ġimage Stream , Ġimage Stream Import Response (" hash ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTemplate Type . deploy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( response . success ). isTrue () ĊĠĠĠĠĠĠĠ ĠassertThat ( response . open Shift Responses . size ). isEqualTo ( 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( response . message ). isEqualTo (" New Ġapplication Ġversion Ġfound .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġopen Shift Response ( response Body : ĠJsonNode Ġ= Ġempty JsonNode ) Ġ= ĊĠĠĠĠĠĠĠ ĠOpen Shift Response ( Open shift Command ( Operation Type . CREATE , Ġ"", Ġempty JsonNode ), Ġresponse Body ) Ċ } Ċ