Package cz.muni.fi.pa165.stis.entity

Examples of cz.muni.fi.pa165.stis.entity.User


        }));
    }

    @Test
    public void testGet() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        when(dao.get(4L)).thenReturn(user);
        UserTO userTO = service.get(4L);
        assertEquals(userTO, uto);
View Full Code Here


        assertEquals(userTO, uto);
    }

    @Test
    public void getByUsername() {
        User user3 = createUser("mrkvicka", "345sac", false);
        User user2 = createUser("Bruce", "Willis", false);
        User user1 = createUser("Peter", "Mravec", true);
        UserTO uto1 = mapper.map(user1, UserTO.class);
        UserTO uto2 = mapper.map(user2, UserTO.class);
        UserTO uto3 = mapper.map(user3, UserTO.class);
       
        when(dao.getByUsername("mrkvicka")).thenReturn(user3);              
View Full Code Here

        assertEquals(uto, uto3);       
    }

    @Test
    public void testUpdate() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        service.update(uto);
        verify(dao).update(user);
    }
View Full Code Here

        verify(dao).update(user);
    }

    @Test
    public void testRemove() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        service.remove(uto);
        verify(dao).remove(user);
    }
View Full Code Here

        verify(dao).remove(user);
    }

    @Test
    public void testAvailableUsername() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        when(dao.availableUsername("mrkvicka")).thenReturn(Boolean.FALSE);
        assertFalse("Should not be available Username", service.availableUsername("mrkvicka"));
        service.remove(uto);
View Full Code Here

        assertTrue("Should be available Username", service.availableUsername("mrkvicka"));
    }

    @Test
    public void testIsAdmin() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        when(dao.isAdmin(user)).thenReturn(Boolean.FALSE);
        assertFalse("user should not have roleAdmin", service.isAdmin(uto));
        when(dao.isAdmin(user)).thenReturn(Boolean.TRUE);
View Full Code Here

        assertTrue("user should have roleAdmin", service.isAdmin(uto));
    }

    @Test
    public void testMakeAdmin() {
        User user = createUser("mrkvicka", "345sac", false);
        user.setId(4L);
        UserTO uto = mapper.map(user, UserTO.class);

        when(dao.isAdmin(user)).thenReturn(Boolean.FALSE);
        assertFalse("User should not be admin", service.isAdmin(uto));
        service.makeAdmin(uto);
View Full Code Here

        assertTrue("User should be admin", service.isAdmin(uto));
    }

    // newly created user is missing ID
    private static User createUser(String username, String password, boolean roleAdmin) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setRoleAdmin(roleAdmin);
        return user;
    }
View Full Code Here

            throw new IllegalArgumentException("user is null");
        }
        if (user.getId() == null) {
            throw new IllegalArgumentException("user.id is null");
        }
        User user2 = em.find(User.class, user.getId());
        em.remove(user2);
    }
View Full Code Here

    public User get(Long id) {
        if (id == null) {
            throw new IllegalArgumentException("id is null");
        }

        User user = em.find(User.class, id);
        return user;
    }
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.stis.entity.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.