Package demo.model

Examples of demo.model.User


    }

    @GET
    @Path("{id}")
    public Response getUser(@PathParam("id") String userID) {
        final User user = this.usersService.get(userID);

        return (user != null)
                ? Response.ok(user).build()
                : Response.status(Response.Status.NOT_FOUND).build();
    }
View Full Code Here


    }

    @DELETE
    @Path("{id}")
    public Response deleteUser(@PathParam("id") String userID) {
        final User user = new User();
        user.setID(userID);

        return (this.usersService.delete(user))
                ? Response.status(Response.Status.NO_CONTENT).build()
                : Response.status(Response.Status.BAD_REQUEST).build();
    }
View Full Code Here

        return userList;
    }

    private User getUser() {
        return new User();
    }
View Full Code Here

        when(this.resultSet.getString("id")).thenReturn(ID);
        when(this.resultSet.getString("name")).thenReturn("Manuel");
        when(this.resultSet.getString("email")).thenReturn("manuel@fakemail.com");
        when(this.resultSet.getBoolean("active")).thenReturn(true);

        final User user = this.rowMapper.mapRow(this.resultSet, 0);

        assertEquals(ID, user.getID().toString());
        assertEquals("Manuel", user.getName());
        assertEquals("manuel@fakemail.com", user.getEmail());
        assertTrue(user.isActive());
    }
View Full Code Here

    }

    @Test
    public void testGetUser() {
        final String QUERY = "select * from users where id = ?";
        final User user = new User();

        user.setID(ID);
        user.setName("Manuel");
        user.setEmail("manuel@fakemail.com");
        user.setActive(true);

        when(this.jdbcTemplate.queryForObject(QUERY, rowMapper, ID)).thenReturn(user);

        assertNull(this.usersService.get(null));
        assertNull(this.usersService.get("other-ID"));
View Full Code Here

    }

    @Test
    public void testUpdate() {
        final String QUERY = "update users set name = ?, email = ?, active = ? where id = ?";
        final User user = new User();

        user.setID(ID);
        user.setName("Manuel");
        user.setEmail("manuel@fakemail.com");
        user.setActive(true);

        when(this.jdbcTemplate.update(QUERY, user.getName(), user.getEmail(), user.isActive(), user.getID())).thenReturn(1);

        assertTrue(this.usersService.update(user));
        user.setID("other-ID");
        assertFalse(this.usersService.update(user));
    }
View Full Code Here

    }

    @Test
    public void testCreate() {
        final String QUERY = "insert into users (id, name, email, active) values (?, ?, ?, ?)";
        final User user = new User();

        user.setID(ID);
        user.setName("Manuel");
        user.setEmail("manuel.martin@gmail.com");
        user.setActive(true);

        when(this.jdbcTemplate.update(QUERY, user.getID(), user.getName(), user.getEmail(), user.isActive())).thenReturn(1);

        assertTrue(this.usersService.create(user));
        user.setID("other-ID");
        assertFalse(this.usersService.create(user));
    }
View Full Code Here

    }

    @Test
    public void testDelete() {
        final String QUERY = "delete from users where id = ?";
        final User user = new User();

        user.setID(ID);

        when(this.jdbcTemplate.update(QUERY, user.getID())).thenReturn(1);

        assertTrue(this.usersService.delete(user));
        user.setID("other-ID");
        assertFalse(this.usersService.delete(user));
    }
View Full Code Here

        assertEquals(0, this.usersWS.getUsers().size());
    }

    @Test
    public void testGetUser() {
        when(usersService.get(ID)).thenReturn(new User());

        Response response = this.usersWS.getUser(ID);
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
        assertNotNull(response.getEntity());
View Full Code Here

        assertNull(response.getEntity());
    }

    @Test
    public void testCreateUser() {
        final User user1 = new User(),
                user2 = new User();

        when(usersService.create(user1)).thenReturn(true);
        when(usersService.create(user2)).thenReturn(false);

        Response response = this.usersWS.createUser(user1);
View Full Code Here

TOP

Related Classes of demo.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.