package Ġs moke Ċ Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġorg . http 4 k . client . Java HttpClient Ċ import Ġorg . http 4 k . core . Response Ċ import Ġorg . http 4 k . core . Status Ċ import Ġorg . http 4 k . ham k rest . has Status Ċ import Ġorg . junit . Test Ċ import Ġs moke . clients . Analytics Keys Submission Client Ċ import Ġs moke . env . S moke Tests Ċ import Ġuk . n hs . n hs x . an alytic ss ub mission . model . Analytics Metadata Ċ import Ġuk . n hs . n hs x . an alytic ss ub mission . model . Analytics Metrics Ċ import Ġuk . n hs . n hs x . an alytic ss ub mission . model . Analytics Window Ċ import Ġuk . n hs . n hs x . an alytic ss ub mission . model . Client Analytics Submission Payload Ċ import Ġuk . n hs . n hs x . core . DateFormat Validator Ċ import Ġuk . n hs . n hs x . core . Jack son Ċ import Ġjava . time . Offset DateTime Ċ Ċ class ĠAnalytics Submission S moke Test () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġconfig Ġ= ĠS moke Tests . load Config () ĊĠĠĠ Ġprivate Ġval Ġclient Ġ= ĠJava HttpClient () ĊĠĠĠ Ġprivate Ġval ĠstartDate Ġ= ĠOffset DateTime . now (). minus Days ( 1 ). format ( DateFormat Validator . formatter ). toString () ĊĠĠĠ Ġprivate Ġval ĠendDate Ġ= ĠOffset DateTime . now (). plus Days ( 1 ). format ( DateFormat Validator . formatter ). toString () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` submit Ġios Ġanalytics Ġdata `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpayload : ĠClient Analytics Submission Payload Ġ= Ġgenerate I os Analytics Payload () ĊĠĠĠĠĠĠĠ Ġinvoke Analytics And Validate () ĊĠĠĠĠĠĠĠ Ġval Ġupload Response Ġ= Ġupload Analytics ToS 3 ( Jack son . toJson ( payload )) ĊĠĠĠĠĠĠĠ ĠassertThat ( upload Response , Ġhas Status ( Status . OK )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` submit Ġandroid Ġanalytics Ġdata `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpayload : ĠClient Analytics Submission Payload Ġ= Ġgenerate Android Analytics Payload () ĊĠĠĠĠĠĠĠ Ġinvoke Analytics And Validate () ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġupload Analytics ToS 3 ( Jack son . toJson ( payload )) ĊĠĠĠĠĠĠĠ ĠassertThat ( response , Ġhas Status ( Status . OK )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgenerate I os Analytics Payload (): ĠClient Analytics Submission Payload Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanalytics Metrics Ġ= ĠAnalytics Metrics () ĊĠĠĠĠĠĠĠ Ġval Ġanalytics Metadata Ġ= ĠAnalytics Metadata (" AB 1 0 ", Ġ" iPhone - smoke - test ", Ġ" iPhone ĠOS Ġ 1 3 . 5 . 1 Ġ( 1 7 F 8 0 )", Ġ" 3 . 0 ") ĊĊĠĠĠĠĠĠĠ Ġreturn ĠClient Analytics Submission Payload ( Analytics Window ( startDate , ĠendDate ), Ġanalytics Metadata , Ġanalytics Metrics , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgenerate Android Analytics Payload (): ĠClient Analytics Submission Payload Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġanalytics Metrics Ġ= ĠAnalytics Metrics () ĊĠĠĠĠĠĠĠ Ġval Ġanalytics Metadata Ġ= ĠAnalytics Metadata (" AB 1 0 ", Ġ" H UA WE I - smoke - test ", Ġ" 2 9 ", Ġ" 3 . 0 ") ĊĠĠĠĠĠĠĠ Ġreturn ĠClient Analytics Submission Payload ( Analytics Window ( startDate , ĠendDate ), Ġanalytics Metadata , Ġanalytics Metrics , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinvoke Analytics And Validate () Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠAnalytics Keys Submission Client ( client , Ġconfig ). invoke Mobile Analytics () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupload Analytics ToS 3 ( json : ĠString ): ĠResponse Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠAnalytics Keys Submission Client ( client , Ġconfig ). upload ( json ) ĊĠĠĠ Ġ} Ċ }