package Ġcom . ec wid . apic lient . v 3 Ċ Ċ import Ġcom . ec wid . apic lient . v 3 . converter . to Updated Ċ import Ġcom . ec wid . apic lient . v 3 . dto . Upload File Data Ċ import Ġcom . ec wid . apic lient . v 3 . dto . order . enums . Order Ful fillment Status Ċ import Ġcom . ec wid . apic lient . v 3 . dto . order . enums . Order Payment Status Ċ import Ġcom . ec wid . apic lient . v 3 . dto . order . enums . Product Option Type Ċ import Ġcom . ec wid . apic lient . v 3 . dto . order . request .* Ċ import Ġcom . ec wid . apic lient . v 3 . dto . order . result . F etched Order Ċ import Ġcom . ec wid . apic lient . v 3 . exception . E cw id ApiException Ċ import Ġcom . ec wid . apic lient . v 3 . util .* Ċ import Ġorg . junit . jupiter . api . Assertions .* Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert All Ċ import Ġjava . io . FileInputStream Ċ import Ġjava . nio . file . Files Ċ import Ġjava . util .* ĊĊ Ċ class ĠOrders Test Ġ: ĠBase Entity Test () Ġ{ ĊĊ ĉ @ BeforeEach Ċ ĉ override Ġfun ĠbeforeEach () Ġ{ Ċĉ ĉ super . before Each () ĊĊĉ ĉ // ĠWe Ġneed Ġto Ġstart Ġfrom Ġscratch Ġeach Ġtime Ċĉ ĉ init Store Profile () Ċĉ ĉ removeAll Orders () Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Order Lifecycle () Ġ{ Ċĉ ĉ // ĠCreating Ġnew Ġorder Ċĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( Ċĉĉĉ ĉ new Order Ġ= Ġgenerate Test Order () Ċĉ ĉ ) Ċĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉ ĉ assertTrue ( order Create Result . id Ġ> Ġ 0 ) ĊĊĉ ĉ // ĠChecking Ġthat Ġorder Ġwas Ġsuccessfully Ġcreated Ġwith Ġnecessary Ġparameters Ċĉ ĉ val Ġorder Details Request Ġ= ĠOrder Details Request ( order Number Ġ= Ġorder Create Result . id ) Ċĉ ĉ val Ġorder Details 1 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ assertEquals ( order CreateRequest . new Order , Ġorder Details 1 . to Updated (). cleanup For Comparison ( order CreateRequest . new Order )) ĊĊĉ ĉ // ĠComp let ely Ġupdating Ġnewly Ġcreated Ġorder Ċĉ ĉ val Ġorder Update Request Ġ= ĠOrder Update Request ( Ċĉĉĉ ĉ order Number Ġ= Ġorder Details 1 . order Number , Ċĉĉĉ ĉ updated Order Ġ= Ġgenerate Test Order (). copy ( Ċĉĉĉĉĉ ĉ customer Group Ġ= Ġnull Ġ// ĠTODO ĠDis cover Ġwhy Ġafter Ġeach Ġupdate Ġthis Ġfield Ġresets Ġto Ġnull Ċĉĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Update Result 1 Ġ= ĠapiClient . update Order ( order Update Request ) Ċĉ ĉ assertEquals ( 1 , Ġorder Update Result 1 . update Count ) ĊĊĉ ĉ // ĠChecking Ġthat Ġorder Ġwas Ġsuccessfully Ġupdated Ġwith Ġnecessary Ġparameters Ċĉ ĉ val Ġorder Details 2 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ assertEquals ( order Update Request . updated Order , Ġorder Details 2 . to Updated (). cleanup For Comparison ( order Update Request . updated Order )) ĊĊĉ ĉ // ĠDe leting Ġorder Ċĉ ĉ val Ġorder Delete Request Ġ= ĠOrder Delete Request ( order Number Ġ= Ġorder Details 1 . order Number ) Ċĉ ĉ val Ġorder Delete Result Ġ= ĠapiClient . delete Order ( order Delete Request ) Ċĉ ĉ assertEquals ( 1 , Ġorder Delete Result . delete Count ) ĊĊĉ ĉ // ĠChecking Ġthat Ġdeleted Ġorder Ġis Ġnot Ġaccessible Ġanymore Ċĉ ĉ try Ġ{ Ċĉĉ ĉ apiClient . getOrder Details ( order Details Request ) Ċĉ ĉ } Ġcatch Ġ( e : ĠE cw id ApiException ) Ġ{ Ċĉĉ ĉ assertEquals ( 4 0 4 , Ġe . statusCode ) Ċĉĉ ĉ assertEquals (" Order Ġ# ${ order Create Result . id } Ġnot Ġfound ", Ġe . message ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Manip ulate Order Item Option Files () Ġ{ Ċĉ ĉ // ĠCreating Ġorder Ġwith Ġitem Ġwith ĠFILE S Ġoption Ċĉ ĉ val Ġfiles Option Name Ġ= Ġ" File Ġoption ĠÐ¢ ÐµÑģÑĤ Ġ! @ #$ %^ & * ()" ĊĊĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( Ċĉĉĉ ĉ new Order Ġ= ĠUpdated Order ( Ċĉĉĉĉĉ ĉ email Ġ= Ġrandom Email (), Ċĉĉĉĉĉ ĉ items Ġ= ĠlistOf ( Ċĉĉĉĉĉĉĉ ĉ Updated Order . Order Item ( Ċĉĉĉĉĉĉĉĉĉ ĉ name Ġ= Ġ" Order Ġitem Ġwith Ġfiles ", Ċĉĉĉĉĉĉĉĉĉ ĉ selected Options Ġ= ĠlistOf ( Ċĉĉĉĉĉĉĉĉĉĉĉ ĉ Updated Order . Order ItemSelected Option . create For Files Option ( Ċĉĉĉĉĉĉĉĉĉĉĉĉĉ ĉ name Ġ= Ġfiles Option Name Ċĉĉĉĉĉĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉĉ ĉ ) Ċĉĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉ ĉ val ĠorderNumber Ġ= Ġorder Create Result . id Ċĉ ĉ assertTrue ( order Number Ġ> Ġ 0 ) ĊĊĉ ĉ // ĠGet Ġorder Ġitem ĠID Ġin Ġnewly Ġcreated Ġorder Ċĉ ĉ val Ġorder Details Request Ġ= ĠOrder Details Request ( order Number Ġ= ĠorderNumber ) Ċĉ ĉ val Ġorder Details 1 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ val Ġorder ItemId Ġ= Ġorder Details 1 . items ?. first OrNull ()?. id Ċĉ ĉ require ( order ItemId Ġ!= Ġnull ) ĊĊĉ ĉ // ĠUpload Ġsome Ġorder Ġfiles Ġfrom Ġdifferent Ġsources Ċĉ ĉ val Ġorder Item Option FileUpload Request 1 Ġ= ĠOrder Item Option FileUpload Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name , Ċĉĉĉ ĉ fileName Ġ= Ġrandom FileName (" test ", Ġ" png "), Ċĉĉĉ ĉ file Data Ġ= ĠUpload File Data . External Url Data ( external Url Ġ= Ġ" https :// don 1 6 ob qb ay 2 c . cloudfront . net / fav icons / apple - touch - icon - 1 8 0 x 1 8 0 . png ") Ċĉ ĉ ) Ċĉ ĉ val Ġorder Item Option FileUpload Request 2 Ġ= ĠOrder Item Option FileUpload Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name , Ċĉĉĉ ĉ fileName Ġ= Ġrandom FileName (" test ", Ġ" png "), Ċĉĉĉ ĉ file Data Ġ= ĠUpload File Data . Local File Data ( file Ġ= Ġget Test P ng FilePath (). to File ()) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Item Option FileUpload Request 3 Ġ= ĠOrder Item Option FileUpload Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name , Ċĉĉĉ ĉ fileName Ġ= Ġrandom FileName (" test ", Ġ" png "), Ċĉĉĉ ĉ file Data Ġ= ĠUpload File Data . InputStream Data ( stream Ġ= ĠFileInputStream ( getTest P ng FilePath (). to File ())) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Item Option FileUpload Request 4 Ġ= ĠOrder Item Option FileUpload Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name , Ċĉĉĉ ĉ fileName Ġ= Ġrandom FileName (" test ", Ġ" png "), Ċĉĉĉ ĉ file Data Ġ= ĠUpload File Data . ByteArray Data ( bytes Ġ= ĠFiles . read All Bytes ( getTest P ng FilePath ())) Ċĉ ĉ ) ĊĊĉ ĉ val Ġorder Item Option FileUpload Result 1 Ġ= ĠapiClient . upload Order Item Option File ( order Item Option FileUpload Request 1 ) Ċĉ ĉ val Ġorder Item Option FileUpload Result 2 Ġ= ĠapiClient . upload Order Item Option File ( order Item Option FileUpload Request 2 ) Ċĉ ĉ val Ġorder Item Option FileUpload Result 3 Ġ= ĠapiClient . upload Order Item Option File ( order Item Option FileUpload Request 3 ) Ċĉ ĉ val Ġorder Item Option FileUpload Result 4 Ġ= ĠapiClient . upload Order Item Option File ( order Item Option FileUpload Request 4 ) ĊĊĉ ĉ assert All ( Ċĉĉĉ ĉ { ĠassertTrue ( order Item Option FileUpload Result 1 . id Ġ> Ġ 0 ) Ġ}, Ċĉĉĉ ĉ { ĠassertTrue ( order Item Option FileUpload Result 2 . id Ġ> Ġ 0 ) Ġ}, Ċĉĉĉ ĉ { ĠassertTrue ( order Item Option FileUpload Result 3 . id Ġ> Ġ 0 ) Ġ}, Ċĉĉĉ ĉ { ĠassertTrue ( order Item Option FileUpload Result 4 . id Ġ> Ġ 0 ) Ġ} Ċĉ ĉ ) ĊĊĉ ĉ // ĠCheck Ġthat Ġfiles Ġoption Ġhas Ġaccurate Ġ 4 Ġattached Ġfiles Ċĉ ĉ val Ġorder Details 2 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ val Ġfiles Option 2 Ġ= Ġorder Details 2 . items ?. first ()?. selected Options ?. first ()?. files Ċĉ ĉ require ( files Option 2 Ġ!= Ġnull ) Ċĉ ĉ assertEquals ( 4 , Ġfiles Option 2 . size ) Ċĉ ĉ assert File Option ( files Option 2 [ 0 ], Ġorder Item Option FileUpload Request 1 . fileName ) Ċĉ ĉ assert File Option ( files Option 2 [ 1 ], Ġorder Item Option FileUpload Request 2 . fileName ) Ċĉ ĉ assert File Option ( files Option 2 [ 2 ], Ġorder Item Option FileUpload Request 3 . fileName ) Ċĉ ĉ assert File Option ( files Option 2 [ 3 ], Ġorder Item Option FileUpload Request 4 . fileName ) ĊĊĉ ĉ // ĠNow Ġdelete Ġfirst Ġattached Ġto Ġoption Ġfile Ċĉ ĉ val Ġdelete Order Item Option File Request Ġ= ĠOrder Item Option File Delete Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name , Ċĉĉĉ ĉ file Id Ġ= Ġorder Item Option FileUpload Result 1 . id Ċĉ ĉ ) Ċĉ ĉ val Ġorder Item Option File Delete Result Ġ= ĠapiClient . delete Order Item Option File ( delete Order Item Option File Request ) Ċĉ ĉ assertEquals ( 1 , Ġorder Item Option File Delete Result . delete Count ) ĊĊĉ ĉ // ĠCheck Ġthat Ġonly Ġ 3 Ġattached Ġfiles Ġleft Ċĉ ĉ val Ġorder Details 3 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ val Ġfiles Option 3 Ġ= Ġorder Details 3 . items ?. first ()?. selected Options ?. first ()?. files Ċĉ ĉ assertEquals ( 3 , Ġfiles Option 3 ?. size ) ĊĊĉ ĉ // ĠNow Ġdelete Ġthe Ġrest Ġattached Ġto Ġoption Ġfiles Ċĉ ĉ val Ġdelete Order Item Option Files Request Ġ= ĠOrder Item Option Files Delete Request ( Ċĉĉĉ ĉ order Number Ġ= ĠorderNumber , Ċĉĉĉ ĉ order ItemId Ġ= Ġorder ItemId , Ċĉĉĉ ĉ option Name Ġ= Ġfiles Option Name Ċĉ ĉ ) Ċĉ ĉ val Ġorder Item Option Files Delete Result Ġ= ĠapiClient . delete Order Item Option Files ( delete Order Item Option Files Request ) Ċĉ ĉ assertEquals ( 3 , Ġorder Item Option Files Delete Result . delete Count ) ĊĊĉ ĉ // ĠCheck Ġthat Ġno Ġattached Ġfiles Ġremain Ċĉ ĉ val Ġorder Details 4 Ġ= ĠapiClient . getOrder Details ( order Details Request ) Ċĉ ĉ val Ġfiles Option 4 Ġ= Ġorder Details 4 . items ?. first ()?. selected Options ?. first ()?. files Ċĉ ĉ assertNull ( files Option 4 ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Search Fields () Ġ{ Ċĉ ĉ // ĠCreating Ġnew Ġorder Ċĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( Ċĉĉĉ ĉ new Order Ġ= ĠUpdated Order ( Ċĉĉĉĉĉ ĉ email Ġ= Ġrandom Email (), Ċĉĉĉĉĉ ĉ total Ġ= Ġrandom Price (), Ċ // ĉĉĉĉĉ ĉ discount Coupon Ġ= ĠUpdated Order . Discount Coupon Info ( Ċ // ĉĉĉĉĉĉĉ ĉ name Ġ= Ġ" Discount Ġcoupon Ġ" Ġ+ Ġrandom Al phanumeric ( 1 6 ), Ċ // ĉĉĉĉĉĉĉ ĉ code Ġ= Ġrandom Al phanumeric ( 1 6 ) Ċ // ĉĉĉĉĉ ĉ ), Ċĉĉĉĉĉ ĉ payment Method Ġ= Ġ" Payment Ġmethod Ġ" Ġ+ Ġrandom Al phanumeric ( 8 ), Ċĉĉĉĉĉ ĉ shipping Option Ġ= ĠUpdated Order . Shipping Option ( Ċĉĉĉĉĉĉĉ ĉ shipping MethodName Ġ= Ġ" Method Ġ" Ġ+ Ġrandom Al phanumeric ( 8 ) Ċĉĉĉĉĉ ĉ ), Ċĉĉĉĉĉ ĉ payment Status Ġ= ĠOrder Payment Status . AW A IT ING _ PAYMENT , Ċĉĉĉĉĉ ĉ ful fillment Status Ġ= ĠOrder Ful fillment Status . AW A IT ING _ PROCESS ING , Ċĉĉĉĉĉ ĉ order Comments Ġ= Ġrandom Al phanumeric ( 1 6 ), Ċĉĉĉĉĉ ĉ billing Person Ġ= ĠUpdated Order . Person Info ( Ċĉĉĉĉĉĉĉ ĉ name Ġ= Ġrandom Al phanumeric ( 1 6 ) Ċĉĉĉĉĉ ĉ ) Ċĉĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉ ĉ assertTrue ( order Create Result . id Ġ> Ġ 0 ) ĊĊĉ ĉ // ĠWaiting Ġtill Ġorder Ġbecame Ġavailable Ġfor Ġsearching Ċĉ ĉ process Delay ( 1 0 0 0 , Ġ 1 0 ) Ġ{ Ċĉĉ ĉ val Ġorders Search Request Ġ= ĠOrders Search Request ( keywords Ġ= Ġorder CreateRequest . new Order . order Comments ) Ċĉĉ ĉ val Ġorders SearchResult Ġ= ĠapiClient . search Orders ( orders Search Request ) Ċĉĉ ĉ if Ġ( orders SearchResult . total Ġ> Ġ 0 ) Ġorders SearchResult Ġelse Ġnull Ċĉ ĉ } ĊĊĉ ĉ // ĠTrying Ġto Ġsearch Ġby Ġdifferent Ġfields Ċĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( keywords Ġ= Ġorder CreateRequest . new Order . order Comments ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( keywords Ġ= Ġorder CreateRequest . new Order . order Comments Ġ+ Ġ" foo ") Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ total From Ġ= Ġorder CreateRequest . new Order . total !! Ġ- Ġ 1 0 . 0 , Ċĉĉĉĉĉ ĉ total To Ġ= Ġorder CreateRequest . new Order . total !! Ġ+ Ġ 1 0 . 0 Ċĉĉĉ ĉ ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ total From Ġ= Ġorder CreateRequest . new Order . total !! Ġ- Ġ 2 0 . 0 , Ċĉĉĉĉĉ ĉ total To Ġ= Ġorder CreateRequest . new Order . total !! Ġ- Ġ 1 0 . 0 Ċĉĉĉ ĉ ) Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ created From Ġ= ĠDate . from ( Date (). to Instant (). minus Seconds ( 6 0 )), Ċĉĉĉĉĉ ĉ created To Ġ= ĠDate . from ( Date (). to Instant (). plus Seconds ( 6 0 )) Ċĉĉĉ ĉ ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ created From Ġ= ĠDate ( 0 ), Ċĉĉĉĉĉ ĉ created To Ġ= ĠDate ( 0 ) Ċĉĉĉ ĉ ) Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ updated From Ġ= ĠDate . from ( Date (). to Instant (). minus Seconds ( 6 0 )), Ċĉĉĉĉĉ ĉ updated To Ġ= ĠDate . from ( Date (). to Instant (). plus Seconds ( 6 0 )) Ċĉĉĉ ĉ ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( Ċĉĉĉĉĉ ĉ updated From Ġ= ĠDate ( 0 ), Ċĉĉĉĉĉ ĉ updated To Ġ= ĠDate ( 0 ) Ċĉĉĉ ĉ ) Ċĉ ĉ ) ĊĊĉ ĉ // ĠTODO ĠWe Ġshould Ġcreate Ġreal Ġdiscount Ġcoupon Ġto Ġmake Ġthis Ġsearch Ġworks Ġcorrectly Ċ // ĉ ĉ assert Order Search ( Ċ // ĉĉĉ ĉ positive Order Number Ġ= Ġcreate Order Result . id , Ċ // ĉĉĉ ĉ positive Search Request Ġ= ĠSearch Orders Request ( coupon Code Ġ= Ġcreate Order Request . new Order . discount Coupon ?. code ), Ċ // ĉĉĉ ĉ negative Search Request Ġ= ĠSearch Orders Request ( coupon Code Ġ= Ġcreate Order Request . new Order . discount Coupon ?. code Ġ+ Ġ" foo ") Ċ // ĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( order Number Ġ= Ġorder Create Result . id ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( order Number Ġ= ĠInt . MAX _ VALUE ) Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( vendor Order Number Ġ= Ġorder Create Result . id . toString ()), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( vendor Order Number Ġ= Ġ" foo ") Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( customer Ġ= Ġorder CreateRequest . new Order . billing Person ?. name ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( customer Ġ= Ġ" foo ") Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( payment Method Ġ= Ġorder CreateRequest . new Order . payment Method ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( payment Method Ġ= Ġ" foo ") Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( shipping Method Ġ= Ġorder CreateRequest . new Order . shipping Option ?. shipping MethodName ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( shipping Method Ġ= Ġ" foo ") Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( payment Status Ġ= ĠOrder Payment Status . AW A IT ING _ PAYMENT ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( payment Status Ġ= ĠOrder Payment Status . PA ID ) Ċĉ ĉ ) ĊĊĉ ĉ assert Orders Search ( Ċĉĉĉ ĉ positive Order Number Ġ= Ġorder Create Result . id , Ċĉĉĉ ĉ positive Search Request Ġ= ĠOrders Search Request ( ful fillment Status Ġ= ĠOrder Ful fillment Status . AW A IT ING _ PROCESS ING ), Ċĉĉĉ ĉ negative Search Request Ġ= ĠOrders Search Request ( ful fillment Status Ġ= ĠOrder Ful fillment Status . SHIP PED ) Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Search Paging () Ġ{ Ċĉ ĉ // ĠCreate Ġsome Ġorders Ċĉ ĉ for Ġ( i Ġin Ġ 1 .. 3 ) Ġ{ Ċĉĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( new Order Ġ= ĠUpdated Order ()) Ċĉĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉĉ ĉ assertTrue ( order Create Result . id Ġ> Ġ 0 ) Ċĉ ĉ } ĊĊĉ ĉ // ĠWaiting Ġtill Ġorder Ġbecame Ġavailable Ġfor Ġsearching Ġand Ġtrying Ġto Ġrequest Ġonly Ġone Ġpage Ċĉ ĉ val Ġorders Search Request Ġ= ĠOrders Search Request ( offset Ġ= Ġ 2 , Ġlimit Ġ= Ġ 2 ) Ċĉ ĉ val Ġorders SearchResult Ġ= Ġprocess Delay ( 1 0 0 0 , Ġ 1 0 ) Ġ{ Ċĉĉ ĉ val Ġresult Ġ= ĠapiClient . search Orders ( orders Search Request ) Ċĉĉ ĉ if Ġ( result . count Ġ== Ġ 1 Ġ&& Ġresult . total Ġ== Ġ 3 ) Ġresult Ġelse Ġnull Ċĉ ĉ } ĊĊĉ ĉ assertEquals ( 1 , Ġorders SearchResult . count ) Ċĉ ĉ assertEquals ( 3 , Ġorders SearchResult . total ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun ĠtestGet Order Invoice () Ġ{ Ċĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( Ċĉĉĉ ĉ new Order Ġ= ĠUpdated Order ( Ċĉĉĉĉĉ ĉ email Ġ= Ġrandom Email () Ċĉĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉ ĉ assertTrue ( order Create Result . id Ġ> Ġ 0 ) ĊĊĉ ĉ process Delay ( 1 0 0 0 , Ġ 1 0 ) Ġ{ Ċĉĉ ĉ val Ġresult Ġ= ĠapiClient . search Orders ( Orders Search Request ()) Ċĉĉ ĉ if Ġ( result . count Ġ== Ġ 1 ) Ġresult Ġelse Ġnull Ċĉ ĉ } ĊĊĉ ĉ val Ġorder Invoice Request Ġ= ĠOrder Invoice Request ( order Number Ġ= Ġorder Create Result . id ) Ċĉ ĉ val Ġinvoice Html Ġ= ĠapiClient . getOrder Invoice ( order Invoice Request ) Ċĉ ĉ assertTrue ( invoice Html . contains (" <!-- ĠInvoice Ġbody Ġmarkup Ġ--> ")) Ċĉ ĉ assertTrue ( invoice Html . contains (" <!-- ĠOrder Ġnumber Ġ--> ")) Ċĉ ĉ assertTrue ( invoice Html . contains ("# ${ order Create Result . id }</ span > ")) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Deleted Orders () Ġ{ Ċĉ ĉ // ĠCreating Ġnew Ġorder Ċĉ ĉ val Ġorder CreateRequest Ġ= ĠOrder CreateRequest ( Ċĉĉĉ ĉ new Order Ġ= Ġgenerate Test Order () Ċĉ ĉ ) Ċĉ ĉ val Ġorder Create Result Ġ= ĠapiClient . create Order ( order CreateRequest ) Ċĉ ĉ assertTrue ( order Create Result . id Ġ> Ġ 0 ) ĊĊĉ ĉ // ĠDe leting Ġorder Ċĉ ĉ val Ġorder Delete Request Ġ= ĠOrder Delete Request ( order Number Ġ= Ġorder Create Result . id ) Ċĉ ĉ val Ġorder Delete Result Ġ= ĠapiClient . delete Order ( order Delete Request ) Ċĉ ĉ assertEquals ( 1 , Ġorder Delete Result . delete Count ) ĊĊĉ ĉ val Ġinstant Ġ= ĠDate (). to Instant () Ċĉ ĉ val Ġinstant From Ġ= Ġinstant . minus Seconds ( 1 0 ) Ċĉ ĉ val Ġinstant To Ġ= Ġinstant . plus Seconds ( 1 0 ) ĊĊĉ ĉ // ĠChecking Ġthat Ġjust Ġdeleted Ġorder Ġreturned Ġfrom Ġapi Ċĉ ĉ val Ġdeleted Orders Search Request Ġ= ĠDeleted Orders Search Request ( Ċĉĉĉ ĉ deleted From Ġ= ĠDate . from ( instant From ), Ċĉĉĉ ĉ deleted To Ġ= ĠDate . from ( instant To ) Ċĉ ĉ ) Ċĉ ĉ val Ġdeleted Orders Ġ= ĠapiClient . search Deleted Orders As Sequence ( deleted Orders Search Request ) Ċĉ ĉ val Ġdeleted Order Ġ= Ġdeleted Orders . first OrNull Ġ{ Ġdeleted Order Ġ-> Ġdeleted Order . id Ġ== Ġorder Create Result . id Ġ} Ċĉ ĉ require ( deleted Order Ġ!= Ġnull ) Ċĉ ĉ assertTrue ( instant From . is Before ( deleted Order . date . to Instant ())) Ċĉ ĉ assertTrue ( instant To . is After ( deleted Order . date . to Instant ())) Ċ ĉ } ĊĊ ĉ private Ġfun Ġassert Orders Search ( positive Order Number : ĠInt , Ġpositive Search Request : ĠOrders Search Request , Ġnegative Search Request : ĠOrders Search Request ) Ġ{ Ċĉ ĉ val Ġpositive Orders SearchResult Ġ= ĠapiClient . search Orders ( positive Search Request ) Ċĉ ĉ assertEquals ( 1 , Ġpositive Orders SearchResult . total ) Ċĉ ĉ assertEquals ( positive Order Number , Ġpositive Orders SearchResult . items [ 0 ]. order Number ) ĊĊĉ ĉ val Ġnegative Orders SearchResult Ġ= ĠapiClient . search Orders ( negative Search Request ) Ċĉ ĉ assertEquals ( 0 , Ġnegative Orders SearchResult . total ) Ċ ĉ } Ċ } Ċ Ċ private Ġfun Ġassert File Option ( order Item Product File : ĠF etched Order . Order Item Product File , ĠfileName : ĠString ) Ġ{ Ċ ĉ assert All ( Ċĉĉ ĉ { ĠassertTrue ( order Item Product File . id Ġ?: Ġ 0 Ġ> Ġ 0 ) Ġ}, Ċĉĉ ĉ { ĠassertEquals ( fileName , Ġorder Item Product File . name ) Ġ}, Ċĉĉ ĉ { ĠassertTrue ( order Item Product File . size Ġ?: Ġ 0 Ġ> Ġ 0 ) Ġ}, Ċĉĉ ĉ { ĠassertTrue ( order Item Product File . url ?. contains ( fileName ) Ġ?: Ġfalse ) Ġ} Ċ ĉ ) Ċ } Ċ Ċ private Ġfun ĠUpdated Order . cleanup For Comparison ( order : ĠUpdated Order ): ĠUpdated Order Ġ{ Ċ ĉ return Ġcopy ( Ċĉ ĉ // ĠPick up Ġtime Ġconverted Ġto ĠUTC Ġfrom Ġlocal Ġduring Ġorder Ġcreation Ċĉ ĉ pickup Time Ġ= Ġpick up Time ?. let Ġ{ Ġdate To Utc ( it ) Ġ}, Ċĉ ĉ // ĠCustomer Ġid Ġand Ġcustomer Ġgroup Ġupdated Ġduring Ġorder Ġcreation Ċĉ ĉ customer Id Ġ= Ġorder . customer Id , Ċĉ ĉ customer Group Ġ= Ġorder . customer Group , ĊĊĉ ĉ // ĠDelete Ġafter Ġbug ĠEC WID - 7 1 4 8 1 Ġfix Ċĉ ĉ items Ġ= Ġitems ?. map Indexed Ġ{ Ġindex , Ġitem Ġ-> Ċĉĉ ĉ val Ġrequest Item Ġ= Ġorder . items ?. get ( index ) Ċĉĉ ĉ item . cleanup For Comparison ( request Item ) Ċĉ ĉ } Ċ ĉ ) Ċ } Ċ Ċ private Ġfun ĠUpdated Order . Order Item . cleanup For Comparison ( order Item : ĠUpdated Order . Order Item ?): ĠUpdated Order . Order Item Ġ{ Ċ ĉ return Ġcopy ( Ċĉ ĉ selected Options Ġ= Ġselected Options ?. map Indexed Ġ{ Ġindex , Ġoption Ġ-> Ċĉĉ ĉ if Ġ( option . type Ġ== ĠProduct Option Type . CHO ICES ) Ġ{ Ċĉĉĉ ĉ val Ġrequest Option Ġ= Ġorder Item ?. selected Options ?. get ( index ) Ċĉĉĉ ĉ option . cleanup For Comparison ( request Option ) Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ option Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ ) Ċ } Ċ Ċ private Ġfun ĠUpdated Order . Order ItemSelected Option . cleanup For Comparison ( order ItemSelected Option : ĠUpdated Order . Order ItemSelected Option ?): ĠUpdated Order . Order ItemSelected Option Ġ{ Ċ ĉ return Ġcopy ( Ċĉ ĉ values Array Ġ= Ġorder ItemSelected Option ?. values Array , Ċĉ ĉ selections Ġ= Ġorder ItemSelected Option ?. selections ?. map Ġ{ Ġselection Info Ġ-> Ċĉĉ ĉ selection Info . copy () Ċĉ ĉ } Ċ ĉ ) Ċ } Ċ