/** Ċ Ġ* Ċ Ġ* ĠCopyright Ġ 2 0 1 6 - 2 0 1 7 , ĠOptim iz ely Ġand Ġcontributors Ċ Ġ* Ċ Ġ* Ġ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 Ċ Ġ* Ċ Ġ* Ġhttp :// 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 . optim iz ely . ab . event . internal . serializer Ċ Ċ import Ġcom . google . gson . Field Naming Policy Ċ import Ġcom . google . gson . Gson Ċ Ċ import Ġcom . google . gson . Gson Builder Ċ import Ġcom . optim iz ely . ab . event . internal . payload . Event Batch Ċ Ċ import Ġorg . junit . Test Ċ Ċ import Ġjava . io . IOException Ċ Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Conversion Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Conversion Json Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Conversion With SessionId Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Conversion With SessionId Json Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Imp ression Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Imp ression Json Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Imp ression With SessionId Ċ import Ġcom . optim iz ely . ab . event . internal . serializer . Serializer TestUtils . generate Imp ression With SessionId Json Ċ Ċ import Ġorg . hamcrest . Core Matchers .` is ` Ċ import Ġorg . junit . Assert . assertThat Ċ Ċ class ĠGson Serializer Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġserializer Ġ= ĠGson Serializer () ĊĠĠĠ Ġprivate Ġval Ġgson Ġ= ĠGson Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. setField Naming Policy ( Field Naming Policy . LOWER _ CASE _ WITH _ UNDER SCO RES ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. create () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( IOException :: class ) ĊĠĠĠ Ġfun Ġserialize Imp ression () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġimp ression Ġ= Ġgenerate Imp ression () ĊĠĠĠĠĠĠĠ Ġ// Ġcan 't Ġcompare ĠJSON Ġstrings Ġsince Ġorders Ġcould Ġvary Ġso Ġcompare Ġobjects Ġinstead ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgson . fromJson < Event Batch >( serializer . serialize ( imp ression ), ĠEvent Batch :: class . java !! ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġgson . fromJson < Event Batch >( generate Imp ression Json (), ĠEvent Batch :: class . java !! ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual , Ġ` is `( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( IOException :: class ) ĊĠĠĠ Ġfun Ġserialize Imp ression With SessionId () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġimp ression Ġ= Ġgenerate Imp ression With SessionId () ĊĠĠĠĠĠĠĠ Ġ// Ġcan 't Ġcompare ĠJSON Ġstrings Ġsince Ġorders Ġcould Ġvary Ġso Ġcompare Ġobjects Ġinstead ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgson . fromJson < Event Batch >( serializer . serialize ( imp ression ), ĠEvent Batch :: class . java !! ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġgson . fromJson < Event Batch >( generate Imp ression With SessionId Json (), ĠEvent Batch :: class . java !! ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual , Ġ` is `( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( IOException :: class ) ĊĠĠĠ Ġfun Ġserialize Conversion () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconversion Ġ= Ġgenerate Conversion () ĊĠĠĠĠĠĠĠ Ġ// Ġcan 't Ġcompare ĠJSON Ġstrings Ġsince Ġorders Ġcould Ġvary Ġso Ġcompare Ġobjects Ġinstead ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgson . fromJson < Event Batch >( serializer . serialize ( conversion ), ĠEvent Batch :: class . java !! ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġgson . fromJson < Event Batch >( generate Conversion Json (), ĠEvent Batch :: class . java !! ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual , Ġ` is `( expected )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġserialize Conversion With SessionId () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconversion Ġ= Ġgenerate Conversion With SessionId () ĊĠĠĠĠĠĠĠ Ġ// Ġcan 't Ġcompare ĠJSON Ġstrings Ġsince Ġorders Ġcould Ġvary Ġso Ġcompare Ġobjects Ġinstead ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgson . fromJson < Event Batch >( serializer . serialize ( conversion ), ĠEvent Batch :: class . java !! ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġgson . fromJson < Event Batch >( generate Conversion With SessionId Json (), ĠEvent Batch :: class . java !! ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual , Ġ` is `( expected )) ĊĠĠĠ Ġ} Ċ } Ċ