Examples of loadAs()


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

        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());
    }

    public void testBigDecimal1() {
        Yaml yaml = new Yaml();
View Full Code Here

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

        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        Human son2 = beanLoader.loadAs(output, Human.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());

        Human father2 = son2.getFather();
        assertEquals("Father", father2.getName());
View Full Code Here

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

        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        Human son2 = beanLoader.loadAs(output, Human.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());

        Human father2 = son2.getFather();
        assertEquals("Father", father2.getName());
View Full Code Here

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

        String yaml = beanDumper.dumpAsMap(house);
        String etalon = Util.getLocalResource("javabeans/house-dump1.yaml");
        assertEquals(etalon, yaml);
        // load
        Yaml beanLoader = new Yaml();
        House loadedHouse = beanLoader.loadAs(yaml, House.class);
        assertNotNull(loadedHouse);
        assertEquals("Wall Street", loadedHouse.getStreet());
        // dump again
        String yaml3 = beanDumper.dumpAsMap(loadedHouse);
        assertEquals(yaml, yaml3);
View Full Code Here

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

        // load
        TypeDescription description = new TypeDescription(House.class);
        description.putListPropertyType("rooms", Room.class);
        Yaml beanLoader = new Yaml(new Constructor(description));
        House loadedHouse = (House) beanLoader.load(yaml);
        House loadedHouse2 = (House) beanLoader.loadAs(yaml, House.class);
        assertNotNull(loadedHouse);
        assertFalse(loadedHouse == loadedHouse2);
        assertEquals("Wall Street", loadedHouse.getStreet());
        assertEquals(1, loadedHouse.getNumber());
        assertEquals(1, loadedHouse2.getNumber());
View Full Code Here

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

        String yaml = beanDumper.dump(house);
        String etalon = Util.getLocalResource("javabeans/house-dump2.yaml");
        assertEquals(etalon, yaml);
        // load
        Yaml beanLoader = new Yaml();
        House loadedHouse = beanLoader.loadAs(yaml, House.class);
        assertNotNull(loadedHouse);
        assertEquals("Wall Street", loadedHouse.getStreet());
        // dump again
        String yaml3 = beanDumper.dump(loadedHouse);
        assertEquals(yaml, yaml3);
View Full Code Here

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

    /**
     * global tag is correct (but ignored)
     */
    public void testEmptyBean1() {
        Yaml beanLoader = new Yaml();
        EmptyBean bean = beanLoader.loadAs(
                "!!org.yaml.snakeyaml.javabeans.ConstructEmptyBeanTest$EmptyBean {}",
                EmptyBean.class);
        assertNotNull(bean);
        assertNull(bean.getFirstName());
        assertEquals(5, bean.getHatSize());
View Full Code Here

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

    /**
     * global tag is ignored
     */
    public void testEmptyBean2() {
        Yaml beanLoader = new Yaml();
        EmptyBean bean = beanLoader.loadAs("!!Bla-bla-bla {}", EmptyBean.class);
        assertNotNull(bean);
        assertNull(bean.getFirstName());
        assertEquals(5, bean.getHatSize());
    }

View Full Code Here

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

    /**
     * no tag
     */
    public void testEmptyBean3() {
        Yaml beanLoader = new Yaml();
        EmptyBean bean = beanLoader.loadAs("{   }", EmptyBean.class);
        assertNotNull(bean);
        assertNull(bean.getFirstName());
        assertEquals(5, bean.getHatSize());
    }

View Full Code Here

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

    /**
     * empty document
     */
    public void testEmptyBean4() {
        Yaml beanLoader = new Yaml();
        EmptyBean bean = beanLoader.loadAs("", EmptyBean.class);
        assertNull(bean);
    }

    /**
     * local tag is ignored
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.