Package org.javalite.activejdbc.test_models

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


        long createdAt = new GregorianCalendar(2014, 8, 22).getTimeInMillis();
        long updatedAt = new GregorianCalendar(2014, 8, 23).getTimeInMillis();

        p.set("created_at", new Timestamp(createdAt));
        p.set("updated_at", new Timestamp(updatedAt));
        p.saveIt();

        p = (Person) Person.findAll().get(0);

        a(p.get("created_at")).shouldBeEqual(new Timestamp(createdAt));
        a(p.get("updated_at")).shouldBeEqual(new Timestamp(updatedAt));
View Full Code Here


        p.manageTime(false);

        p.set("name", "igor");
        p.set("created_at", new Timestamp(createdAt));
        p.set("updated_at", new Timestamp(updatedAt));
        p.saveIt();

        Person.findAll().dump();

        p = (Person) Person.findAll().get(0);
View Full Code Here

   
    @Test
    public void shouldCreateModel() {

        Person p = Person.create("name", "Sam", "last_name", "Margulis", "dob", "2001-01-07");
        p.saveIt();
        a(p.get("name")).shouldBeEqual("Sam");
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfWrongValuePassed() {
View Full Code Here

    @Test
    public void shouldRefreshCreatedAndUpdatedAttributes() throws InterruptedException {

        Person p = new Person();
        p.set("name", "John", "last_name", "Doe");
        p.saveIt();

        Timestamp createdOrig = p.getTimestamp("created_at");
        Timestamp updatedOrig = p.getTimestamp("updated_at");

        Thread.sleep(500);
View Full Code Here

        Person p = new Person();
        p.set("name", "Lisa");
        p.set("last_name", "Simpson");
        //DOB setter missing
        p.saveIt();

        p  = Person.findFirst("last_name = ?", "Simpson");
        Timestamp createdAt = p.getTimestamp("created_at");
        a(createdAt).shouldNotBeNull();
View Full Code Here

        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

        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

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.