Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.AnonymousUser


     */
    @Override
    public JCUser getCurrentUser() {
        JCUser currentUser = userReader.getCurrentUser();
        if (currentUser.isAnonymous()) {
            return new AnonymousUser();
        } else {
            return JCUser.copyUser(currentUser);
        }
    }
View Full Code Here


        verify(userService).getCurrentUser();
    }

    @Test
    public void testLoginUserNotLogged() {
        when(userService.getCurrentUser()).thenReturn(new AnonymousUser());

        ModelAndView mav = userController.loginPage(request);

        assertEquals(mav.getViewName(), UserController.LOGIN);
        verify(userService).getCurrentUser();
View Full Code Here

     */
    @Override
    public JCUser getCurrentUser() {
        String name = securityService.getCurrentUserUsername();
        if (name == null) {
            return new AnonymousUser();
        } else {
            return this.getDao().getByUsername(name);
        }

    }
View Full Code Here

    }

    @Test
    public void testCurrentUserIsAnonymous() {
        when(sessionRegistry.getAllPrincipals()).thenReturn(list);
        when(userService.getCurrentUser()).thenReturn(new AnonymousUser());

        locationService.getUsersViewing(topic);
    }
View Full Code Here

        locationService.clearUserLocation();
    }
   
    @Test
    public void testClearUserLocationForAnonymous() {
        when(userService.getCurrentUser()).thenReturn(new AnonymousUser());
       
      locationService.clearUserLocation();
      @SuppressWarnings("unchecked")
    Map<JCUser, String> registerUserMap = mock(Map.class);
      verify(registerUserMap, Mockito.never()).remove(Mockito.any());
View Full Code Here

    }

    @Test
    public void resolveLocaleShouldReturnRequestLocaleIfUserAnonymous() {
        JcLocaleResolver localeResolver = new JcLocaleResolver(userService);
        AnonymousUser user = new AnonymousUser();
        user.setLanguage(Language.SPANISH);
        Locale defaultLocale = Language.ENGLISH.getLocale();
        when(userService.getCurrentUser()).thenReturn(user);
        when(request.getLocale()).thenReturn(defaultLocale);

        Locale result = localeResolver.resolveLocale(request);
View Full Code Here

        Assert.assertThat(result, not(instanceOf(AnonymousUser.class)));
    }

    @Test
    public void getCurrentUserShouldReturnAnonymousUserIfCurrentUserNotFound() {
        when(userReader.getCurrentUser()).thenReturn(new AnonymousUser());
        ReadOnlySecurityService service = (ReadOnlySecurityService)ReadOnlySecurityService.getInstance();
        service.setUserReader(userReader);

        JCUser result = service.getCurrentUser();
View Full Code Here

        assertTrue(validator.isValid("other name", null));
    }

    @Test
    public void testIsValidForAnonymous() throws Exception {
        when(service.getCurrentUser()).thenReturn(new AnonymousUser());

        assertTrue(validator.isValid(username, null));
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.AnonymousUser

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.