package Ġorg . s ange et . k graphql . merge Ċ Ċ import Ġcom . fasterxml . jackson . databind . JsonNode Ċ import Ġcom . fasterxml . jackson . databind . node . JsonNode Factory Ċ import Ġorg . s ange et . k graphql . expect Ċ import Ġorg . s ange et . k graphql . schema . execution . merge Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠObject Node Merge Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġjson Node Factory Ġ= ĠJsonNode Factory . instance ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` merge Ġshould Ġadd Ġproperty `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexisting Ġ= Ġjson Node Factory . object Node (). put (" param 1 ", Ġ" value 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġupdate Ġ= Ġjson Node Factory . object Node (). put (" param 2 ", Ġ" value 2 ") ĊĊĠĠĠĠĠĠĠ Ġexisting . merge ( update ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected : ĠJsonNode ? Ġ= Ġjson Node Factory . text Node (" value 2 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( existing . get (" param 2 "), ĠequalTo ( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` merge Ġshould Ġadd Ġnested Ġproperty `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexisting Ġ= Ġjson Node Factory . object Node (). put (" param 1 ", Ġ" value 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġupdate Ġ= Ġjson Node Factory . object Node () ĊĠĠĠĠĠĠĠ Ġupdate . put Object (" sub "). put (" param 2 ", Ġ" value 2 ") ĊĊĠĠĠĠĠĠĠ Ġexisting . merge ( update ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected : ĠJsonNode ? Ġ= Ġjson Node Factory . object Node (). put (" param 2 ", Ġ" value 2 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( existing . get (" sub "), ĠequalTo ( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` merge Ġshould Ġnot Ġchange Ġsimple Ġnode `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexisting Ġ= Ġjson Node Factory . object Node (). put (" param ", Ġ" value 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġupdate Ġ= Ġjson Node Factory . object Node (). put (" param ", Ġ" value 2 ") ĊĊĠĠĠĠĠĠĠ Ġexpect < IllegalStateException >(" different Ġsimple Ġnodes ") Ġ{ Ġexisting . merge ( update ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected : ĠJsonNode ? Ġ= Ġjson Node Factory . text Node (" value 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( existing . get (" param "), ĠequalTo ( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` merge Ġshould Ġnot Ġmerge Ġsimple Ġnode Ġwith Ġobject Ġnode `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexisting Ġ= Ġjson Node Factory . object Node (). put (" param ", Ġ" value 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġupdate Ġ= Ġjson Node Factory . object Node () ĊĠĠĠĠĠĠĠ Ġupdate . put Object (" param ") ĊĊĠĠĠĠĠĠĠ Ġexpect < IllegalStateException >(" merge Ġobject Ġwith Ġsimple Ġnode ") Ġ{ Ġexisting . merge ( update ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected : ĠJsonNode ? Ġ= Ġjson Node Factory . text Node (" value 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( existing . get (" param "), ĠequalTo ( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` merge Ġshould Ġnot Ġmerge Ġobject Ġnode Ġwith Ġsimple Ġnode `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexisting Ġ= Ġjson Node Factory . object Node () ĊĠĠĠĠĠĠĠ Ġval Ġexisting Obj : ĠJsonNode ? Ġ= Ġexisting . put Object (" param "). put (" other ", Ġ" value 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġupdate Ġ= Ġjson Node Factory . object Node (). put (" param ", Ġ" value 2 ") ĊĊĠĠĠĠĠĠĠ Ġexpect < IllegalStateException >(" merge Ġsimple Ġnode Ġwith Ġobject Ġnode ") Ġ{ Ġexisting . merge ( update ) Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( existing . get (" param "), ĠequalTo ( existing Obj )) ĊĠĠĠ Ġ} Ċ } Ċ