Package org.superbiz.rest.model

Examples of org.superbiz.rest.model.User


public class UserDAO {
    @Inject
    private DAO dao;

    public User create(String name, String pwd, String mail) {
        User user = new User();
        user.setFullname(name);
        user.setPassword(pwd);
        user.setEmail(mail);
        return dao.create(user);
    }
View Full Code Here


    public void delete(long id) {
        dao.delete(User.class, id);
    }

    public User update(long id, String name, String pwd, String mail) {
        User user = dao.find(User.class, id);
        if (user == null) {
            throw new IllegalArgumentException("setUser id " + id + " not found");
        }

        user.setFullname(name);
        user.setPassword(pwd);
        user.setEmail(mail);
        return dao.update(user);
    }
View Full Code Here

public class PostDAO {
    @Inject
    private DAO dao;

    public Post create(String title, String content, long userId) {
        User user = dao.find(User.class, userId);
        Post post = new Post();
        post.setTitle(title);
        post.setContent(content);
        post.setUser(user);
        return dao.create(post);
View Full Code Here

    public void delete(long id) {
        dao.delete(Post.class, id);
    }

    public Post update(long id, long userId, String title, String content) {
        User user = dao.find(User.class, userId);
        if (user == null) {
            throw new IllegalArgumentException("user id " + id + " not found");
        }

        Post post = dao.find(Post.class, id);
View Full Code Here

    }

    @Test
    public void create() throws NamingException {
        final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
        final User user = dao.create("foo", "dummy", "foo@dummy.org");
        assertNotNull(dao.find(user.getId()));

        final String uri = "http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/rest-example";
        final UserServiceClientAPI client = JAXRSClientFactory.create(uri, UserServiceClientAPI.class);
        final User retrievedUser = client.show(user.getId());
        assertNotNull(retrievedUser);
        assertEquals("foo", retrievedUser.getFullname());
        assertEquals("dummy", retrievedUser.getPassword());
        assertEquals("foo@dummy.org", retrievedUser.getEmail());
    }
View Full Code Here

    }

    @Test
    public void create() throws NamingException {
        final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
        final User user = dao.create("foo", "dummy", "foo@bar.org");
        assertNotNull(dao.find(user.getId()));
    }
View Full Code Here

TOP

Related Classes of org.superbiz.rest.model.User

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.