package Ġio . tol gee . api . v 2 . controllers . v 2 Projects Controller Ċ Ċ import Ġio . tol gee . controllers . Project Auth Controller Test Ċ import Ġio . tol gee . development . testData Builder . data . Project Trans f erring TestData Ċ import Ġio . tol gee . fixtures . and Assert That Json Ċ import Ġio . tol gee . fixtures . and Is Forbidden Ċ import Ġio . tol gee . fixtures . and Is Ok Ċ import Ġio . tol gee . fixtures . and Pretty Print Ċ import Ġio . tol gee . fixtures . node Ċ import Ġio . tol gee . model . Permission Ċ import Ġio . tol gee . testing . annotations . Project JWT Auth TestMethod Ċ import Ġio . tol gee . testing . assertions . Assertions . assertThat Ċ import Ġorg . springframework . boot . test . autoconfigure . web . servlet . Auto Configure MockMvc Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . testng . annotations . Test Ċ Ċ @ SpringBootTest Ċ @ Auto Configure MockMvc Ċ class ĠV 2 Projects Controller Trans f erring Test Ġ: ĠProject Auth Controller Test ("/ v 2 / projects /") Ġ{ ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` trans fers Ġfrom Ġuser Ġto Ġuser `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - user /${ testData . user 2 . id }", Ġnull ). and Is Ok ĊĠĠĠ ĠassertThat ( project Service . get ( project . id ). orElse ( null ) !!. user Owner !!. id ) ĊĠĠĠĠĠ Ġ. isEqualTo ( testData . user 2 . id ) ĊĠĠĠ ĠassertThat ( permission Service . getProject Permission Type ( project . id , ĠtestData . user 2 . id )) ĊĠĠĠĠĠ Ġ. isEqualTo ( Permission . Project Permission Type . MANAGE ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` trans fers Ġfrom Ġorganization Ġto Ġuser `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . organization Owned Project Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - user /${ testData . user 2 . id }", Ġnull ). and Is Ok ĊĠĠĠ ĠassertThat ( project Service . get ( project . id ). orElse ( null ) !!. user Owner !!. id ) ĊĠĠĠĠĠ Ġ. isEqualTo ( testData . user 2 . id ) ĊĠĠĠ ĠassertThat ( permission Service . getProject Permission Type ( project . id , ĠtestData . user 2 . id )) ĊĠĠĠĠĠ Ġ. isEqualTo ( Permission . Project Permission Type . MANAGE ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` trans fers Ġfrom Ġuser Ġto Ġorganization `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - organization /${ testData . organization . id }", Ġnull ). and Is Ok ĊĠĠĠ ĠassertThat ( project Service . get ( project . id ). orElse ( null ) !!. organization Owner !!. id ) ĊĠĠĠĠĠ Ġ. isEqualTo ( testData . organization . id ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` does n 't Ġtransfers Ġfrom Ġuser Ġto Ġorganization Ġwhen Ġnot Ġowner `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - organization /${ testData . not Owned Organization . id }", Ġnull ) ĊĠĠĠĠĠ Ġ. and Is Forbidden ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` does n 't Ġtransfer Ġfrom Ġuser Ġto Ġuser Ġwhen Ġnot Ġin Ġproject `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user 2 ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . organization Owned Project Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - user /${ testData . user 3 . id }", Ġnull ) ĊĠĠĠĠĠ Ġ. and Is Forbidden ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` does n 't Ġtransfer Ġto Ġuser Ġwhen Ġnot Ġpermitted `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( ĊĠĠĠĠĠ ĠtestData . root . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġdata . projects [ 0 ]. data . permissions [ 0 ]. self Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġtype Ġ= ĠPermission . Project Permission Type . VIEW ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - user /${ testData . user 2 . id }", Ġnull ). and Is Forbidden ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` does n 't Ġtransfer Ġto Ġorganization Ġwhen Ġnot Ġpermitted `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( ĊĠĠĠĠĠ ĠtestData . root . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġdata . projects [ 0 ]. data . permissions [ 0 ]. self Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġtype Ġ= ĠPermission . Project Permission Type . VIEW ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Put ("/ transfer - to - organization /${ testData . organization . id }", Ġnull ). and Is Forbidden ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Project JWT Auth TestMethod ĊĠ Ġfun Ġ` provides Ġtransfer Ġoptions `() Ġ{ ĊĠĠĠ Ġval ĠtestData Ġ= ĠProject Trans f erring TestData () ĊĠĠĠ Ġtest DataService . save TestData ( testData . root ) ĊĠĠĠ Ġuser Account Ġ= ĠtestData . user ĊĠĠĠ Ġproject Supplier Ġ= Ġ{ ĠtestData . project Builder . self Ġ} ĊĠĠĠ Ġperform Project Auth Get ("/ transfer - options "). and Pretty Print . and Is Ok . and Assert That Json Ġ{ ĊĠĠĠĠĠ Ġnode ("_ embedded . transfer Options ") Ġ{ ĊĠĠĠĠĠĠĠ ĠisArray ĊĠĠĠĠĠĠĠ Ġnode ("[ 0 ]. name "). isEqualTo (" J ose f ĠK aj et an ") ĊĠĠĠĠĠĠĠ Ġnode ("[ 1 ]. name "). isEqualTo (" Owned Ġorganization ") ĊĠĠĠĠĠĠĠ Ġnode ("[ 2 ]. name "). isEqualTo (" Pe tr ĠV ob ta h lo ") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ