Package org.yaml.snakeyaml

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


    public void testOwnBigDecimal() {
        DogFoodBean input = new DogFoodBean();
        input.setDecimal(new BigDecimal("5"));
        Yaml yaml = new Yaml();
        String text = yaml.dump(input);
        // System.out.println(text);
        assertEquals("!!org.yaml.snakeyaml.issues.issue40.DogFoodBean {decimal: !!float '5'}\n",
                text);
        DogFoodBean output = (DogFoodBean) yaml.load(text);
        assertEquals(output.getDecimal(), input.getDecimal());
View Full Code Here


        mother.setBankAccountOwner(father);
        DumperOptions options = new DumperOptions();
        options.setPrettyFlow(true);
        options.setDefaultFlowStyle(FlowStyle.FLOW);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(father);
        String etalon = Util.getLocalResource("recursive/no-children-1-pretty.yaml");
        assertEquals(etalon, output);
        //
        Human father2 = (Human) yaml.load(output);
        assertNotNull(father2);
View Full Code Here

    public void testBigDecimalPrecision() {
        DogFoodBean input = new DogFoodBean();
        input.setDecimal(new BigDecimal("5.123"));
        Yaml yaml = new Yaml();
        String text = yaml.dump(input);
        // System.out.println(text);
        assertEquals("!!org.yaml.snakeyaml.issues.issue40.DogFoodBean {decimal: 5.123}\n", text);
        DogFoodBean output = (DogFoodBean) yaml.load(text);
        assertEquals(input.getDecimal(), output.getDecimal());
    }
View Full Code Here

        //
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.FLOW);
        options.setPrettyFlow(true);
        Yaml beanDumper = new Yaml(options);
        String output = beanDumper.dump(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children-pretty.yaml");
        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
View Full Code Here

        assertEquals(input.getDecimal(), output.getDecimal());
    }

    public void testBigDecimal1() {
        Yaml yaml = new Yaml();
        String text = yaml.dump(new BigDecimal("5"));
        assertEquals("!!float '5'\n", text);
    }

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

        TypeDescription humanDescription = new TypeDescription(Human2.class);
        humanDescription.putMapPropertyType("children", Human2.class, String.class);
        constructor.addTypeDescription(humanDescription);

        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children-2.yaml");
        assertEquals(etalon, output);
        //
        Human2 son2 = (Human2) yaml.load(output);
View Full Code Here

        TypeDescription Human3Description = new TypeDescription(Human3.class);
        Human3Description.putListPropertyType("children", Human3.class);
        constructor.addTypeDescription(Human3Description);

        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children-3.yaml");
        assertEquals(etalon, output);
        //
        Human3 son2 = (Human3) yaml.load(output);
View Full Code Here

        assertEquals("!!float '5'\n", text);
    }

    public void testBigDecimal2() {
        Yaml yaml = new Yaml();
        String text = yaml.dump(new BigDecimal("5.123"));
        assertEquals("5.123\n", text);
    }
}
View Full Code Here

public class PrattleRepresenterTest extends TestCase {
    public void test() {
        Yaml yaml = new Yaml();
        Person person = new Person("Alan", "Gutierrez", 9);
        String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
        assertEquals(etalon, yaml.dump(person));
        assertEquals(etalon, yaml.dump(person));
    }

    public void test2beans() {
        DumperOptions options = new DumperOptions();
View Full Code Here

    public void test() {
        Yaml yaml = new Yaml();
        Person person = new Person("Alan", "Gutierrez", 9);
        String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
        assertEquals(etalon, yaml.dump(person));
        assertEquals(etalon, yaml.dump(person));
    }

    public void test2beans() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
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.