/******************************************************************************* Ċ Ġ* Ġ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 . controller . test Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġorg . eclipse . ket i . acs . commons . web . PARENT S _ ATTR _ NOT _ SUPPORTED _ MSG Ċ import Ġorg . eclipse . ket i . acs . rest . Base Subject Ċ import Ġorg . eclipse . ket i . acs . test utils . Test Active Profiles Resolver Ċ import Ġorg . eclipse . ket i . acs . test utils . TestUtils Ċ import Ġorg . eclipse . ket i . acs . test utils . mock Ac s RequestContext Ċ import Ġorg . eclipse . ket i . acs . test utils . mock SecurityContext Ċ import Ġorg . eclipse . ket i . acs . utils . Json Utils Ċ import Ġorg . eclipse . ket i . acs . zone . management . Zone Service Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . core . env . Configurable Environment Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . testng . Abstract Test NG Spring Context Tests Ċ import Ġorg . springframework . test . context . web . WebApp Configuration Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . status Ċ import Ġorg . springframework . web . context . Web ApplicationContext Ċ import Ġorg . testng . Assert Ċ import Ġorg . testng . Skip Exception Ċ import Ġorg . testng . annotations . BeforeClass Ċ import Ġorg . testng . annotations . Test Ċ Ċ private Ġval ĠOBJECT _ MAP PER Ġ= ĠObjectMapper () Ċ private Ġval ĠJSON _ UTILS Ġ= ĠJson Utils () Ċ private Ġval ĠTEST _ UTILS Ġ= ĠTestUtils () Ċ private Ġval ĠTEST _ ZONE Ġ= ĊĠĠĠ ĠTEST _ UTILS . create Test Zone (" Subject Mgmt Controller IT ") Ċ Ċ @ WebApp Configuration Ċ @ Context Configuration (" classpath : controller - tests - context . xml ") Ċ @ Active Profiles ( resolver Ġ= ĠTest Active Profiles Resolver :: class ) Ċ class ĠNon Hierarchical Subject s IT Ġ: ĠAbstract Test NG Spring Context Tests () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġzone Service : ĠZone Service ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġw ac : ĠWeb ApplicationContext ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconfigurable Environment : ĠConfigur able Environment ĊĊĠĠĠ Ġ@ BeforeClass ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġbefore Class () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( listOf (* this . configurable Environment . active Profiles ). contains (" graph ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠSkip Exception (" This Ġtest Ġonly Ġapplies Ġwhen ĠNOT Ġusing Ġthe Ġ\" graph \" Ġprofile ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġthis . zone Service . upsert Zone ( TEST _ ZONE ) ĊĠĠĠĠĠĠĠ Ġmock SecurityContext ( TEST _ ZONE ) ĊĠĠĠĠĠĠĠ Ġmock Ac s RequestContext () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Subject With Parents Fail When Not Using Graph () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsubject Ġ= ĠJSON _ UTILS . deserialize FromFile ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" controller - test / a - subject - with - parents . json ", ĠBase Subject :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( subject ) ĊĊĠĠĠĠĠĠĠ Ġval Ġput Context Ġ= ĠTEST _ UTILS . create W AC With Custom PUT RequestBuilder ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . w ac , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTEST _ ZONE . subdomain , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ SUBJECT _ BASE _ URL / d ave - with - parents " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġput Context . mock Mvc . perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġput Context . builder . contentType ( MediaType . APPLICATION _ JSON ). content ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠOBJECT _ MAP PER . writeValue AsString ( subject ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ). andExpect ( status (). isNot Implemented ). andReturn () ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . response . content AsString , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"{\" Error Details \":{\" errorCode \":\" FAILURE \",\" errorMessage \":\" $ PARENT S _ ATTR _ NOT _ SUPPORTED _ MSG \" }}" ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ