Package org.ngrinder.model

Examples of org.ngrinder.model.User


   */
  @Test
  public void testGetOne() {
    ModelMap model = new ModelMap();
    userController.getOne(getTestUser().getUserId(), model);
    User user = (User) model.get("user");
    assertThat(user.getId(), is(getTestUser().getId()));
  }
View Full Code Here


   */
  @Test
  public void testSave() {
    // test update
    ModelMap model = new ModelMap();
    User currUser = getTestUser();
    currUser.setUserName("new name");
    userController.save(currUser, currUser, model);
    userController.getOne(currUser.getUserId(), model);
    User user = (User) model.get("user");
    assertThat(user.getUserName(), is("new name"));
    assertThat(user.getPassword(), is(currUser.getPassword()));

    User admin = getAdminUser();
    User temp = new User("temp1", "temp1", "temp1", "temp@nhn.com", Role.USER);
    userController.save(admin, temp, model);
    temp = new User("temp2", "temp2", "temp2", "temp@nhn.com", Role.USER);
    userController.save(admin, temp, model);
    model.clear();
    currUser.setFollowersStr("temp1, temp2");
    userController.save(currUser, currUser, model);
    userController.getOne(currUser.getUserId(), model);
View Full Code Here

  @Test
  public void testUpdate() {
    // test update the role of current user.
    ModelMap model = new ModelMap();
    User currUser = getTestUser();
    assertThat(currUser.getRole(), is(Role.USER)); // current test user is "USER"

    User updatedUser = new User(currUser.getUserId(), currUser.getUserName(), currUser.getPassword(),
        "temp@nhn.com", currUser.getRole());
    updatedUser.setId(currUser.getId());
    updatedUser.setEmail("test@test.com");
    updatedUser.setRole(Role.ADMIN); // Attempt to modify himself as ADMIN
    userController.save(currUser, updatedUser, model);

    userController.getOne(currUser.getUserId(), model);
    User user = (User) model.get("user");
    assertThat(user.getUserName(), is(currUser.getUserName()));
    assertThat(user.getPassword(), is(currUser.getPassword()));
    assertThat(user.getRole(), is(Role.USER));
  }
View Full Code Here

    assertThat(user.getPassword(), is(currUser.getPassword()));
    assertThat(user.getRole(), is(Role.USER));
  }

  private void saveTestUser(String userId, String userName) {
    User newUser = new User();
    newUser.setUserId(userId);
    newUser.setUserName(userName);
    newUser.setEmail("junoyoon@gmail.com");
    newUser.setCreatedUser(getTestUser());
    newUser.setCreatedDate(new Date());
    newUser.setRole(Role.USER);
    ModelMap model = new ModelMap();
    userController.save(getAdminUser(), newUser, model);
  }
View Full Code Here

  }

  @Test
  public void testSwitchOptions() {
    ModelMap model = new ModelMap();
    User currUser = getTestUser();
    User temp = new User("temp1", "temp1", "temp1", "temp@nhn.com", Role.USER);
    User admin = getAdminUser();
    userController.save(admin, temp, model);
    currUser.setOwners(Lists.newArrayList(temp));
    currUser.setOwnerUser(temp);
    userController.save(currUser, currUser, model);
    HttpEntity<String> shareUsersStr = userController.switchOptions(currUser, "");
View Full Code Here

  }

  @Test
  public void test() {

    User user = new User();
    user.setUserId("haha");
    Map<String, MutableInt> userAvailableAgentCountMap = agentManagerService.getAvailableAgentCountMap(user);
    System.out.println(userAvailableAgentCountMap);
    assertThat(userAvailableAgentCountMap.containsKey("kiki"), is(false));
    assertThat(userAvailableAgentCountMap.get("hello").intValue(), is(2));
    assertThat(userAvailableAgentCountMap.get("haha").intValue(), is(3));

    user.setUserId("wow");
    userAvailableAgentCountMap = agentManagerService.getAvailableAgentCountMap(user);
    assertThat(userAvailableAgentCountMap.get("hello").intValue(), is(3));
    assertThat(userAvailableAgentCountMap.get("haha").intValue(), is(3));

    user.setUserId("my");
    userAvailableAgentCountMap = agentManagerService.getAvailableAgentCountMap(user);
    assertThat(userAvailableAgentCountMap.get("hello").intValue(), is(2));
    assertThat(userAvailableAgentCountMap.get("haha").intValue(), is(4));
    assertThat(userAvailableAgentCountMap.get("wowo").intValue(), is(3));
View Full Code Here

  @Test
  public void testBreadCrumb() {
    FileEntryController controller = new FileEntryController();
    controller.httpContainerContext = mock(HttpContainerContext.class);
    when(controller.httpContainerContext.getCurrentContextUrlFromUserRequest()).thenReturn("http://helloworld.org/ngrinder");
    User user = new User();
    user.setUserId("admin");
    assertThat(controller.getSvnUrlBreadcrumbs(user, "hello/world"))
        .isEqualTo("<a href='http://helloworld.org/ngrinder/script/list'>http://helloworld.org/ngrinder/svn/admin</a>/<a href='http://helloworld.org/ngrinder/script/list/hello'>hello</a>/<a href='http://helloworld.org/ngrinder/script/list/hello/world'>world</a>");
  }
View Full Code Here

  @Autowired
  private PerfTestController perfTestController;

  @Test
  public void testCurrentUser() {
    User currUser = perfTestController.currentUser();
    assertThat(currUser, notNullValue());
  }
View Full Code Here

                add(mockLoginPlugin);
              }
            });

    // When user is return by plugin module.
    User user = new User();
    user.setUserName("hello1");
    user.setUserId("hello1");
    user.setEmail("helloworld@gmail.com");
    user.setRole(Role.SUPER_USER);
    user.setAuthProviderClass(mockLoginPlugin.getClass().getName());
    when(mockLoginPlugin.loadUser("hello1")).thenReturn(user);
    when(mockLoginPlugin.validateUser(anyString(), anyString(), anyString(), any(), any())).thenReturn(true);

    // Then, Auth should be succeeded.
    assertThat(authProvider.authenticate(auth), notNullValue());
View Full Code Here

  public void testAddNewUserIntoLocal() {
    SecuredUser secUser = new SecuredUser(getTestUser(), null);
    provider.addNewUserIntoLocal(secUser);
    assertThat(secUser.getUser(), is(getTestUser()));
   
    User tmpUser = new User("tmpUserId", "tmpName", "123", "test.nhn.com", Role.USER);
    SecuredUser tmpSecUser = new SecuredUser(tmpUser, null);
    provider.addNewUserIntoLocal(tmpSecUser);
    assertThat(tmpSecUser.getUser(), is(tmpUser));
  }
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.