Package models

Examples of models.User.save()


        user.name = "alex";
        user.photo = newBlob("test/googlelogo.png");
        user.save();

        user.photo = newBlob("test/user.png");
        user.save();
       
        String name = user.getBlobFileName("photo");
        DBObject queryObj = new BasicDBObject("name", name);
        List<GridFSDBFile> list = MorphiaPlugin.gridFs().find(queryObj);
       
View Full Code Here


    public static void uploadImage(File image) {
        notFoundIfNull(image);
        User u = new User();
        u.name = RandomStringUtils.randomAlphabetic(5);
        u.photo = new Blob(image, "image/jpeg");
        u = u.save();

        renderText(u.getId());
    }

    public static void getImage(String id) {
View Full Code Here

    @Test
    public void test() {
        User u0 = new User();
        u0.name = "Foo";
        u0.tag = "sdfu893749";
        u0.save();
       
        User2 u1 = User2.filter("nm", "Foo").get();
        assertNotNull(u1);
        assertEquals(u1.tag, u0.tag);
    }
View Full Code Here

    @Test
    public void createToken() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User newUser = new User("foo@foo.com", "password", "John Doe");
                newUser.save();
               
                assertThat(newUser.id).isNotNull();
               
                String token = newUser.createToken();
               
View Full Code Here

    @Test
    public void testCreate() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user = new User("foo@foo.com", "password", "John Doe");
                user.save();
                assertThat(user.id).isNotNull();
                assertThat(user.getEmailAddress()).isEqualTo("foo@foo.com");
                assertThat(user.fullName).isEqualTo("John Doe");
                assertThat(user.creationDate).isNotNull();
View Full Code Here

    @Test(expected = PersistenceException.class)
    public void testCreateWithDuplicateEmail() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user1 = new User("foo@foo.com", "password", "John Doe");
                user1.save();
                User user2 = new User("foo@foo.com", "password", "John Doe");
                user2.save();
            }
        });
    }
View Full Code Here

        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user1 = new User("foo@foo.com", "password", "John Doe");
                user1.save();
                User user2 = new User("foo@foo.com", "password", "John Doe");
                user2.save();
            }
        });
    }

    @Test(expected = PersistenceException.class)
View Full Code Here

    @Test(expected = PersistenceException.class)
    public void testCreateWithDuplicateEmailDifferentCase() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user1 = new User("foo@foo.com", "password", "John Doe");
                user1.save();
                User user2 = new User("FOO@FOO.COM", "password", "John Doe");
                user2.save();
            }
        });
    }
View Full Code Here

        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user1 = new User("foo@foo.com", "password", "John Doe");
                user1.save();
                User user2 = new User("FOO@FOO.COM", "password", "John Doe");
                user2.save();
            }
        });
    }

    @Test
View Full Code Here

    @Test
    public void findAll() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                User user1 = new User("foo@foo.com", "password", "John Doe");
                user1.save();

                User user2 = new User("bar@foo.com", "password", "Jane Doe");
                user2.save();

                List<User> users = User.find.all();
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.