/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 8 ĠNu ĠEcho ĠInc Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . n ue cho . mut agen . cli . models . configuration Ċ Ċ import Ġcom . genes ys lab . platform . application blocks . com . objects . Cfg Agent Group Ċ import Ġcom . genes ys lab . platform . application blocks . com . objects . Cfg Group Ċ import Ġcom . genes ys lab . platform . application blocks . com . objects . Cfg Switch Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . DEFAULT _ FOLDER _ DB ID Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . DEFAULT _ FOLDER _ REFERENCE Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . DEFAULT _ TEN ANT _ REFERENCE Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . mock Cfg Agent Group Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . mock Cfg Person Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . mock Cfg Switch Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . Configuration Object Mocks . mock Empty Cfg Group Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . reference . Person Reference Ċ import Ġcom . n ue cho . mut agen . cli . models . configuration . reference . reference Set Builder Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve DN Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Folder By Db id Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Objective Table Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Person Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Script Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Stat Table Ċ import Ġcom . n ue cho . mut agen . cli . services . Conf Service Extension Mocks . mock Retrieve Tenant Ċ import Ġcom . n ue cho . mut agen . cli . services . Service Mocks Ċ import Ġcom . n ue cho . mut agen . cli . services . Service Mocks . mock Conf Service Ċ import Ġio . mock k . every Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . hamcrest . Matchers . contains Ċ import Ġorg . hamcrest . Matchers . equalTo Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ private Ġconst Ġval ĠNAME Ġ= Ġ" name " Ċ private Ġval Ġagent Group Ġ= ĠAgent Group ( ĊĠĠĠ Ġagents Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠPerson Reference (" agent 1 ", ĠDEFAULT _ TEN ANT _ REFERENCE ), ĊĠĠĠĠĠĠĠ ĠPerson Reference (" agent 2 ", ĠDEFAULT _ TEN ANT _ REFERENCE ), ĊĠĠĠĠĠĠĠ ĠPerson Reference (" agent 3 ", ĠDEFAULT _ TEN ANT _ REFERENCE ) ĊĠĠĠ Ġ), ĊĠĠĠ Ġgroup Ġ= ĠGroup ( ĊĠĠĠĠĠĠĠ Ġtenant Ġ= ĠDEFAULT _ TEN ANT _ REFERENCE , ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġ" name ", ĊĠĠĠĠĠĠĠ Ġstate Ġ= Ġ" enabled " ĊĠĠĠ Ġ), ĊĠĠĠ Ġfolder Ġ= ĠDEFAULT _ FOLDER _ REFERENCE Ċ ) Ċ Ċ class ĠAgent Group Test Ġ: ĠConfiguration Object Test ( ĊĠĠĠ Ġconfiguration Object Ġ= Ġagent Group , ĊĠĠĠ Ġempty Configuration Object Ġ= ĠAgent Group ( tenant Ġ= ĠDEFAULT _ TEN ANT _ REFERENCE , Ġname Ġ= ĠNAME ), ĊĠĠĠ Ġmandatory Properties Ġ= Ġempty Set (), ĊĠĠĠ Ġimported Configuration Object Ġ= ĠAgent Group ( mock Cfg Agent Group ()) Ċ ) Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġ` get References () Ġshould Ġreturn Ġall Ġobject 's Ġreferences `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġreference Set Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add ( agent Group . agents ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add ( agent Group . group . get References ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add ( agent Group . folder ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. toSet () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( agent Group . get References (), ĠequalTo ( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġoverride Ġfun Ġ` object Ġwith Ġdifferent Ġun change able Ġproperties ' Ġvalues Ġshould Ġreturn Ġthe Ġright Ġun change able Ġproperties `() Ġ= ĊĠĠĠĠĠĠĠ Ġassert Un change able Properties ( mock Cfg Agent Group (), ĠF OLDER ) ĊĊĠĠĠ Ġval Ġservice Ġ= ĠService Mocks . mock Conf Service () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` create Cfg Object Ġshould Ġproperly Ġcreate ĠC fg Agent Group `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcfg Switch Ġ= Ġmock Cfg Switch (" switch ") ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . retrieve Object ( Cfg Switch :: class . java , Ġany ()) Ġ} Ġreturns Ġcfg Switch ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . retrieve Object ( Cfg Agent Group :: class . java , Ġany ()) Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġperson Db id Ġ= Ġ 1 0 2 ĊĠĠĠĠĠĠĠ Ġval Ġdn Db id Ġ= Ġ 1 0 3 ĊĠĠĠĠĠĠĠ Ġval Ġobjective Table Db id Ġ= Ġ 1 0 4 ĊĠĠĠĠĠĠĠ Ġval Ġstat Table Db id Ġ= Ġ 1 0 5 ĊĠĠĠĠĠĠĠ Ġval Ġscript 1 Db id Ġ= Ġ 1 0 6 ĊĠĠĠĠĠĠĠ Ġmock Retrieve Tenant ( service ) ĊĠĠĠĠĠĠĠ Ġmock Retrieve Person ( service , Ġperson Db id ) ĊĠĠĠĠĠĠĠ Ġmock Retrieve DN ( service , Ġcfg Switch , Ġdn Db id ) ĊĠĠĠĠĠĠĠ Ġmock Retrieve Objective Table ( service , Ġobjective Table Db id ) ĊĠĠĠĠĠĠĠ Ġmock Retrieve Stat Table ( service , Ġstat Table Db id ) ĊĠĠĠĠĠĠĠ Ġmock Retrieve Script ( service , Ġscript 1 Db id ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcfg Agent Group Ġ= Ġagent Group . create Cfg Object ( service ) ĊĊĠĠĠĠĠĠĠ Ġwith ( cfg Agent Group ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( agent DB IDs , Ġcontains ( person Db id , Ġperson Db id , Ġperson Db id )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( group Info , ĠequalTo ( agent Group . group . to Updated Cfg Group ( service , ĠC fg Group ( service , Ġthis )))) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( folder Id , ĠequalTo ( DEFAULT _ FOLDER _ DB ID )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġmock Cfg Agent Group (): ĠC fg Agent Group Ġ{ ĊĠĠĠ Ġval Ġservice Ġ= Ġmock Conf Service () ĊĠĠĠ Ġmock Retrieve Folder By Db id ( service ) ĊĊĠĠĠ Ġval Ġgroup Info Mock Ġ= Ġmock Empty Cfg Group ( agent Group . group . name ) ĊĠĠĠ Ġval Ġagents Mock Ġ= Ġagent Group . agents ?. map Ġ{ Ġref Ġ-> Ġmock Cfg Person ( ref . primaryKey ) Ġ} ĊĊĠĠĠ Ġreturn Ġmock Cfg Agent Group ( agent Group . group . name ). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġconfiguration Service Ġ} Ġreturns Ġservice ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġagents Ġ} Ġreturns Ġagents Mock ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfolder Id Ġ} Ġreturns ĠDEFAULT _ FOLDER _ DB ID ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġgroup Info Ġ} Ġreturns Ġgroup Info Mock ĊĠĠĠ Ġ} Ċ } Ċ