package Ġcom . github . ker ub istan . ker ub . hyper visor . k vm Ċ Ċ import Ġcom . github . ker ub istan . ker ub . model . Host Ċ import Ġcom . github . ker ub istan . ker ub . model . VirtualMachine Ċ import Ġcom . github . ker ub istan . ker ub . utils . getLogger Ċ import Ġorg . hamcrest . Core Matchers Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Test Ċ import Ġorg . xml . sax . Input Source Ċ import Ġjava . io . String Reader Ċ import Ġjava . math . BigInteger Ċ import Ġjava . util . UUID Ċ import Ġjavax . xml . parsers . Document BuilderFactory Ċ import Ġjavax . xml . xpath . XPath Factory Ċ import Ġcom . github . ker ub istan . ker ub . model . Range Ġas Ġserial izable Range Ċ Ċ class ĠUtils Test Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ private Ġval Ġlogger Ġ= Ġget Logger () Ċ ĉ } ĊĊĊ ĉ @ Test Ġfun Ġvm Definition to Xml () Ġ{ Ċĉ ĉ val Ġvm Ġ= ĠVirtual Machine ( Ċĉĉĉ ĉ id Ġ= ĠUUID . randomUUID (), Ċĉĉĉ ĉ nr Of C pus Ġ= Ġ 2 , Ċĉĉĉ ĉ expect ations Ġ= ĠlistOf (), Ċĉĉĉ ĉ memory Ġ= Ġserial izable Range ( BigInteger (" 1 0 2 4 "), ĠBigInteger (" 2 0 4 8 ")), Ċĉĉĉ ĉ name Ġ= Ġ" test - vm </ ", Ċĉĉĉ ĉ virtual Storage Links Ġ= ĠlistOf () Ċĉ ĉ ) ĊĊĉ ĉ val Ġhost Ġ= ĠHost ( Ċĉĉĉ ĉ id Ġ= ĠUUID . randomUUID (), Ċĉĉĉ ĉ dedicated Ġ= Ġtrue , Ċĉĉĉ ĉ address Ġ= Ġ" host 1 . example . com ", Ċĉĉĉ ĉ publicKey Ġ= Ġ"" Ċĉ ĉ ) ĊĊĉ ĉ val Ġlib virt Xml Ġ= Ġvm Definition To Xml ( vm , ĠlistOf (), Ġ"", Ġtarget Host Ġ= Ġhost ) ĊĊĉ ĉ val Ġdom Ġ= ĠDocument BuilderFactory . newInstance (). new Document Builder (). parse ( Input Source ( String Reader ( lib virt Xml ))) Ċĉ ĉ val Ġx Path Ġ= ĠXPath Factory . newInstance (). new XPath () ĊĊĉ ĉ logger . info (" generated Ġlib virt Ġxml :\ n {}", Ġlib virt Xml ) Ċĉ ĉ Assert . assertThat ( UUID . fromString ( x Path . evaluate (" domain / uuid / text ()", Ġdom )), ĠCore Matchers .` is `( vm . id )) Ċĉ ĉ // domain Ġname Ġis Ġfrom Ġid , Ġsince Ġit Ġneeds Ġto Ġbe Ġcluster - wide Ġunique Ċĉ ĉ Assert . assertThat ( UUID . fromString ( x Path . evaluate (" domain / name / text ()", Ġdom )), ĠCore Matchers .` is `( vm . id )) Ċĉ ĉ Assert . assertThat ( x Path . evaluate (" domain / memory / text ()", Ġdom ), ĠCore Matchers .` is `( vm . memory . min . toString ())) ĊĊ ĉ } Ċ }