Package models

Examples of models.Account


        new Account("xyz", "xyz@1.com", "au", "it", 32, 89).save();
    }

    @Test
    public void testUpdateFirst() {
        Account acc0 = Account.o().inc("age").updateFirst("region", "au");
        assertEquals(30, acc0.age);
        Account acc = Account.q().filter("login", "abc").get();
        assertEquals(acc0, acc);
        assertEquals(30, acc.age);
        acc = Account.q().filter("login", "xyz").get();
        assertEquals(32, acc.age);
    }
View Full Code Here


    }

    @Test
    public void testUpdateAll() {
        Account.o().inc("age").update("region", "au");
        Account acc = Account.q().filter("login", "abc").get();
        assertEquals(30, acc.age);
        acc = Account.q().filter("login", "xyz").get();
        assertEquals(33, acc.age);
    }
View Full Code Here

        assertEquals(33, acc.age);
    }

    @Test
    public void testUpdateNull() {
        Account acc = Account.o().inc("age").updateFirst(Account.q().filter("region", "cn"));
        assertNull(acc);
    }
View Full Code Here

    }

    @Test
    public void testUpdateSet() {
        Account.o().set("byAgeAndRegion", 100, "cn").updateAll();
        Account acc = Account.q().filter("login", "abc").get();
        assertEquals(100, acc.age);
        assertEquals("cn", acc.region);
        acc = Account.q().filter("login", "xyz").get();
        assertEquals(100, acc.age);
        assertEquals("cn", acc.region);
View Full Code Here

    }
   
    @Test
    public void testIncDec() {
        Account.o().inc("age score", 100).updateAll();
        Account acc = Account.q().filter("login", "abc").get();
        assertEquals(129, acc.age);
        assertEquals(177, acc.score);
    }
View Full Code Here

        Account.deleteAll();
    }
   
    @Test
    public void testFind() {
        Account a1 = new Account("a", "a@a.com", "AU", "IT", 50, 80).save();
        Account a2 = new Account("b", "b@b.com", "AU", "IT", 46, 77).save();
       
        List<Account> l0 = Account.find("region department", "AU", "IT").filter("age >", 30).order("age").asList();
        assertEquals(l0.size(), 2);
        a1 = l0.get(0);
        a2 = l0.get(1);
View Full Code Here

        assertTrue(a1.age >= a2.age);
    }
   
    @Test
    public void testFindNull() {
        Account a1 = new Account("a", "a@a.com", "AU", "IT", 50, 80).save();
        Account a2 = new Account("b", "b@b.com", "AU", null, 46, 77).save();
       
        List<Account> l0 = Account.q().findBy("department", null).asList();
        assertTrue(l0.size() == 1);
       
        assertEquals(l0.get(0).login, "b");
View Full Code Here

        this.statusId = statusId;
    }

    static public void fetchForAccount(Long accountId) {

        Account account = Account.findById(accountId);
        if (account != null) {

            // FIXME CLA simple API quota management
            boolean fetch = true;
            if (account.lastFetched != null) {
                DateTime lastFetch = new DateTime(account.lastFetched);
                int delay = Minutes.minutesBetween(lastFetch, new DateTime()).getMinutes();
                if (delay < FETCH_PERIOD) {
                    fetch = false;
                    Logger.info("Fetch timeline for %s on %s : already done %d minutes ago (< %d configured period)", account.member, account.provider, delay, FETCH_PERIOD);
                }
            }
            if (fetch) {
                Logger.info("Fetch timeline for %s on %s", account.member, account.provider);
                List<StatusActivity> statuses = account.fetchActivities();
                if (!statuses.isEmpty()) {
                    // Memorizing most recent id
                    Collections.sort(statuses);
                    account.lastStatusId = statuses.get(0).statusId;
                    account.save();

                    account.enhance(statuses);
                }

                for (StatusActivity status : statuses) {
                    boolean add = true;
                    // Google hack : workaround for lack of "since" parameter in API, returning already fetched statuses.
View Full Code Here

TOP

Related Classes of models.Account

Copyright © 2018 www.massapicom. 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.