/* Ċ Ġ* ĠThe ĠMIT ĠLicense Ċ Ġ* ĠĊ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 4 - ĠHigh - Mob ility ĠGmbH Ġ( https :// high - mob ility . com ) Ċ Ġ* ĠĊ Ġ* ĠPermission Ġis Ġhereby Ġgranted , Ġfree Ġof Ġcharge , Ġto Ġany Ġperson Ġobtaining Ġa Ġcopy Ċ Ġ* Ġof Ġthis Ġsoftware Ġand Ġassociated Ġdocumentation Ġfiles Ġ( the Ġ" Software "), Ġto Ġdeal Ċ Ġ* Ġin Ġthe ĠSoftware Ġwithout Ġrestriction , Ġincluding Ġwithout Ġlimitation Ġthe Ġrights Ċ Ġ* Ġto Ġuse , Ġcopy , Ġmodify , Ġmerge , Ġpublish , Ġdistribute , Ġsublicense , Ġand / or Ġsell Ċ Ġ* Ġcopies Ġof Ġthe ĠSoftware , Ġand Ġto Ġpermit Ġpersons Ġto Ġwhom Ġthe ĠSoftware Ġis Ċ Ġ* Ġfurnished Ġto Ġdo Ġso , Ġsubject Ġto Ġthe Ġfollowing Ġconditions : Ċ Ġ* ĠĊ Ġ* ĠThe Ġabove Ġcopyright Ġnotice Ġand Ġthis Ġpermission Ġnotice Ġshall Ġbe Ġincluded Ġin Ċ Ġ* Ġall Ġcopies Ġor Ġsubstantial Ġportions Ġof Ġthe ĠSoftware . Ċ Ġ* ĠĊ Ġ* ĠTHE ĠSOFTWARE ĠIS ĠPROVIDED Ġ" AS ĠIS ", ĠWITHOUT ĠWARRANTY ĠOF ĠANY ĠKIND , ĠEXPRESS ĠOR Ċ Ġ* ĠIMPLIED , ĠINCLUDING ĠBUT ĠNOT ĠLIMITED ĠTO ĠTHE ĠWARRANTIES ĠOF ĠMERCHANTABILITY , Ċ Ġ* ĠFITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE ĠAND ĠNONINFRINGEMENT . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE Ċ Ġ* ĠAUTHORS ĠOR ĠCOPYRIGHT ĠHOLDERS ĠBE ĠLIABLE ĠFOR ĠANY ĠCLAIM , ĠDAMAGES ĠOR ĠOTHER Ċ Ġ* ĠLIABILITY , ĠWHETHER ĠIN ĠAN ĠACTION ĠOF ĠCONTRACT , ĠTORT ĠOR ĠOTHERWISE , ĠARISING ĠFROM , Ċ Ġ* ĠOUT ĠOF ĠOR ĠIN ĠCONNECTION ĠWITH ĠTHE ĠSOFTWARE ĠOR ĠTHE ĠUSE ĠOR ĠOTHER ĠDEALINGS ĠIN Ċ Ġ* ĠTHE ĠSOFTWARE . Ċ Ġ*/ Ċ package Ġcom . high mob ility . auto api Ċ Ċ import Ġcom . high mob ility . auto api . property . Property Ċ import Ġcom . high mob ility . auto api . value .* Ċ import Ġcom . high mob ility . value . Bytes Ċ Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ import Ġorg . junit . jupiter . api . Assertions . assertTrue Ċ Ċ class ĠK Do ors Test Ġ: ĠBaseTest () Ġ{ ĊĠĠĠ Ġval Ġbytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 1 " Ġ+ ĠĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 2 0 0 0 5 0 1 0 0 0 2 0 0 0 1 " Ġ+ Ġ Ġ// ĠFront Ġleft Ġdoor Ġis Ġlocked Ġinside ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 2 0 0 0 5 0 1 0 0 0 2 0 1 0 0 " Ġ+ Ġ Ġ// ĠFront Ġright Ġdoor Ġis Ġun locked Ġinside ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 2 0 0 0 5 0 1 0 0 0 2 0 2 0 0 " Ġ+ Ġ Ġ// ĠRe ar Ġright Ġdoor Ġis Ġun locked Ġinside ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 2 0 0 0 5 0 1 0 0 0 2 0 3 0 0 " Ġ+ Ġ Ġ// ĠRe ar Ġleft Ġdoor Ġis Ġun locked Ġinside ĊĠ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ĠDo ors Ġare Ġlocked Ġinside ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 6 0 0 0 4 0 1 0 0 0 1 0 0 " Ġ// ĠDo ors Ġare Ġun locked ĊĠĠĠ Ġ) ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest State () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= ĠCommand Resolver . resolve ( bytes ) ĊĠĠĠĠĠĠĠ Ġtest State ( command Ġas ĠDo ors . State ) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Builder () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠDo ors . State . Builder () ĊĠĠĠĠĠĠĠ Ġbuilder . add Inside Lock ( Property ( Lock ( Location . FRONT _ LEFT , ĠLock State . LOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Inside Lock ( Property ( Lock ( Location . FRONT _ RIGHT , ĠLock State . UNLOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Inside Lock ( Property ( Lock ( Location . RE AR _ RIGHT , ĠLock State . UNLOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Inside Lock ( Property ( Lock ( Location . RE AR _ LEFT , ĠLock State . UNLOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Lock ( Property ( Lock ( Location . FRONT _ LEFT , ĠLock State . UNLOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Lock ( Property ( Lock ( Location . FRONT _ RIGHT , ĠLock State . UNLOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Lock ( Property ( Lock ( Location . RE AR _ RIGHT , ĠLock State . LOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Lock ( Property ( Lock ( Location . RE AR _ LEFT , ĠLock State . LOCK ED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Position ( Property ( Door Position ( Door Position . Location . FRONT _ LEFT , ĠPosition . OPEN ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Position ( Property ( Door Position ( Door Position . Location . FRONT _ RIGHT , ĠPosition . CLOSED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Position ( Property ( Door Position ( Door Position . Location . RE AR _ RIGHT , ĠPosition . CLOSED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Position ( Property ( Door Position ( Door Position . Location . RE AR _ LEFT , ĠPosition . CLOSED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . add Position ( Property ( Door Position ( Door Position . Location . ALL , ĠPosition . CLOSED ))) ĊĠĠĠĠĠĠĠ Ġbuilder . set Inside Locks State ( Property ( Lock State . LOCK ED )) ĊĠĠĠĠĠĠĠ Ġbuilder . set Locks State ( Property ( Lock State . UNLOCK ED )) ĊĠĠĠĠĠĠĠ Ġtest State ( builder . build ()) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġprivate Ġfun Ġtest State ( state : ĠDo ors . State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( bytes The Same ( state , Ġbytes )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 0 ]. value ?. location Ġ== ĠLocation . FRONT _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 0 ]. value ?. lock State Ġ== ĠLock State . LOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 1 ]. value ?. location Ġ== ĠLocation . FRONT _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 1 ]. value ?. lock State Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 2 ]. value ?. location Ġ== ĠLocation . RE AR _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 2 ]. value ?. lock State Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 3 ]. value ?. location Ġ== ĠLocation . RE AR _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks [ 3 ]. value ?. lock State Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 0 ]. value ?. location Ġ== ĠLocation . FRONT _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 0 ]. value ?. lock State Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 1 ]. value ?. location Ġ== ĠLocation . FRONT _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 1 ]. value ?. lock State Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 2 ]. value ?. location Ġ== ĠLocation . RE AR _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 2 ]. value ?. lock State Ġ== ĠLock State . LOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 3 ]. value ?. location Ġ== ĠLocation . RE AR _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks [ 3 ]. value ?. lock State Ġ== ĠLock State . LOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 0 ]. value ?. location Ġ== ĠDoor Position . Location . FRONT _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 0 ]. value ?. position Ġ== ĠPosition . OPEN ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 1 ]. value ?. location Ġ== ĠDoor Position . Location . FRONT _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 1 ]. value ?. position Ġ== ĠPosition . CLOSED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 2 ]. value ?. location Ġ== ĠDoor Position . Location . RE AR _ RIGHT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 2 ]. value ?. position Ġ== ĠPosition . CLOSED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 3 ]. value ?. location Ġ== ĠDoor Position . Location . RE AR _ LEFT ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 3 ]. value ?. position Ġ== ĠPosition . CLOSED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 4 ]. value ?. location Ġ== ĠDoor Position . Location . ALL ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . positions [ 4 ]. value ?. position Ġ== ĠPosition . CLOSED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . inside Locks State . value Ġ== ĠLock State . LOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( state . locks State . value Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet State () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdefault Getter Bytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġdefault Getter Ġ= ĠDo ors . GetState () ĊĠĠĠĠĠĠĠ ĠassertTrue ( default Getter Ġ== Ġdefault Getter Bytes ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( default Getter . getProperty Identifiers (). isEmpty ()) ĊĠĠĠĠĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġproperty Getter Bytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 0 0 2 0 3 0 4 0 5 0 6 ") ĊĠĠĠĠĠĠĠ Ġval Ġproperty Getter Ġ= ĠDo ors . GetState ( 0 x 0 2 , Ġ 0 x 0 3 , Ġ 0 x 0 4 , Ġ 0 x 0 5 , Ġ 0 x 0 6 ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( property Getter Ġ== Ġproperty Getter Bytes ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( property Getter . getProperty Identifiers () Ġ== ĠBytes (" 0 2 0 3 0 4 0 5 0 6 ")) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet State Availability All () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġcreated Ġ= ĠDo ors . GetState Availability () ĊĠĠĠĠĠĠĠ ĠassertTrue ( created . identifier Ġ== ĠIdentifier . DO ORS ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( created . type Ġ== ĠType . GET _ AVAIL ABILITY ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( created . getProperty Identifiers (). isEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( created Ġ== Ġbytes ) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġset Environment ( Command Resolver . Environment . VE H IC LE ) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġresolved Ġ= ĠCommand Resolver . resolve ( bytes ) Ġas ĠDo ors . GetState Availability ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . identifier Ġ== ĠIdentifier . DO ORS ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . type Ġ== ĠType . GET _ AVAIL ABILITY ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . getProperty Identifiers (). isEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved Ġ== Ġbytes ) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet State Availability Some () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġidentifier Bytes Ġ= ĠBytes (" 0 2 0 3 0 4 0 5 0 6 ") ĊĠĠĠĠĠĠĠ Ġval Ġall Bytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 2 " Ġ+ Ġidentifier Bytes ) ĊĠĠĠĠĠĠĠ Ġval Ġconstructed Ġ= ĠDo ors . GetState Availability ( identifier Bytes ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( construct ed . identifier Ġ== ĠIdentifier . DO ORS ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( construct ed . type Ġ== ĠType . GET _ AVAIL ABILITY ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( construct ed . getProperty Identifiers () Ġ== Ġidentifier Bytes ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( construct ed Ġ== Ġall Bytes ) ĊĠĠĠĠĠĠĠ Ġval Ġsecond Construct ed Ġ= ĠDo ors . GetState Availability ( 0 x 0 2 , Ġ 0 x 0 3 , Ġ 0 x 0 4 , Ġ 0 x 0 5 , Ġ 0 x 0 6 ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( construct ed Ġ== Ġsecond Construct ed ) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġset Environment ( Command Resolver . Environment . VE H IC LE ) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġresolved Ġ= ĠCommand Resolver . resolve ( all Bytes ) Ġas ĠDo ors . GetState Availability ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . identifier Ġ== ĠIdentifier . DO ORS ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . type Ġ== ĠType . GET _ AVAIL ABILITY ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . getProperty Identifiers () Ġ== Ġidentifier Bytes ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved Ġ== Ġall Bytes ) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlock Unlock Do ors () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbytes Ġ= ĠBytes ( COMMAND _ HEADER Ġ+ Ġ" 0 0 2 0 0 1 " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 6 0 0 0 4 0 1 0 0 0 1 0 0 ") ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġconstructed Ġ= ĠDo ors . Lock Unlock Do ors ( Lock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( bytes The Same ( construct ed , Ġbytes )) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġset Environment ( Command Resolver . Environment . VE H IC LE ) ĊĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġresolved Ġ= ĠCommand Resolver . resolve ( bytes ) Ġas ĠDo ors . Lock Unlock Do ors ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved . locks State . value Ġ== ĠLock State . UNLOCK ED ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( resolved Ġ== Ġbytes ) ĊĠĠĠ Ġ} Ċ }