/* Ċ Ġ* ĠCopyright ĠOpen Search ĠContributors Ċ Ġ* ĠSPDX - License - Identifier : ĠApache - 2 . 0 Ċ Ġ*/ Ċ Ċ package Ġorg . opense arch . observ ability . model Ċ Ċ import Ġcom . fasterxml . jackson . core . Json ParseException Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert Throws Ċ import Ġorg . opense arch . commons . utils . re createObject Ċ import Ġorg . opense arch . observ ability . construct Sample Ob serv ability Object Doc Ċ import Ġorg . opense arch . observ ability . createObject FromJson String Ċ import Ġorg . opense arch . observ ability . get Json String Ċ Ċ internal Ġclass ĠOb serv ability Object Doc Tests Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsample Ob serv ability Object Doc Ġ= Ġconstruct Sample Ob serv ability Object Doc () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ob serv ability Object Doc Ġserialize Ġand Ġdeserialize Ġtransport Ġobject Ġshould Ġbe Ġequal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġre created Object Ġ= Ġrecreate Object ( sample Ob serv ability Object Doc ) Ġ{ ĠOb serv ability Object Doc ( it ) Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( sample Ob serv ability Object Doc , Ġre created Object ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ob serv ability Object Doc Ġserialize Ġand Ġdeserialize Ġusing Ġjson Ġobject Ġshould Ġbe Ġequal `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson String Ġ= Ġget Json String ( sample Ob serv ability Object Doc , ĠRest Tag . REST _ OUTPUT _ PARAMS ) ĊĠĠĠĠĠĠĠ Ġval Ġre created Object Ġ= Ġcreate Object FromJson String ( json String ) Ġ{ ĠOb serv ability Object Doc . parse ( it ) Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( sample Ob serv ability Object Doc , Ġre created Object ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ob serv ability Object Doc Ġshould Ġdeserialize Ġjson Ġobject Ġusing Ġparser `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson String Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"{\" objectId \":\" test - id \",\" last Updated Time Ms \": 1 6 3 8 4 8 2 2 0 8 7 9 0 ,\" created Time Ms \": 1 6 3 8 4 8 2 2 0 8 7 9 0 ,\" tenant \":\" test - tenant \",\" access \":[\" test - access \" ],\" timestamp \":{\" name \":\" test Ġobject \",\" index \":\" opense arch _ dashboards _ sample _ data _ logs \",\" type \":\" timestamp \",\" dsl _ type \":\" date \" }}" ĊĠĠĠĠĠĠĠ Ġval Ġre created Object Ġ= Ġcreate Object FromJson String ( json String ) Ġ{ ĠOb serv ability Object Doc . parse ( it ) Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( sample Ob serv ability Object Doc , Ġre created Object ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ob serv ability Object Doc Ġshould Ġthrow Ġexception Ġwhen Ġinvalid Ġjson Ġobject Ġis Ġpassed `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson String Ġ= Ġ" sample Ġmessage " ĊĠĠĠĠĠĠĠ ĠassertThrows < Json ParseException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Object FromJson String ( json String ) Ġ{ ĠOb serv ability Object Doc . parse ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ob serv ability Object Doc Ġshould Ġsafely Ġignore Ġextra Ġfield Ġin Ġjson Ġobject `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson String Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"{\" objectId \":\" test - id \",\" last Updated Time Ms \": 1 6 3 8 4 8 2 2 0 8 7 9 0 ,\" created Time Ms \": 1 6 3 8 4 8 2 2 0 8 7 9 0 ,\" tenant \":\" test - tenant \",\" access \":[\" test - access \" ],\" timestamp \":{\" name \":\" test Ġobject \",\" index \":\" opense arch _ dashboards _ sample _ data _ logs \",\" type \":\" timestamp \",\" dsl _ type \":\" date \" }, \" another \":\" field \" }" ĊĠĠĠĠĠĠĠ Ġval Ġre created Object Ġ= Ġcreate Object FromJson String ( json String ) Ġ{ ĠOb serv ability Object Doc . parse ( it ) Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( sample Ob serv ability Object Doc , Ġre created Object ) ĊĠĠĠ Ġ} Ċ } Ċ