/******************************************************************************* Ċ Ġ* ĠCopyright Ġ 2 0 1 8 ĠGeneral ĠE lectric ĠCompany Ċ Ġ* Ċ Ġ* Ġ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 . Ċ Ġ* Ċ Ġ* ĠSPDX - License - Identifier : ĠApache - 2 . 0 Ċ Ġ************************************************************************* ******/ Ċ Ċ package Ġorg . eclipse . ket i . acs . zone . management Ċ Ċ import Ġorg . eclipse . ket i . acs . config . InMemory DataSource Config Ċ import Ġorg . eclipse . ket i . acs . encryption . Encrypt or Ċ import Ġorg . eclipse . ket i . acs . rest . Attribute Adapter Connection Ċ import Ġorg . eclipse . ket i . acs . rest . Attribute Connector Ċ import Ġorg . eclipse . ket i . acs . test utils . Test Active Profiles Resolver Ċ import Ġorg . eclipse . ket i . acs . zone . management . dao . Zone Entity Ċ import Ġorg . eclipse . ket i . acs . zone . management . dao . Zone Repository Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . autoconfigure . Enable Auto Configuration Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . Test Property Source Ċ import Ġorg . springframework . test . context . testng . Abstract Transactional Test NG Spring Context Tests Ċ import Ġorg . testng . Assert Ċ import Ġorg . testng . annotations . Test Ċ Ċ @ Enable Auto Configuration Ċ @ Context Configuration ( classes Ġ= Ġ[( InMemory DataSource Config :: class ), Ġ( Encrypt or :: class )]) Ċ @ Active Profiles ( resolver Ġ= ĠTest Active Profiles Resolver :: class ) Ċ @ Test Property Source ("/ application . properties ") Ċ class ĠZone Repository Test Ġ: ĠAbstract Transactional Test NG Spring Context Tests () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġzone Repository : ĠZone Repository ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Add Connector () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Zone With Connector And Assert () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Update Connector () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġzone Ġ= Ġcreate Zone With Connector And Assert () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Connector Ġ= ĠAttribute Connector () ĊĠĠĠĠĠĠĠ Ġexpected Connector . isActive Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġexpected Connector . adapters Ġ= Ġset Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAttribute Adapter Connection ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" http :// some - adapter . com ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" http :// some - u aa . com ", Ġ" some - client ", Ġ" some - secret " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġzone . resource Attribute Connector Ġ= Ġexpected Connector ĊĊĠĠĠĠĠĠĠ Ġthis . zone Repository . save ( zone ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠAssert Ġthat Ġzone Ġconnector s Ġand Ġadapters Ġare Ġupdated ĊĠĠĠĠĠĠĠ Ġval Ġactual Connector Ġ= Ġthis . zone Repository . get ByName ( zone . name !! ) !! ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. resource Attribute Connector ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( actual Connector , Ġexpected Connector ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( actual Connector !!. adapters , Ġexpected Connector . adapters ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Delete Connector () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġzone Ġ= Ġcreate Zone With Connector And Assert () ĊĊĠĠĠĠĠĠĠ Ġzone . resource Attribute Connector Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġthis . zone Repository . save ( zone ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNull ( this . zone Repository . get ByName ( zone . name !! ) !!. resource Attribute Connector ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġprivate Ġfun Ġcreate Zone With Connector And Assert (): ĠZone Entity Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Connector Ġ= ĠAttribute Connector () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Adapters Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Of ( Attribute Adapter Connection (" http :// my - adapter . com ", Ġ" http :// my - u aa ", Ġ" my - client ", Ġ" my - secret ")) ĊĠĠĠĠĠĠĠ Ġexpected Connector . adapters Ġ= Ġexpected Adapters ĊĠĠĠĠĠĠĠ Ġexpected Connector . max Cached Interval Minutes Ġ= Ġ 2 4 ĊĠĠĠĠĠĠĠ Ġval Ġzone Ġ= ĠZone Entity () ĊĠĠĠĠĠĠĠ Ġzone . name Ġ= Ġ" az one " ĊĠĠĠĠĠĠĠ Ġzone . subdomain Ġ= Ġ" as ub domain " ĊĠĠĠĠĠĠĠ Ġzone . description Ġ= Ġ" ade scription " ĊĠĠĠĠĠĠĠ Ġzone . resource Attribute Connector Ġ= Ġexpected Connector ĊĠĠĠĠĠĠĠ Ġthis . zone Repository . save ( zone ) ĊĠĠĠĠĠĠĠ Ġval Ġac ut al Zone Ġ= Ġthis . zone Repository . get ByName (" az one ") ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( ac ut al Zone !!. subject Attribute Connector , Ġnull ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( ac ut al Zone . resource Attribute Connector , Ġexpected Connector ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( ac ut al Zone . resource Attribute Connector !!. adapters , Ġexpected Adapters ) ĊĠĠĠĠĠĠĠ Ġreturn Ġzone ĊĠĠĠ Ġ} Ċ } Ċ