public void testDumpList() { ListBean1 bean = new ListBean1(); List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); bean.setChildren(list); List<Developer> developers = new ArrayList<Developer>(); developers.add(new Developer("Fred", "creator")); developers.add(new Developer("John", "committer")); bean.setDevelopers(developers); Yaml yaml = new Yaml(); String output = yaml.dumpAsMap(bean); // System.out.println(output); String etalon = Util.getLocalResource("examples/list-bean-1.yaml"); assertEquals(etalon, output); }
public void testLoadList() { String output = Util.getLocalResource("examples/list-bean-1.yaml"); // System.out.println(output); Yaml beanLoader = new Yaml(); ListBean1 parsed = beanLoader.loadAs(output, ListBean1.class); assertNotNull(parsed); List<String> list2 = parsed.getChildren(); assertEquals(2, list2.size()); assertEquals("aaa", list2.get(0)); assertEquals("bbb", list2.get(1)); List<Developer> developers = parsed.getDevelopers(); assertEquals(2, developers.size()); assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass()); Developer fred = developers.get(0); assertEquals("Fred", fred.getName()); assertEquals("creator", fred.getRole()); }