Package models

Examples of models.FileMove


    DateTime now = DateTime.now();
        Date d2 = now.toDateMidnight().toDate();
        Date d1 = now.minusDays(1).toDateMidnight().toDate()
       
    //create a file move for a user 1
    FileMove mv1 = new FileMove(key1(), "foo", "bar", false);
    mv1.when = d2;
   
    //create a file move for a user 2 that's too old to be included
    FileMove mv2 = new FileMove(key2(), "foo", "bar", false);
    mv2.when = now.minusDays(3).toDate();
    FileMove.save(Arrays.asList(mv1, mv2));

    int count = UserStatsUtil.countUniqueFileMoveUsers("when", d1, FileMove.all());
    assertEquals(1, count);

    //create a file move for user 2
    FileMove mv3 = new FileMove(key2(), "rick", "james", false);
    FileMove.save(Arrays.asList(mv3));

    int newCount = UserStatsUtil.countUniqueFileMoveUsers("when", d1, FileMove.all());
    assertEquals(2, newCount);
  }
View Full Code Here


        return User.key(AccountType.DROPBOX, 2L);
    }

    @Test
    public void testDml() throws Exception {
        FileMove mv1 = new FileMove(key1(), "foo", "bar", true);
        FileMove mv2 = new FileMove(key2(), "tom", "jerry", false);
        FileMove.save(Arrays.asList(mv1, mv2));
       
        List<FileMove> fileMoves = FileMove.findByOwner(key1(), 2);
        FileMove mv = Iterables.getFirst(fileMoves, null);
        assertEquals("foo", mv.fromFile);
        assertEquals("bar", mv.toDir);
        assertTrue(mv.hasCollision);

        fileMoves = FileMove.findByOwner(key2(), 2);
View Full Code Here

        Date lastDate = null;

        for (int i = 0; i< count; i++) {
            Date when = new DateTime(now).plusDays(i).toDate();
            lastDate = when;
            FileMove m = new FileMove(key1(), "from" + i, "/dest/to" + i, (i % 2) == 0);
            m.when = when;
            moves.add(m);
        }

        FileMove.save(moves);
View Full Code Here

        int count = 10;

        // Create moves in increasing chronological order
        for (int i = 0; i< count; i++) {
            Date when = DateTime.now().plusDays(i).toDate();
            FileMove m = new FileMove(key1(), "from" + i, "/dest/to" + i, (i % 2) == 0);
            m.when = when;
            moves.add(m);
        }
        FileMove.save(moves);
View Full Code Here

    /**
     * Verify that FileMoves are queriable via ancestor.
     */
    @Test
    public void testGetByParent() {
        FileMove mv1 = new FileMove(key1(), "foo", "bar", true);
        FileMove mv2 = new FileMove(key1(), "tom", "jerry", false);
        FileMove.save(Arrays.asList(mv1, mv2));
        Query q = new Query(FileMove.KIND).setAncestor(key1());
        assertEquals(2, Iterables.size(DatastoreServiceFactory.getDatastoreService().prepare(q).asIterable()));
    }
View Full Code Here

     * Ensure that the successful column
     * gets migrated properly
     */
    @Test
    public void testSuccess() {
        FileMove mv = new FileMove(key1(), "foo", "bar", true);
        mv.id = 1L;
        FileMove.save(Arrays.asList(mv));
       
        // ignore successful if hasCollision is set
        setSuccess(mv, true, true);
View Full Code Here

                        if (hasCollision && (resolvedName == null)) {
                            Logger.error("Cannot move file '%s' to '%s' after %d tries. Skipping.",
                                       file, r.dest, MAX_TRIES);
                        }

                        fileMoves.add(new FileMove(user.getKey(), base, r.dest, hasCollision, resolvedName));
                        break;
                    }
                }
            }
View Full Code Here

TOP

Related Classes of models.FileMove

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.