Examples of dumpAsMap()


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

public class VelocityTest extends TestCase {
    public void testNoTemplate() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dumpAsMap(createBean());
        // System.out.println(output);
        assertEquals(Util.getLocalResource("template/etalon1.yaml"), output);
    }

    public void testTemplate1() throws Exception {
View Full Code Here

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

        List<ArrayMember> list = new ArrayList<ArrayMember>(2);
        list.add(new ArrayMember("John", 111));
        list.add(new ArrayMember("Tony", 222));
        bean.setList(list);
        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals(Util.getLocalResource("issues/issue74-array1.txt"), output);
        Yaml beanLoader = new Yaml();
        ArrayBean parsed = beanLoader.loadAs(output, ArrayBean.class);
        // System.out.println(parsed);
View Full Code Here

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

public class ReadOnlyPropertiesTest extends TestCase {
    public void testBean1() {
        IncompleteBean bean = new IncompleteBean();
        bean.setName("lunch");
        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("name: lunch\n", output);
        //
        Yaml loader = new Yaml();
        IncompleteBean parsed = loader.loadAs(output, IncompleteBean.class);
View Full Code Here

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

        IncompleteBean bean = new IncompleteBean();
        bean.setName("lunch");
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("id: 10\nname: lunch\n", output);
        //
        Yaml loader = new Yaml();
        try {
View Full Code Here

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

public class YamlFieldAccessCollectionTest extends TestCase {

    public void testYaml() {
        Blog original = createTestBlog();
        Yaml yamlDumper = constructYamlDumper();
        String serialized = yamlDumper.dumpAsMap(original);
        // System.out.println(serialized);
        assertEquals(Util.getLocalResource("issues/issue55_1.txt"), serialized);
        Yaml blogLoader = new Yaml();
        blogLoader.setBeanAccess(BeanAccess.FIELD);
        Blog rehydrated = blogLoader.loadAs(serialized, Blog.class);
View Full Code Here

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

        final Foo foo = new Foo();
        foo.bar.add(1);
        foo.bar.add("A");
        foo.bar.add(3.14);
        Yaml yaml = new Yaml();
        assertEquals("bar:\n- 1\n- A\n- 3.14\n", yaml.dumpAsMap(foo));
    }

    public void testNullListElement() {
        final Foo foo = new Foo();
View Full Code Here

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

        foo.bar.add(1);
        foo.bar.add("A");
        foo.bar.add(null);
        foo.bar.add(3.14);
        Yaml yaml = new Yaml();
        assertEquals("bar:\n- 1\n- A\n- null\n- 3.14\n", yaml.dumpAsMap(foo));
        assertEquals(
                "!!org.yaml.snakeyaml.issues.issue58.NullValueDumperTest$Foo\nbar: [1, A, null, 3.14]\n",
                new Yaml().dump(foo));
    }
}
View Full Code Here

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

        children.add(daughter);
        father.setChildren(children);
        mother.setChildren(children);
        //
        Yaml beanDumper = new Yaml();
        String output = beanDumper.dumpAsMap(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children.yaml");
        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
View Full Code Here

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

    public void testBigDecimalNoRootTag() {
        DogFoodBean input = new DogFoodBean();
        input.setDecimal(new BigDecimal("5.123"));
        Yaml yaml = new Yaml();
        String text = yaml.dumpAsMap(input);
        // System.out.println(text);
        assertEquals("decimal: 5.123\n", text);
        Yaml loader = new Yaml();
        DogFoodBean output = loader.loadAs(text, DogFoodBean.class);
        assertEquals(input.getDecimal(), output.getDecimal());
View Full Code Here

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

            DataBean bean = new DataBean();
            bean.setId("id" + i);
            bean.setList(list);
            bean.setMap(map);
            beans.add(bean);
            String ooo = yaml.dumpAsMap(bean);
            String[] lines = ooo.split("\n");
            builder.append("-\n");
            for (int j = 0; j < lines.length; j++) {
                builder.append("  ");
                builder.append(lines[j]);
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.