/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠExp edia , Ġ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 Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttps :// 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 . exp edi ag roup . graphql . fed eration . validation . integration Ċ Ċ import Ġcom . exp edi ag roup . graphql . TopLevel Object Ċ import Ġcom . exp edi ag roup . graphql . fed eration . data . integration . requires . failure ._ 3 . Requires On Local Type Query Ċ import Ġcom . exp edi ag roup . graphql . fed eration . exception . Invalid F ederated Schema Ċ import Ġcom . exp edi ag roup . graphql . fed eration . to F ederated Schema Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert DoesNot Throw Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assert Fails With Ċ import Ġkotlin . test . assertNotNull Ċ Ċ class ĠF ederated Requires Directive IT Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ver ifies Ġ@ requires Ġdirective `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert DoesNot Throw Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġschema Ġ= Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . success ._ 1 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġvalidated Type Ġ= Ġschema . get ObjectType (" Simple Requires ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( validated Type . get Directive (" key ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweight Field Ġ= Ġvalidated Type . getField Definition (" weight ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( weight Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( weight Field . get Directive (" external ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrequires Field Ġ= Ġvalidated Type . getField Definition (" shipping Cost ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field . get Directive (" requires ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ`@ requires Ġdirective Ġcannot Ġreference Ġlocal Ġfields `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexception Ġ= Ġassert Fails With < Invalid F ederated Schema > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . failure ._ 1 ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals (" Invalid Ġf ederated Ġschema :\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ- Ġ@ requires ( fields Ġ= Ġweight ) Ġdirective Ġon ĠRequires Local Field . shipping Cost Ġspecifies Ġinvalid Ġfield Ġset Ġ- Ġextended Ġtype Ġincorrectly Ġreferences Ġlocal Ġfield = weight ", Ġexception . message ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ`@ requires Ġdirective Ġshould Ġreference Ġvalid Ġfields `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexception Ġ= Ġassert Fails With < Invalid F ederated Schema > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . failure ._ 2 ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals (" Invalid Ġf ederated Ġschema :\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ- Ġ@ requires ( fields Ġ= Ġzip Code ) Ġdirective Ġon ĠRequires Non Ex istent Field . shipping Cost Ġspecifies Ġinvalid Ġfield Ġset Ġ- Ġfield Ġset Ġspecifies Ġfields Ġthat Ġdo Ġnot Ġexist ", Ġexception . message ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ`@ requires Ġdirective Ġcannot Ġbe Ġapplied Ġon Ġlocal Ġtype `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexception Ġ= Ġassert Fails With < Invalid F ederated Schema > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġto F ederated Schema ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfig Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . failure ._ 3 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġqueries Ġ= ĠlistOf ( TopLevel Object ( Requires On Local Type Query ()))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals (" Invalid Ġf ederated Ġschema :\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ- Ġbase ĠRequires On Local Type Ġtype Ġhas Ġfields Ġmarked Ġwith Ġ@ requires Ġdirective , Ġvalidated Field = shipping Cost ", Ġexception . message ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ver ifies Ġ@ requires Ġdirective Ġon Ġlist Ġdoes Ġnot Ġthrow `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert DoesNot Throw Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġschema Ġ= Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . success ._ 2 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġvalidated Type Ġ= Ġschema . get ObjectType (" User ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( validated Type . get Directive (" key ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexternal Field Ġ= Ġvalidated Type . getField Definition (" email ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field . get Directive (" external ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrequires Field Ġ= Ġvalidated Type . getField Definition (" reviews ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field . get Directive (" requires ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ver ifies Ġ@ requires Ġdirective Ġon Ġinterface Ġdoes Ġnot Ġthrow `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert DoesNot Throw Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġschema Ġ= Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . success ._ 3 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġvalidated Type Ġ= Ġschema . get ObjectType (" User ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( validated Type . get Directive (" key ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexternal Field Ġ= Ġvalidated Type . getField Definition (" email ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field . get Directive (" external ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrequires Field Ġ= Ġvalidated Type . getField Definition (" reviews ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field . get Directive (" requires ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ver ifies Ġ@ requires Ġdirective Ġon Ġunion Ġdoes Ġnot Ġthrow `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert DoesNot Throw Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġschema Ġ= Ġto F ederated Schema ( config Ġ= Ġf ederated Test Config (" com . exp edi ag roup . graphql . fed eration . data . integration . requires . success ._ 4 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġvalidated Type Ġ= Ġschema . get ObjectType (" User ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( validated Type . get Directive (" key ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexternal Field Ġ= Ġvalidated Type . getField Definition (" email ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( external Field . get Directive (" external ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrequires Field Ġ= Ġvalidated Type . getField Definition (" reviews ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( requires Field . get Directive (" requires ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ