package Ġorg . ny pl . simpl ified . tests . bookmarks Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġcom . fasterxml . jackson . databind . node . Object Node Ċ import Ġorg . joda . time . DateTime Utils Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Assertions . assert Throws Ċ import Ġorg . junit . jupiter . api . Assertions . assertTrue Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . ny pl . simpl ified . books . api . Book Location Ċ import Ġorg . ny pl . simpl ified . books . api . Bookmark Kind Ċ import Ġorg . ny pl . simpl ified . json . core . JSON ParseException Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation Body Node Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation First Node Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation Response Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation Selector Node Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotation Target Node Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotations Ċ import Ġorg . ny pl . simpl ified . reader . bookmarks . api . Bookmark Annotations JSON Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġjava . io . FileNotFoundException Ċ import Ġjava . io . InputStream Ċ Ċ class ĠBook mark Annotations JSON Test Ġ{ ĊĊĠ Ġprivate Ġval Ġlogger Ġ= ĊĠĠĠ ĠLoggerFactory . getLogger ( Bookmark Annotations JSON Test :: class . java ) ĊĊĠ Ġprivate Ġval ĠobjectMapper : ĠObjectMapper Ġ= ĠObjectMapper () ĊĊĠ Ġprivate Ġval Ġtarget Value 0 Ġ= ĊĠĠĠ Ġ" {\ n Ġ Ġ\" @ type \": Ġ\" Locator Href Progress ion \",\ n Ġ Ġ\" href \": Ġ\" / 0 . html \",\ n Ġ Ġ\" progress Within Chapter \": Ġ 0 . 5 \ n }\ n " ĊĠ Ġprivate Ġval Ġtarget Value 1 Ġ= ĊĠĠĠ Ġ" {\ n Ġ Ġ\" @ type \": Ġ\" Locator Href Progress ion \",\ n Ġ Ġ\" href \": Ġ\" / 1 . html \",\ n Ġ Ġ\" progress Within Chapter \": Ġ 0 . 5 \ n }\ n " ĊĠ Ġprivate Ġval Ġtarget Value 2 Ġ= ĊĠĠĠ Ġ" {\ n Ġ Ġ\" @ type \": Ġ\" Locator Href Progress ion \",\ n Ġ Ġ\" href \": Ġ\" / 2 . html \",\ n Ġ Ġ\" progress Within Chapter \": Ġ 0 . 5 \ n }\ n " ĊĊĠ Ġprivate Ġval Ġbookmark Body 0 Ġ= ĊĠĠĠ ĠBook mark Annotation Body Node ( ĊĠĠĠĠĠ Ġtimestamp Ġ= Ġ" 2 0 1 9 - 0 1 - 2 5 T 2 0 : 0 0 : 3 7 + 0 0 0 0 ", ĊĠĠĠĠĠ Ġdevice Ġ= Ġ" cca 8 0 4 1 6 - 3 1 6 8 - 4 e 5 8 - b 6 2 1 - 7 9 6 4 b 9 2 6 5 ac 9 ", ĊĠĠĠĠĠ Ġchapter Title Ġ= Ġ" A ĠTitle ", ĊĠĠĠĠĠ Ġbook Progress Ġ= Ġ 5 0 . 0 f ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark Body 1 Ġ= ĊĠĠĠ ĠBook mark Annotation Body Node ( ĊĠĠĠĠĠ Ġtimestamp Ġ= Ġ" 2 0 1 9 - 0 1 - 2 5 T 2 0 : 0 0 : 3 7 + 0 0 0 0 ", ĊĠĠĠĠĠ Ġdevice Ġ= Ġ" cca 8 0 4 1 6 - 3 1 6 8 - 4 e 5 8 - b 6 2 1 - 7 9 6 4 b 9 2 6 5 ac 9 ", ĊĠĠĠĠĠ Ġchapter Title Ġ= Ġ" A ĠTitle ", ĊĠĠĠĠĠ Ġbook Progress Ġ= Ġ 5 0 . 0 f ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark Body 2 Ġ= ĊĠĠĠ ĠBook mark Annotation Body Node ( ĊĠĠĠĠĠ Ġtimestamp Ġ= Ġ" 2 0 1 9 - 0 1 - 2 5 T 2 0 : 0 0 : 3 7 + 0 0 0 0 ", ĊĠĠĠĠĠ Ġdevice Ġ= Ġ" cca 8 0 4 1 6 - 3 1 6 8 - 4 e 5 8 - b 6 2 1 - 7 9 6 4 b 9 2 6 5 ac 9 ", ĊĠĠĠĠĠ Ġchapter Title Ġ= Ġ" A ĠTitle ", ĊĠĠĠĠĠ Ġbook Progress Ġ= Ġ 5 0 . 0 f ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark Body Bad Date Ġ= ĊĠĠĠ ĠBook mark Annotation Body Node ( ĊĠĠĠĠĠ Ġtimestamp Ġ= Ġ" 2 0 1 9 - 0 1 - 2 5 T 2 0 : 0 0 : 3 7 Z ", ĊĠĠĠĠĠ Ġdevice Ġ= Ġ" cca 8 0 4 1 6 - 3 1 6 8 - 4 e 5 8 - b 6 2 1 - 7 9 6 4 b 9 2 6 5 ac 9 ", ĊĠĠĠĠĠ Ġchapter Title Ġ= Ġ" A ĠTitle ", ĊĠĠĠĠĠ Ġbook Progress Ġ= Ġ 5 0 . 0 f ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark 0 Ġ= ĊĠĠĠ ĠBook mark Annotation ( ĊĠĠĠĠĠ Ġcontext Ġ= Ġ" http :// www . w 3 . org / ns / anno . json ld ", ĊĠĠĠĠĠ Ġbody Ġ= Ġthis . bookmark Body 0 , ĊĠĠĠĠĠ Ġid Ġ= Ġ" x ", ĊĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠ Ġmotivation Ġ= Ġ" http :// www . w 3 . org / ns / oa # bookmark ing ", ĊĠĠĠĠĠ Ġtarget Ġ= ĠBook mark Annotation Target Node ( ĊĠĠĠĠĠĠĠ Ġ" z 0 ", ĊĠĠĠĠĠĠĠ ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 0 ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark 1 Ġ= ĊĠĠĠ ĠBook mark Annotation ( ĊĠĠĠĠĠ Ġcontext Ġ= Ġ" http :// www . w 3 . org / ns / anno . json ld ", ĊĠĠĠĠĠ Ġbody Ġ= Ġthis . bookmark Body 1 , ĊĠĠĠĠĠ Ġid Ġ= Ġ" x ", ĊĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠ Ġmotivation Ġ= Ġ" http :// www . w 3 . org / ns / oa # bookmark ing ", ĊĠĠĠĠĠ Ġtarget Ġ= ĠBook mark Annotation Target Node ( ĊĠĠĠĠĠĠĠ Ġ" z 1 ", ĊĠĠĠĠĠĠĠ ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 1 ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark 2 Ġ= ĊĠĠĠ ĠBook mark Annotation ( ĊĠĠĠĠĠ Ġcontext Ġ= Ġ" http :// www . w 3 . org / ns / anno . json ld ", ĊĠĠĠĠĠ Ġbody Ġ= Ġthis . bookmark Body 2 , ĊĠĠĠĠĠ Ġid Ġ= Ġ" x ", ĊĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠ Ġmotivation Ġ= Ġ" http :// www . w 3 . org / ns / oa # bookmark ing ", ĊĠĠĠĠĠ Ġtarget Ġ= ĠBook mark Annotation Target Node ( ĊĠĠĠĠĠĠĠ Ġ" z 2 ", ĊĠĠĠĠĠĠĠ ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 2 ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġval Ġbookmark Annotation Response Ġ= ĊĠĠĠ ĠBook mark Annotation Response ( ĊĠĠĠĠĠ Ġcontext Ġ= ĠlistOf (" c 0 ", Ġ" c 1 ", Ġ" c 2 "), ĊĠĠĠĠĠ Ġtotal Ġ= Ġ 2 0 , ĊĠĠĠĠĠ Ġtype Ġ= ĠlistOf (" t 0 ", Ġ" t 1 ", Ġ" t 2 "), ĊĠĠĠĠĠ Ġid Ġ= Ġ" id 0 ", ĊĠĠĠĠĠ Ġfirst Ġ= ĠBook mark Annotation First Node ( ĊĠĠĠĠĠĠĠ Ġitems Ġ= ĠlistOf ( this . bookmark 0 , Ġthis . bookmark 1 , Ġthis . bookmark 2 ), ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġ" id " ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Selector () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 0 ) ĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Selector Node To JSON ( this . object Mapper , Ġinput ) ĊĊĠĠĠ ĠassertEquals (" oa : Fragment Selector ", Ġnode [" type "]. text Value ()) ĊĠĠĠ ĠassertEquals ( this . target Value 0 , Ġnode [" value "]. text Value ()) ĊĊĠĠĠ ĠassertEquals ( input , ĠBook mark Annotations JSON . deserialize Selector Node From JSON ( this . object Mapper , Ġnode )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Target () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation Target Node (" z ", ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 0 )) ĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Target Node To JSON ( this . object Mapper , Ġinput ) ĊĊĠĠĠ ĠassertEquals (" z ", Ġnode [" source "]. text Value ()) ĊĠĠĠ ĠassertEquals (" oa : Fragment Selector ", Ġnode [" selector "][" type "]. text Value ()) ĊĠĠĠ ĠassertEquals ( this . target Value 0 , Ġnode [" selector "][" value "]. text Value ()) ĊĊĠĠĠ ĠassertEquals ( input , ĠBook mark Annotations JSON . deserialize Target Node From JSON ( this . object Mapper , Ġnode )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Body () Ġ{ ĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Body Node To JSON ( this . object Mapper , Ġthis . bookmark Body 0 ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġ" 2 0 1 9 - 0 1 - 2 5 T 2 0 : 0 0 : 3 7 + 0 0 0 0 ", ĊĠĠĠĠĠ Ġnode [" http :// library simpl ified . org / terms / time "]. text Value () ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġ" cca 8 0 4 1 6 - 3 1 6 8 - 4 e 5 8 - b 6 2 1 - 7 9 6 4 b 9 2 6 5 ac 9 ", ĊĠĠĠĠĠ Ġnode [" http :// library simpl ified . org / terms / device "]. text Value () ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠ Ġnode [" http :// library simpl ified . org / terms / progress Within Chapter "] ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠ 5 0 . 0 , ĊĠĠĠĠĠ Ġnode [" http :// library simpl ified . org / terms / progress Within Book "]. doubleValue (), ĊĠĠĠĠĠĠ 0 . 0 ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġ" A ĠTitle ", ĊĠĠĠĠĠ Ġnode [" http :// library simpl ified . org / terms / chapter "]. text Value () ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( this . bookmark Body 0 , ĠBook mark Annotations JSON . deserialize Body Node From JSON ( node )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Bookmark () Ġ{ ĊĠĠĠ Ġval Ġtarget Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation Target Node (" z ", ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 0 )) ĊĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation ( ĊĠĠĠĠĠĠĠ Ġcontext Ġ= Ġ" http :// www . w 3 . org / ns / anno . json ld ", ĊĠĠĠĠĠĠĠ Ġbody Ġ= Ġthis . bookmark Body 0 , ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġ" x ", ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠĠĠ Ġmotivation Ġ= Ġ" http :// www . w 3 . org / ns / oa # bookmark ing ", ĊĠĠĠĠĠĠĠ Ġtarget Ġ= Ġtarget ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Bookmark Annotation To JSON ( this . object Mapper , Ġinput ) ĊĊĠĠĠ Ġthis . compare Annotations ( input , ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( this . object Mapper , Ġnode )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Bookmark Annotation First Node () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation First Node ( ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġ" x ", ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġ" z ", ĊĠĠĠĠĠĠĠ Ġitems Ġ= ĠlistOf ( this . bookmark 0 , Ġthis . bookmark 1 , Ġthis . bookmark 2 ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Bookmark Annotation First Node To JSON ( this . object Mapper , Ġinput ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġinput , ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation First Node From JSON ( this . object Mapper , Ġnode ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Bookmark Annotation Response () Ġ{ ĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Bookmark Annotation Response To JSON ( ĊĠĠĠĠĠĠĠ Ġthis . object Mapper , Ġthis . bookmark Annotation Response ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġthis . bookmark Annotation Response , ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation Response From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġnode ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Bookmark Bad Date SIMP LY _ 1 9 3 8 () Ġ{ ĊĠĠĠ Ġval Ġtarget Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation Target Node (" z ", ĠBook mark Annotation Selector Node (" oa : Fragment Selector ", Ġthis . target Value 0 )) ĊĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ ĠBook mark Annotation ( ĊĠĠĠĠĠĠĠ Ġcontext Ġ= Ġ" http :// www . w 3 . org / ns / anno . json ld ", ĊĠĠĠĠĠĠĠ Ġbody Ġ= Ġthis . bookmark Body Bad Date , ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġ" x ", ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġ" Annotation ", ĊĠĠĠĠĠĠĠ Ġmotivation Ġ= Ġ" http :// www . w 3 . org / ns / oa # bookmark ing ", ĊĠĠĠĠĠĠĠ Ġtarget Ġ= Ġtarget ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġnode Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Bookmark Annotation To JSON ( this . object Mapper , Ġinput ) ĊĊĠĠĠ Ġthis . compare Annotations ( input , ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( this . object Mapper , Ġnode )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Bookmark 0 () Ġ{ ĊĠĠĠ Ġval Ġannotation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" valid - bookmark - 0 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġbookmark Ġ= ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġannotation ) ĊĠĠĠ ĠassertEquals (" urn : uuid : 1 daa 8 de 6 - 9 4 e 8 - 4 7 1 1 - b 7 d 1 - e 4 3 b 5 7 2 aa 6 e 0 ", Ġbookmark . op ds Id ) ĊĠĠĠ ĠassertEquals (" urn : uuid : c 8 3 db 5 b 1 - 9 1 3 0 - 4 b 8 6 - 9 3 ea - 6 3 4 b 0 0 2 3 5 c 7 c ", Ġbookmark . device ID ) ĊĠĠĠ ĠassertEquals ( Bookmark Kind . Reader Bookmark Last Read Location , Ġbookmark . kind ) ĊĠĠĠ ĠassertEquals (" 2 0 2 1 - 0 3 - 1 2 T 1 6 : 3 2 : 4 9 . 0 0 0 Z ", Ġbookmark . time . toString ()) ĊĠĠĠ ĠassertEquals ("", Ġbookmark . chapter Title ) ĊĊĠĠĠ Ġval Ġlocation Ġ= Ġbookmark . location Ġas ĠBook Location . Book Location R 2 ĊĠĠĠ ĠassertEquals ( 0 . 6 6 6 , Ġlocation . progress . chapter Progress , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals ("/ xyz . html ", Ġlocation . progress . chapter Href ) ĊĊĠĠĠ Ġthis . check Round Trip ( annotation ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Bookmark 1 () Ġ{ ĊĠĠĠ Ġval Ġannotation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" valid - bookmark - 1 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ ĠDateTime Utils . setCurrent Millis Fixed ( 0 L ) ĊĊĠĠĠ Ġval Ġbookmark Ġ= ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġannotation ) ĊĠĠĠ ĠassertEquals (" urn : uuid : 1 daa 8 de 6 - 9 4 e 8 - 4 7 1 1 - b 7 d 1 - e 4 3 b 5 7 2 aa 6 e 0 ", Ġbookmark . op ds Id ) ĊĠĠĠ ĠassertEquals (" urn : uuid : c 8 3 db 5 b 1 - 9 1 3 0 - 4 b 8 6 - 9 3 ea - 6 3 4 b 0 0 2 3 5 c 7 c ", Ġbookmark . device ID ) ĊĠĠĠ ĠassertEquals ( Bookmark Kind . Reader Bookmark Last Read Location , Ġbookmark . kind ) ĊĠĠĠ ĠassertEquals (" 2 0 2 1 - 0 3 - 1 2 T 1 6 : 3 2 : 4 9 . 0 0 0 Z ", Ġbookmark . time . toString ()) ĊĠĠĠ ĠassertEquals ("", Ġbookmark . chapter Title ) ĊĊĠĠĠ Ġval Ġlocation Ġ= Ġbookmark . location Ġas ĠBook Location . Book Location R 2 ĊĠĠĠ ĠassertEquals ( 0 . 6 6 6 , Ġlocation . progress . chapter Progress , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals ("/ xyz . html ", Ġlocation . progress . chapter Href ) ĊĊĠĠĠ Ġthis . check Round Trip ( annotation ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Bookmark 2 () Ġ{ ĊĠĠĠ Ġval Ġannotation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" valid - bookmark - 2 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ ĠDateTime Utils . setCurrent Millis Fixed ( 0 L ) ĊĊĠĠĠ Ġval Ġbookmark Ġ= ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġannotation ) ĊĠĠĠ ĠassertEquals (" urn : uuid : 1 daa 8 de 6 - 9 4 e 8 - 4 7 1 1 - b 7 d 1 - e 4 3 b 5 7 2 aa 6 e 0 ", Ġbookmark . op ds Id ) ĊĠĠĠ ĠassertEquals (" urn : uuid : c 8 3 db 5 b 1 - 9 1 3 0 - 4 b 8 6 - 9 3 ea - 6 3 4 b 0 0 2 3 5 c 7 c ", Ġbookmark . device ID ) ĊĠĠĠ ĠassertEquals ( Bookmark Kind . Reader Bookmark Explicit , Ġbookmark . kind ) ĊĠĠĠ ĠassertEquals (" 2 0 2 1 - 0 3 - 1 2 T 1 6 : 3 2 : 4 9 . 0 0 0 Z ", Ġbookmark . time . toString ()) ĊĠĠĠ ĠassertEquals ("", Ġbookmark . chapter Title ) ĊĊĠĠĠ Ġval Ġlocation Ġ= Ġbookmark . location Ġas ĠBook Location . Book Location R 2 ĊĠĠĠ ĠassertEquals ( 0 . 6 6 6 , Ġlocation . progress . chapter Progress , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals ("/ xyz . html ", Ġlocation . progress . chapter Href ) ĊĊĠĠĠ Ġthis . check Round Trip ( annotation ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Bookmark 3 () Ġ{ ĊĠĠĠ Ġval Ġannotation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" valid - bookmark - 3 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ ĠDateTime Utils . setCurrent Millis Fixed ( 0 L ) ĊĊĠĠĠ Ġval Ġbookmark Ġ= ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġannotation ) ĊĠĠĠ ĠassertEquals (" urn : uuid : 1 daa 8 de 6 - 9 4 e 8 - 4 7 1 1 - b 7 d 1 - e 4 3 b 5 7 2 aa 6 e 0 ", Ġbookmark . op ds Id ) ĊĠĠĠ ĠassertEquals (" urn : uuid : c 8 3 db 5 b 1 - 9 1 3 0 - 4 b 8 6 - 9 3 ea - 6 3 4 b 0 0 2 3 5 c 7 c ", Ġbookmark . device ID ) ĊĠĠĠ ĠassertEquals ( Bookmark Kind . Reader Bookmark Explicit , Ġbookmark . kind ) ĊĠĠĠ ĠassertEquals (" 2 0 2 1 - 0 3 - 1 2 T 1 6 : 3 2 : 4 9 . 0 0 0 Z ", Ġbookmark . time . toString ()) ĊĠĠĠ ĠassertEquals ("", Ġbookmark . chapter Title ) ĊĊĠĠĠ Ġval Ġlocation Ġ= Ġbookmark . location Ġas ĠBook Location . Book Location R 2 ĊĠĠĠ ĠassertEquals ( 0 . 6 6 6 , Ġlocation . progress . chapter Progress , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals ("/ xyz . html ", Ġlocation . progress . chapter Href ) ĊĊĠĠĠ Ġthis . check Round Trip ( annotation ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Locator 0 () Ġ{ ĊĠĠĠ Ġval Ġlocation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Location ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġvalue Ġ= Ġthis . resource Text (" valid - locator - 0 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġlocation HP Ġ= Ġlocation Ġas ĠBook Location . Book Location R 2 ĊĠĠĠ ĠassertEquals ( 0 . 6 6 6 , Ġlocation HP . progress . chapter Progress , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals ("/ xyz . html ", Ġlocation HP . progress . chapter Href ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Valid Locator 1 () Ġ{ ĊĠĠĠ Ġval Ġlocation Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Location ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġvalue Ġ= Ġthis . resource Text (" valid - locator - 1 . json ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġlocation R 1 Ġ= Ġlocation Ġas ĠBook Location . Book Location R 1 ĊĠĠĠ ĠassertEquals ( 0 . 2 5 , Ġlocation R 1 . progress !! , Ġ 0 . 0 ) ĊĠĠĠ ĠassertEquals (" xyz - html ", Ġlocation R 1 . id Ref ) ĊĠĠĠ ĠassertEquals ("/ 4 / 2 / 2 / 2 ", Ġlocation R 1 . content C FI ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 0 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 0 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Expected : ĠA Ġkey Ġ' body ' ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 1 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 1 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Expected : ĠA Ġkey Ġ' mot ivation ' ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 2 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 2 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Expected : ĠA Ġkey Ġ' target ' ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 3 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 3 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Unrecognized Ġselector Ġnode Ġtype : ĠWhat ? ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 4 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 4 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Unexpected Ġcharacter Ġ(' [' ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 5 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 5 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Expected : ĠA Ġkey Ġ' http :// library simpl ified . org / terms / device ' ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Spec Invalid Bookmark 6 () Ġ{ ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( JSON ParseException :: class . java ) Ġ{ ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ ĠobjectMapper Ġ= Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġnode Ġ= Ġthis . resource Node (" invalid - bookmark - 6 . json ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertTrue ( ex . message !!. contains (" Expected : ĠA Ġkey Ġ' http :// library simpl ified . org / terms / time ' ")) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġresource Text ( ĊĠĠĠ Ġname : ĠString ĊĠ Ġ): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġthis . resource ( name ). read Bytes (). decode ToString () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġresource Node ( ĊĠĠĠ Ġname : ĠString ĊĠ Ġ): ĠObject Node Ġ{ ĊĠĠĠ Ġreturn Ġthis . object Mapper . read Tree ( this . resource Text ( name )) Ġas ĠObject Node ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcheck Round Trip ( bookmark Annotation : ĠBook mark Annotation ) Ġ{ ĊĠĠĠ Ġval Ġserialized Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . serialize Bookmark Annotation ToBytes ( this . object Mapper , Ġbookmark Annotation ) ĊĠĠĠ Ġval Ġserialized Text Ġ= ĊĠĠĠĠĠ Ġserialized . decode ToString () ĊĊĠĠĠ Ġthis . logger . debug (" serialized : Ġ{}", Ġserialized Text ) ĊĊĠĠĠ Ġval Ġdeserialized Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Bookmark Annotation From JSON ( ĊĠĠĠĠĠĠĠ Ġthis . object Mapper , ĊĠĠĠĠĠĠĠ Ġthis . object Mapper . read Tree ( serialized ) Ġas ĠObject Node ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġthis . compare Annotations ( bookmark Annotation , Ġdeserialized ) ĊĊĠĠĠ Ġval Ġto Bookmark Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġdeserialized ) ĊĠĠĠ Ġval Ġfrom Bookmark Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations . from Bookmark ( this . object Mapper , Ġto Bookmark ) ĊĠĠĠ Ġval Ġto Bookmark Again Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations . to Bookmark ( this . object Mapper , Ġfrom Bookmark ) ĊĊĠĠĠ Ġthis . compare Annotations ( bookmark Annotation , Ġdeserialized ) ĊĠĠĠ Ġthis . compare Annotations ( bookmark Annotation , Ġfrom Bookmark ) ĊĠĠĠ ĠassertEquals ( to Bookmark , Ġto Bookmark Again ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcompare Annotations ( ĊĠĠĠ Ġx : ĠBook mark Annotation , ĊĠĠĠ Ġy : ĠBook mark Annotation ĊĠ Ġ) Ġ{ ĊĠĠĠ Ġthis . logger . debug (" compare Annotations : Ġx : Ġ{}", Ġx ) ĊĠĠĠ Ġthis . logger . debug (" compare Annotations : Ġy : Ġ{}", Ġy ) ĊĊĠĠĠ ĠassertEquals ( x . body . book Progress , Ġy . body . book Progress ) ĊĠĠĠ ĠassertEquals ( x . body . chapter Title , Ġy . body . chapter Title ) ĊĠĠĠ ĠassertEquals ( x . body . device , Ġy . body . device ) ĊĠĠĠ ĠassertEquals ( x . body . timestamp , Ġy . body . timestamp ) ĊĠĠĠ ĠassertEquals ( x . context , Ġy . context ) ĊĠĠĠ ĠassertEquals ( x . id , Ġy . id ) ĊĠĠĠ ĠassertEquals ( x . kind , Ġy . kind ) ĊĠĠĠ ĠassertEquals ( x . mot ivation , Ġy . mot ivation ) ĊĠĠĠ ĠassertEquals ( x . target . selector . type , Ġy . target . selector . type ) ĊĊĠĠĠ Ġval Ġx Selector Value Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Location ( this . object Mapper , Ġx . target . selector . value ) ĊĠĠĠ Ġval Ġy Selector Value Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON . deserialize Location ( this . object Mapper , Ġy . target . selector . value ) ĊĊĠĠĠ ĠassertEquals ( x Selector Value , Ġy Selector Value ) ĊĠĠĠ ĠassertEquals ( x . target . source , Ġy . target . source ) ĊĠĠĠ ĠassertEquals ( x . type , Ġy . type ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġresource ( ĊĠĠĠ Ġname : ĠString ĊĠ Ġ): ĠInputStream Ġ{ ĊĠĠĠ Ġval ĠfileName Ġ= ĊĠĠĠĠĠ Ġ"/ org / ny pl / simpl ified / tests / bookmark _ annotations / spec /$ name " ĊĠĠĠ Ġval Ġurl Ġ= ĊĠĠĠĠĠ ĠBook mark Annotations JSON Test :: class . java . getResource ( fileName ) ĊĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠFileNotFoundException (" No Ġsuch Ġresource : Ġ$ fileName ") ĊĠĠĠ Ġreturn Ġurl . open Stream () ĊĠ Ġ} Ċ } Ċ