Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.User


    @GET
    @Path("{messageId}/hashtag")
    @Override
    public Response getTags(@PathParam("messageId") String messageId) {

        User user = applicationManager.getSecurityService().getCurrentUser();
        Set<String> tags;
        try {
            SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(),
                    new ObjectId(messageId));
            tags = sobaMessage.getHashtags();

        } catch (MessageNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
View Full Code Here


        if (isEmpty(hashtag)) {
            return error("Hashtag payload is empty", Response.status(Response.Status.BAD_REQUEST));
        }

        User user = applicationManager.getSecurityService().getCurrentUser();

        try {
            applicationManager.getMessageService().removeHashtagFromMessage(user.getAccount(), new ObjectId(messageId),
                    hashtag);

        } catch (MessageNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.BAD_REQUEST));
        }
View Full Code Here

    public User findInvitedUser(String inviteKey, String accountId) {
        Assert.hasText(inviteKey);
        Assert.hasText(accountId);

        User user = ds.createQuery(entityClazz)
                .field("secretKey").equal(inviteKey)
                .get();

        if (user != null) {
            if ((user.getAccount().getId().toString().equals(accountId))) {
                return user;
            }
        }
        return null;
    }
View Full Code Here

        );
        return query.get();
    }

    public APIAuthenticationToken findAuthToken(String authenticationToken) {
        User user = findByAuthToken(authenticationToken);
        if (user != null) {
            return user.getAuthenticationToken();
        }
        return null;
    }
View Full Code Here

    public void testHashtagOnConnectionAndChildren() throws Exception {

        // random tag to connection...
        String random = UUID.randomUUID().toString().substring(0, 4);

        User user = applicationManager.getUserService().getUser(testUser.getUsername());
        String authnToken = login(user.getUsername(), testUser.getUsername()); // ugh

        // just get the first random one
        List<Connection> connections = applicationManager.getConnectionService().getConnections(ProjectHostingProvider.TYPE, user);
        Connection connection = connections.get(0);
View Full Code Here

    }

    @Test
    public void testCompleteUserSignupProcess_BadAliasReturnsConstraintViolationDTO() throws Exception {
        User user = new User.Builder().username("maynard@toolband.com")
                .secretKey("aaaaaaaaa")
                .password("bbbbbbbb")
                .roles(userService.getAdminRoles())
                .build();
        user.setAccountOriginator(true);


        UserService mockUserService = mock(UserService.class);
        when(mockUserService.isAliasAvailable(any(Account.class), anyString())).thenReturn(true);
        when(mockUserService.getUserFromSignupKey(anyString(),anyString())).thenReturn(user);
View Full Code Here

        Assert.assertTrue(StringUtils.isNotBlank(dto.getViolations().get("alias")));
    }

    @Test
    public void testCompleteUserInviteProcess_BadAliasReturnsConstraintViolationDTO() throws Exception {
        User user = new User.Builder().username("maynard@toolband.com")
                .secretKey("aaaaaaaaa")
                .password("bbbbbbbb")
                .roles(userService.getAdminRoles())
                .build();
        user.setAccountOriginator(true);


        UserService mockUserService = mock(UserService.class);
        when(mockUserService.isAliasAvailable(any(Account.class), anyString())).thenReturn(true);
        when(mockUserService.getUserFromInvite(anyString(),anyString())).thenReturn(user);
View Full Code Here

    @Autowired
    UserResource userResource;

    @Test
    public void testChangeUserProfileDoesNotAllowDuplicateAlias() {
        User existingAliasUser = new User.Builder().username("maynard@toolband.com").fullname("MJK").alias("maynard")
                .password("vocals").account(testAccount).build();
        userService.createUser(existingAliasUser);

        User anotherUser = new User.Builder().username("justinc@toolband.com").fullname("Justin Chancellor").password("bass")
                .alias("justinc").account(testAccount).build();
        userService.createUser(anotherUser);

        SecurityService mockSecurityService = mock(SecurityService.class);
        when(mockSecurityService.getCurrentUser()).thenReturn(anotherUser);
View Full Code Here

                .alias("TheHoneyBadger")
                .fullname("Honey Badger")
                .password(testUser2Username)
                .build());

        User user = applicationManager.getUserService().getUser(testUser2.getUsername());
        assertFalse(user.isUserLocked());

        String url = getUrl() + "/" + testUser2.getId() + "/disable/";
        makeRequest(url, "PUT", null, authToken);


        user = applicationManager.getUserService().getUser(testUser2.getUsername());
        assertTrue(user.isUserLocked());

        // user should not be returned in the user account list now.
        String response = makeRequest(getPublicApiUrlBase() + "/account/users", "GET", null, authToken);
        List<UserResponseDTO> users = jsonToObject(response, TypeFactory.defaultInstance().constructCollectionType(List.class,
                UserResponseDTO.class));

        assertNotNull(users);
        boolean exists = false;
        for (UserResponseDTO usr : users) {
            if (usr.getUsername().equals(testUser2.getUsername())) {
                exists = true;
            }
        }
        assertFalse(exists);

        url = getUrl() + "/" + testUser2.getId() + "/enable/";
        makeRequest(url, "PUT", null, authToken);

        user = applicationManager.getUserService().getUser(testUser2.getUsername());
        assertFalse(user.isUserLocked());

        // user should be returned in the user account list now.
        // user should not be returned in the user account list now.
        response = makeRequest(getPublicApiUrlBase() + "/account/users", "GET", null, authToken);
        users = jsonToObject(response, TypeFactory.defaultInstance().constructCollectionType(List.class,
View Full Code Here

        UserResponseDTO userDTO = jsonToObject(req, TypeFactory.defaultInstance().constructType(UserResponseDTO.class));

        assertEquals("SELF", String.valueOf(userDTO.getVisibility()));

        // set it back...
        User user = userService.getUserById(testUser.getId());
        user.setVisibility(SobaObject.Visibility.ACCOUNT);
        userService.updateUser(user);
    }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.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.