Package org.ngrinder.model

Examples of org.ngrinder.model.User


  public void testHome() {
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockHttpServletRequest req = new MockHttpServletRequest();
    CookieLocaleResolver localeResolver = new CookieLocaleResolver();
    req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver);
    User testUser2 = getTestUser();
    testUser2.setUserLanguage("EN");
    ModelMap model = new ModelMap();
    String viewName = homeController.home(testUser2, null, null, model, res, req);
    assertThat(viewName, is("index"));

    User testUserError = Mockito.spy(testUser2);
    Mockito.when(testUserError.getRole()).thenReturn(Role.SYSTEM_USER);
    viewName = homeController.home(testUserError, "Test Error message!", null, model, res, req);
    assertThat(viewName, is("login"));

  }
View Full Code Here


  @Autowired
  private SaltSource saltSource;

  @PostConstruct
  public void init() {
    User user = userRepository.findOneByUserId(TEST_USER_ID);
    if (user == null) {
      user = new User();
      user.setUserId(TEST_USER_ID);
      user.setUserName("TEST_USER");
      user.setEmail("TEST_USER@nhn.com");
      user.setPassword("123");
      user.setRole(Role.USER);

      SecuredUser securedUser = new SecuredUser(user, null);
      String encodePassword = passwordEncoder.encodePassword(user.getPassword(), saltSource.getSalt(securedUser));
      user.setPassword(encodePassword);

      userRepository.save(user);
    }
  }
View Full Code Here

      userRepository.save(user);
    }
  }

  public User getCurrentUser() {
    User user = userRepository.findOneByUserId(TEST_USER_ID);
    user.setUserLanguage("en");
    user.setTimeZone(TEST_USER_TIMEZONE_US);
    return user;
  }
View Full Code Here

  public void before() {

  }

  private User createTestUser(String userId) {
    User user = new User();
    user.setUserId(userId);
    user.setUserName("hello");
    user.setPassword("www");
    user.setEmail("www@test.com");
    user.setRole(Role.SUPER_USER);
    user = userService.save(user);
    assertThat(user.getRole().hasPermission(Permission.GET_ALL_TESTS), is(true));
    assertThat(user.getRole().hasPermission(Permission.CHECK_SCRIPT_OF_OTHER), is(true));
    assertThat(user.getRole().hasPermission(Permission.VALIDATE_SCRIPT_OF_OTHER), is(true));
    assertThat(user.getRole().hasPermission(Permission.SWITCH_TO_ANYONE), is(true));
    assertThat(user.getUserId(), is(userId));
    return user;
  }
View Full Code Here

    return user;
  }

  @Test
  public void testUpdateUser() {
    User user = createTestUser("testId1");

    User user2 = new User();
    user2.setId(user.getId());
    user2.setUserId("hello");
    user2.setPassword("www222");
    user2.setEmail("www@test.com");
    user2.setRole(Role.ADMIN);
    user2 = userService.save(user2);
    User userById = userService.getOne("hello");
    assertThat(userById.getId(), is(user.getId()));
    userService.save(user2);
    userById = userService.getOne("hello");
    assertThat(userById.getRole().hasPermission(Permission.GET_ALL_TESTS), is(true));
    assertThat(userById.getRole().hasPermission(Permission.CHECK_SCRIPT_OF_OTHER), is(true));
    assertThat(userById.getRole().hasPermission(Permission.VALIDATE_SCRIPT_OF_OTHER), is(true));
    assertThat(userById.getRole().hasPermission(Permission.SWITCH_TO_ANYONE), is(true));
    assertThat(userById.getRole(), is(Role.ADMIN));
  }
View Full Code Here

    assertThat(userById.getRole(), is(Role.ADMIN));
  }

  @Test
  public void testDeleteUsers() {
    final User user = createTestUser("testId3");
    assertThat(user, notNullValue());
    userService.delete(user.getUserId());
    assertThat(userService.getOne(user.getUserId()), nullValue());
  }
View Full Code Here

  Config config;

  @SuppressWarnings("serial")
  @Test
  public void testUserDelete() {
    final User user = getTestUser();
    File scriptDirectory = config.getHome().getScriptDirectory(user);
    scriptDirectory.mkdirs();
    PerfTest perfTest = new PerfTest();
    perfTest.setTestName("Hello");
    perfTest.setTagString("Hello,World");
    perfTest = perfTestService.save(user, perfTest);
    userService.delete(user.getUserId());
    assertThat(perfTestService.getOne(perfTest.getId()), nullValue());
    assertThat(scriptDirectory.exists(), is(false));
  }
View Full Code Here

    assertThat(scriptDirectory.exists(), is(false));
  }

  @Test
  public void testGetUserListByKeyWord() {
    User user = new User();
    user.setUserId("testIdForNameSearch");
    user.setUserName("testIdForNameSearch");
    user.setPassword("111111");
    user.setEmail("testIdForNameSearch@test.com");
    user.setRole(Role.USER);
    user = userService.save(user);
    assertThat(user.getUserId(), is("testIdForNameSearch"));

    List<User> userList = userService.getAll("ForNameSearch");
    assertThat(userList.size(), is(1));

    userList = userService.getAll("ForName");
View Full Code Here

  @Test
  public void testShareUser() {
    List<User> sharedUsers = new ArrayList<User>();
    List<User> shareUsers = new ArrayList<User>();

    User user = new User();
    user.setUserName("MyName1");
    user.setEmail("junoyoon@gmail.com");
    user.setCreatedUser(getUser("user"));
    user.setCreatedDate(new Date());
    user.setUserId("hello");
    user.setRole(Role.USER);
    user = userRepository.save(user);
    User user2 = new User();
    user2.setUserId("hello2");
    user2.setUserName("MyName2");
    user2.setEmail("junoyoon2@paran.com");
    user2.setCreatedUser(getUser("user"));
    user2.setCreatedDate(new Date());
    user2.setRole(Role.USER);
    userRepository.save(user2);
   
    User user3 = new User();
    user3.setUserId("hello3");
    user3.setUserName("MyName3");
    user3.setEmail("junoyoon3@paran.com");
    user3.setCreatedUser(getUser("user"));
    user3.setCreatedDate(new Date());
    user3.setRole(Role.USER);
    userRepository.save(user3);
   
    User user4 = new User();
    user4.setUserId("hello4");
    user4.setUserName("MyName4");
    user4.setEmail("junoyoon4@paran.com");
    user4.setCreatedUser(getUser("user"));
    user4.setCreatedDate(new Date());
    user4.setRole(Role.USER);
    sharedUsers.add(user3);
    sharedUsers.add(user2);

    user4.setFollowers(sharedUsers);
    shareUsers.add(user);
    user4.setOwners(shareUsers);
    userRepository.save(user4);

      User sharedUser = userRepository.findOneByUserId(user4.getUserId());
    List<User> sh = sharedUser.getFollowers();
    LOG.debug("sharedUser.getFollowers:{}", sh);
  }
View Full Code Here

  }
 

  @Test
  public void testUser() {
    User user = new User();
    user.setUserName("MyName1");
    user.setEmail("junoyoon@gmail.com");
    user.setCreatedUser(getUser("user"));
    user.setCreatedDate(new Date());
    user.setUserId("hello");
    user.setRole(Role.USER);
    user = userRepository.save(user);
    User user2 = new User();
    user2.setUserId("hello2");
    user2.setUserName("MyName2");
    user2.setEmail("junoyoon@paran.com");
    user2.setCreatedUser(getUser("user"));
    user2.setCreatedDate(new Date());
    user2.setRole(Role.USER);
    userRepository.save(user2);

    assertThat(userRepository.count(), is(2L));

    assertThat(userRepository.findAll(UserSpecification.emailLike("gmail")).size(), is(1));
View Full Code Here

TOP

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