Examples of saveIt()


Examples of org.javalite.activejdbc.test_models.Person.saveIt()

        a(createdAt).shouldNotBeNull();

        try{Thread.sleep(1000);}catch(Exception e){}//MySQL seems to round off some milliseconds, this sucks.

        p.set("name", "Bart");
        p.saveIt();

        p = Person.findFirst("last_name = ?", "Simpson");
        Timestamp updatedAt = p.getTimestamp("updated_at");

        a(updatedAt).shouldNotBeNull();
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Person.saveIt()

        deleteAndPopulateTables("people");

        Person p = new Person();
        String xml = readResource("/person.xml");
        p.fromXml(xml);
        p.saveIt();
        p.refresh();

        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

        a(p.get("name")).shouldBeEqual("John");
View Full Code Here

Examples of org.javalite.activejdbc.test_models.User.saveIt()

        User user = new User();
        user.set("email", "john@doe.net");

        SystemStreamUtil.replaceOut();

        user.saveIt();

        //this is tested manually, for some reason, Maven does something stupid with streams, can't catch them
    }
}
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

    @Test
    public void shouldSetVersionToOneWhenCreatingNewRecord(){
        deleteAndPopulateTable("watermelons");
        Watermelon m = new Watermelon();
        m.set("melon_type", "dark_green");
        m.saveIt();
        Watermelon m1 = Watermelon.findById(1);
        a(m1.get("record_version")).shouldBeEqual(1);
    }

View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

    public void shouldAdvanceVersionWhenRecordIsUpdated(){

        deleteAndPopulateTable("watermelons");
        Watermelon m = new Watermelon();
        m.set("melon_type", "dark_green");
        m.saveIt();

        m = Watermelon.findById(1);
        m.set("melon_type", "red").saveIt();
        a(m.get("record_version")).shouldBeEqual(2);// this will ensure that the value is updated in the model itself
        m = Watermelon.findById(1);
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

    @Test(expected = StaleModelException.class)
    public void shouldThrowExceptionWhenVersionCollisionHappens(){
        deleteAndPopulateTable("watermelons");
        Watermelon m = new Watermelon();
        m.set("melon_type", "dark_green");
        m.saveIt();

        Watermelon m1 = Watermelon.findById(1);
        Watermelon m2 = Watermelon.findById(1);

        m1.set("melon_type", "red");
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

        m1.set("melon_type", "red");
        m1.saveIt();

        m2.set("melon_type", "yellow");
        m2.saveIt()//<<<<================ this will cause the StaleModelException
    }



    @Test
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

    public void should(){
        deleteAndPopulateTable("watermelons");

        Watermelon m = new Watermelon();
        m.set("melon_type", "dark_green");
        m.saveIt();

        m.set("melon_type", "light_green");
        m.saveIt();

        m.set("melon_type", "super_green");
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

        Watermelon m = new Watermelon();
        m.set("melon_type", "dark_green");
        m.saveIt();

        m.set("melon_type", "light_green");
        m.saveIt();

        m.set("melon_type", "super_green");
        m.saveIt();

        m.set("melon_type", "dark_red");
View Full Code Here

Examples of org.javalite.activejdbc.test_models.Watermelon.saveIt()

        m.set("melon_type", "light_green");
        m.saveIt();

        m.set("melon_type", "super_green");
        m.saveIt();

        m.set("melon_type", "dark_red");
        m.saveIt();
    }
}
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.