/* Ċ Ġ* ĠCopyright ĠÂ© Ġ 2 0 2 0 ĠN HS X . ĠAll Ġrights Ġreserved . Ċ Ġ*/ Ċ Ċ package Ġuk . n hs . n hs x . sonar . android . app . status Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . joda . time . DateTime Ċ import Ġorg . joda . time . DateTime Zone . UTC Ċ import Ġorg . junit . Test Ċ import Ġuk . n hs . n hs x . sonar . android . app . util . non Empty Set Of Ċ Ċ class ĠUser State Serialization Test Ġ{ ĊĊĠĠĠ Ġval Ġserialize Ġ= ĠUser State Serialization :: serialize ĊĠĠĠ Ġval Ġdeserialize Ġ= ĠUser State Serialization :: deserialize ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` serialize Ġdefault Ġstate `() Ġ{ ĊĊĠĠĠĠĠĠĠ ĠassertThat ( serialize ( Default State )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (""" {" type ":" Default State "} """) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` serialize Ġrecovery Ġstate `() Ġ{ ĊĊĠĠĠĠĠĠĠ ĠassertThat ( serialize ( Recovery State )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (""" {" type ":" Recovery State "} """) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` serialize Ġam ber Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 2 L , ĠUTC ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( serialize ( Am ber State ( until ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (""" {" type ":" Am ber State "," until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 } """) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` serialize Ġred Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 3 L , ĠUTC ) ĊĠĠĠĠĠĠĠ Ġval Ġsy mptoms Ġ= Ġnon Empty Set Of ( Sy mptom . CO UGH , ĠSy mptom . TEMP ER ATURE ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( serialize ( Red State ( until , Ġsy mptoms ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (""" {" type ":" Red State "," sy mptoms ":[" CO UGH "," TEMP ER ATURE "]," until ": 1 5 8 7 2 4 1 3 0 2 2 6 3 } """) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` serialize Ġcheck in Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 3 L , ĠUTC ) ĊĠĠĠĠĠĠĠ Ġval Ġsy mptoms Ġ= Ġnon Empty Set Of ( Sy mptom . TEMP ER ATURE ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( serialize ( Check in State ( until , Ġsy mptoms ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (""" {" type ":" Check in State "," sy mptoms ":[" TEMP ER ATURE "]," until ": 1 5 8 7 2 4 1 3 0 2 2 6 3 } """) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġdefault Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" type ":" Default State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Default State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġdefault Ġstate Ġ- Ġwith Ġlegacy Ġuntil Ġtimestamp `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 1 ," type ":" Default State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Default State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġrecovery Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" type ":" Recovery State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Recovery State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġrecovery Ġstate Ġ- Ġwith Ġlegacy Ġuntil Ġtimestamp `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," type ":" Recovery State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Recovery State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġem ber ( ty po ) Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 2 L , ĠUTC ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," type ":" Em ber State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Am ber State ( until )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġam ber Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 2 L , ĠUTC ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," type ":" Am ber State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Am ber State ( until )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġred Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 2 L , ĠUTC ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," sy mptoms ":[" CO UGH "]," type ":" Red State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Red State ( until , Ġnon Empty Set Of ( Sy mptom . CO UGH ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġcheck in Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuntil Ġ= ĠDateTime ( 1 5 8 7 2 4 1 3 0 2 2 6 2 L , ĠUTC ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," sy mptoms ":[" CO UGH "]," type ":" Check in State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Check in State ( until , Ġnon Empty Set Of ( Sy mptom . CO UGH ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` deserialize Ġinvalid Ġred Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( deserialize (""" {" until ": 1 5 8 7 2 4 1 3 0 2 2 6 2 ," sy mptoms ":[ ]," type ":" Red State "} "" ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isNull () ĊĠĠĠ Ġ} Ċ } Ċ