Examples of dumpAsMap()


Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

    public void testGenericMap() {
        Yaml yaml = new Yaml();
        MapProvider<String, Integer> listProvider = new MapProvider<String, Integer>();
        listProvider.getMap().put("foo", 17);
        listProvider.getMap().put("bar", 19);
        String s = yaml.dumpAsMap(listProvider);
        // System.out.println(s);
        assertEquals("map:\n  foo: 17\n  bar: 19\n", s);
        // parse
        Yaml loader = new Yaml();
        MapProvider<String, Integer> listProvider2 = loader.loadAs(s, MapProvider.class);
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        listProvider.getMap().put("foo", foo);
        Bean bar = new Bean();
        bar.setName("bar");
        bar.setNumber(3);
        listProvider.getMap().put("bar", bar);
        String s = yaml.dumpAsMap(listProvider);
        // System.out.println(s);
        String etalon = Util.getLocalResource("issues/issue61-2.yaml");
        assertEquals(etalon, s);
        // parse
        Yaml loader = new Yaml();
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        triangle.setName("Triangle25");
        TriangleBean bean = new TriangleBean();
        bean.setShape(triangle);
        bean.setName("Bean25");
        Yaml beanDumper = new Yaml();
        String output = beanDumper.dumpAsMap(bean);
        assertEquals(
                "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n  name: Triangle25\n",
                output);
        Yaml beanLoader = new Yaml();
        TriangleBean loadedBean = beanLoader.loadAs(output, TriangleBean.class);
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        mother.setBirthPlace("Saint-Petersburg");
        father.setPartner(mother);
        mother.setPartner(father);
        mother.setBankAccountOwner(father);
        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(father);
        String etalon = Util.getLocalResource("recursive/generics/no-children-2.yaml");
        assertEquals(etalon, output);
        //
        Yaml loader = new Yaml();
        HumanGen father2 = (HumanGen) loader.loadAs(etalon, HumanGen.class);
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        DataSources ds = new DataSources();
        ds.setDataSources(dataSources);

        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(ds);

        String etalon = Util.getLocalResource("javabeans/issue10-2.yaml");
        assertEquals(etalon.trim(), output.trim());
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        DataSources ds = new DataSources();
        ds.setDataSources(dataSources);

        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(ds);

        String etalon = Util.getLocalResource("javabeans/issue10-3.yaml");
        assertEquals(etalon.trim(), output.trim());
        // load
        Yaml beanLoader = new Yaml();
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

public class SkipJavaBeanPropertyTest extends TestCase {
    public void testWithNull() {
        Bean bean = new Bean();
        bean.setValue(3);
        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("name: null\nvalue: 3\n", output);
    }

    public void testWithoutNull() {
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

    public void testWithoutNull() {
        Bean bean = new Bean();
        bean.setValue(5);
        Yaml yaml = new Yaml(new MyRepresenter());
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("value: 5\n", output);
    }

    private class MyRepresenter extends Representer {
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        bean.setName("Bahrack");
        bean.setAge(-47);
        JavaBeanWithStaticState.setType("Type3");
        JavaBeanWithStaticState.color = "Violet";
        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(new Wrapper(bean));
        // System.out.println(output);
        assertEquals("age: -47\ncolor: Violet\nname: Bahrack\ntype: Type3\n", output);
        // parse back to instance
        Yaml loader = new Yaml();
        Wrapper wrapper = loader.loadAs(output, Wrapper.class);
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.dumpAsMap()

        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);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.