package Ġcom . github . le wis od . aws . dsl Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Thrown By Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . params . Parameterized Test Ċ import Ġorg . junit . jupiter . params . provider . Enum Source Ċ import Ġorg . sky sc ream er . json assert . JSON Assert Ċ Ċ internal Ġclass ĠPrincipal Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Build s Ġan ĠAWS Ġprincipal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠPrincipal Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . aws (" account - 1 ", Ġ" account - 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġbuilt Principal Ġ= Ġbuilder . build () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Principal Ġ= ĠPrincipal ( Principal Type . AWS , ĠlistOf (" account - 1 ", Ġ" account - 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( built Principal ). isEqualTo Comp aring Field By Field Re cursively ( expected Principal ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Build s Ġa ĠCan onical User Ġprincipal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠPrincipal Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . canonical User (" user ") ĊĠĠĠĠĠĠĠ Ġval Ġbuilt Principal Ġ= Ġbuilder . build () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Principal Ġ= ĠPrincipal ( Principal Type . CAN ON ICAL _ USER , ĠlistOf (" user ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( built Principal ). isEqualTo Comp aring Field By Field Re cursively ( expected Principal ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Build s Ġa ĠF ederated Ġprincipal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠPrincipal Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . fed erated (" user ") ĊĠĠĠĠĠĠĠ Ġval Ġbuilt Principal Ġ= Ġbuilder . build () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Principal Ġ= ĠPrincipal ( Principal Type . F ED ER ATED , ĠlistOf (" user ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( built Principal ). isEqualTo Comp aring Field By Field Re cursively ( expected Principal ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Build s Ġa ĠService Ġprincipal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠPrincipal Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . service (" service - 1 ", Ġ" service - 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġbuilt Principal Ġ= Ġbuilder . build () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Principal Ġ= ĠPrincipal ( Principal Type . SERVICE , ĠlistOf (" service - 1 ", Ġ" service - 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( built Principal ). isEqualTo Comp aring Field By Field Re cursively ( expected Principal ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Throws Ġan Ġexception Ġwhen Ġprincipal Ġnot Ġspecified `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPrincipal Builder (). build () ĊĠĠĠĠĠĠĠ Ġ}. isInstanceOf ( Invalid Principal Exception :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Throws Ġan Ġexception Ġwhen Ġmultiple Ġprinciples Ġspecified `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠPrincipal Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . service (" service ") ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . fed erated (" fed erated ") ĊĠĠĠĠĠĠĠ Ġ}. isInstanceOf ( Invalid Principal Exception :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Parameterized Test ĊĠĠĠ Ġ@ Enum Source ( Principal Type :: class ) ĊĠĠĠ Ġfun Ġ` Serial izes Ġsingle Ġvalues Ġto ĠJSON Ġcorrectly `( type : ĠPrincipal Type ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprincipal Ġ= ĠPrincipal ( type , ĠlistOf (" account ")) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Json Ġ= Ġ""" ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"${ type . text Value } ": Ġ" account " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Json Ġ= Ġprincipal . toJson () ĊĊĠĠĠĠĠĠĠ ĠJSON Assert . assertEquals ( expected Json , Ġactual Json , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Parameterized Test ĊĠĠĠ Ġ@ Enum Source ( Principal Type :: class ) ĊĠĠĠ Ġfun Ġ` Serial izes Ġlist Ġvalues Ġto ĠJSON Ġcorrectly `( type : ĠPrincipal Type ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprincipal Ġ= ĠPrincipal ( type , ĠlistOf (" account - 1 ", Ġ" account - 2 ")) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Json Ġ= Ġ""" ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"${ type . text Value } ": Ġ[" account - 1 ", Ġ" account - 2 "] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Json Ġ= Ġprincipal . toJson () ĊĊĠĠĠĠĠĠĠ ĠJSON Assert . assertEquals ( expected Json , Ġactual Json , Ġtrue ) ĊĠĠĠ Ġ} Ċ } Ċ