package Ġio . gitlab . art urb os ch . de te kt . api Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Exception OfType Ċ import Ġorg . assertj . core . api . Assertions . fail Ċ import Ġorg . jetbrains . spe k . api . Spe k Ċ import Ġorg . jetbrains . spe k . api . dsl . describe Ċ import Ġorg . jetbrains . spe k . api . dsl . it Ċ import Ġjava . nio . file . Paths Ċ Ċ /** Ċ Ġ* Ġ@ author ĠArt ur ĠB os ch Ċ Ġ*/ Ċ class ĠConfig Spec Ġ: ĠSpe k ({ ĊĊ ĉ describe (" load Ġyaml Ġconfig ") Ġ{ Ċĉ ĉ val Ġconfig Path Ġ= ĠPaths . get ( resource ("/ de te kt . yml ")) Ċĉ ĉ val Ġconfig Ġ= ĠYaml Config . load ( config Path ) ĊĊĉ ĉ it (" should Ġcreate Ġa Ġsub Ġconfig ") Ġ{ Ċĉĉ ĉ try Ġ{ Ċĉĉĉ ĉ val Ġsub Config Ġ= Ġconfig . sub Config (" style ") Ċĉĉĉ ĉ assertThat ( sub Config . value OrDefault (" Wildcard Import ", Ġmap Of < String , ĠAny >() )). isNotEmpty Ċĉĉĉ ĉ assertThat ( sub Config . value OrDefault (" Wildcard Import ", Ġmap Of < String , ĠAny >()) [" active "]. toString ()). isEqualTo (" true ") Ċĉĉĉ ĉ assertThat ( sub Config . value OrDefault (" Wildcard Import ", Ġmap Of < String , ĠAny >()) [" active "] Ġas ĠBoolean ). isTrue () Ċĉĉĉ ĉ assertThat ( sub Config . value OrDefault (" NotFound ", Ġmap Of < String , ĠAny >() )). isEmpty () Ċĉĉĉ ĉ assertThat ( sub Config . value OrDefault (" NotFound ", Ġ" ")). isEmpty () Ċĉĉ ĉ } Ġcatch Ġ( ignored : ĠConfig . Invalid Configuration Error ) Ġ{ Ċĉĉĉ ĉ fail (" Creating Ġa Ġsub Ġconfig Ġshould Ġwork Ġfor Ġtest Ġresources Ġconfig !") Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ it (" should Ġcreate Ġa Ġsub Ġsub Ġconfig ") Ġ{ Ċĉĉ ĉ try Ġ{ Ċĉĉĉ ĉ val Ġsub Config Ġ= Ġconfig . sub Config (" style ") Ċĉĉĉ ĉ val Ġsub Sub Config Ġ= Ġsub Config . sub Config (" Wildcard Import ") Ċĉĉĉ ĉ assertThat ( sub Sub Config . value OrDefault (" active ", Ġfalse )). isTrue () Ċĉĉĉ ĉ assertThat ( sub Sub Config . value OrDefault (" NotFound ", Ġtrue )). isTrue () Ċĉĉ ĉ } Ġcatch Ġ( ignored : ĠConfig . Invalid Configuration Error ) Ġ{ Ċĉĉĉ ĉ fail (" Creating Ġa Ġsub Ġconfig Ġshould Ġwork Ġfor Ġtest Ġresources Ġconfig !") Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ it (" tests Ġwrong Ġsub Ġconfig Ġconversion ") Ġ{ Ċĉĉ ĉ assertThat Exception OfType ( Class CastException :: class . java ). is Thrown By Ġ{ Ċĉĉĉ ĉ @ Suppress (" UNUSED _ VARIABLE ") Ċĉĉĉ ĉ val Ġignored Ġ= Ġconfig . value OrDefault (" style ", Ġ"") Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ describe (" loading Ġempty Ġconfigurations ") Ġ{ ĊĊĉ ĉ it (" empty Ġyaml Ġfile Ġis Ġequivalent Ġto Ġempty Ġconfig ") Ġ{ Ċĉĉ ĉ Yaml Config . load Resource ( java Class . getResource ("/ empty . yml ")) Ċĉ ĉ } ĊĊĉ ĉ it (" single Ġitem Ġin Ġyaml Ġfile Ġis Ġvalid ") Ġ{ Ċĉĉ ĉ Yaml Config . load Resource ( java Class . getResource ("/ one item . yml ")) Ċĉ ĉ } Ċ ĉ } Ċ }) Ċ