public void dumpRacksToFile( List< Rack > rackList, String filePath ) { if ( rackList != null ) { Yaml yaml = new Yaml( new CompactConstructor() ); try { FileWriter fw = new FileWriter( filePath ); yaml.dump( rackList, fw ); fw.close(); } catch ( Exception e ) { e.printStackTrace(); } } }
@Before public void setUp(){ int[] noOfSlots = { INITIAL_NO_OF_SLOTS,INITIAL_NO_OF_SLOTS }; DevRack devRack = new DevRack(); devRack.dumpRacksToFile( devRack.create(rackNames, noOfSlots),yamlFilePath+ System.getProperty( "file.separator" ) + RackService.RACK_CONFIG ); rackService.refresh(); Yaml yaml = new Yaml( new CompactConstructor() ); try { FileWriter fw = new FileWriter( yamlFilePath+ System.getProperty( "file.separator" ) + SettopSlotConfigServiceImpl.SETTOP_TYPE_MAPPING_CONFIG ); yaml.dump( settopTypes, fw ); fw.close(); } catch ( Exception e ) { e.printStackTrace(); } }
public void testCompact() { Yaml yaml = new Yaml(new CompactConstructor()); BeanData obj = (BeanData) yaml .load("org.yaml.snakeyaml.issues.issue144.BeanData(id): { number: 123.4 }"); assertEquals(123.4f, obj.getNumber()); }