Beispiel #1
0
  public UserEntity createUserWithAllValues(
      String uid, String displayName, UserType type, String userStoreName, UserInfo userInfo) {
    UserEntity user = new UserEntity();
    user.setName(uid);
    user.setDisplayName(displayName);
    user.setSyncValue(uid);
    user.setTimestamp(new DateTime());
    user.setType(type);
    user.setDeleted(0);
    if (userStoreName != null) {
      user.setUserStore(fixture.findUserStoreByName(userStoreName));
    }
    user.setUserGroup(null);

    user.setUserFields(new UserInfoTransformer().toUserFields(userInfo));

    return user;
  }
Beispiel #2
0
  public UserEntity createUser(
      String uid, String displayName, UserType type, String userStoreName, GroupEntity group) {
    UserEntity user = new UserEntity();
    user.setName(uid);
    user.setDisplayName(displayName);
    user.setSyncValue(uid);
    user.setTimestamp(new DateTime());
    user.setType(type);
    user.setDeleted(0);
    if (userStoreName != null) {
      user.setUserStore(fixture.findUserStoreByName(userStoreName));
    }
    if (group != null) {
      user.setUserGroup(group);
    }

    return user;
  }
  @Before
  public void setUp() throws Exception {
    final GroupEntity adminGroupEntity = new GroupEntity();
    final GroupKey adminGroupKey = new GroupKey("admin");
    adminGroupEntity.setKey(adminGroupKey);

    final GroupEntity anonGroupEntity = new GroupEntity();
    final GroupKey anonGroupKey = new GroupKey("anonymous");
    anonGroupEntity.setKey(anonGroupKey);

    servlet = new MyPageServlet();
    servlet.groupDao = Mockito.mock(GroupDao.class);
    Mockito.when(servlet.groupDao.findBuiltInAnonymous()).thenReturn(anonGroupEntity);
    Mockito.when(servlet.groupDao.findBuiltInEnterpriseAdministrator())
        .thenReturn(adminGroupEntity);

    final GroupEntity groupEntity = new GroupEntity();
    final GroupKey groupKey = new GroupKey("user_group");
    groupEntity.setKey(groupKey);

    userEntity = new UserEntity();
    userEntity.setName("user");
    userEntity.setType(UserType.NORMAL);
    userEntity.setUserGroup(groupEntity);

    final Map<GroupKey, CategoryAccessEntity> accessRights =
        new HashMap<GroupKey, CategoryAccessEntity>();

    accessEntity = new CategoryAccessEntity();
    accessRights.put(groupKey, accessEntity);

    contentType = Mockito.mock(ContentTypeEntity.class);

    final CategoryEntity categoryEntity = new CategoryEntity();
    categoryEntity.setAccessRights(accessRights);
    Mockito.when(contentType.getCategories(false))
        .thenReturn(Arrays.<CategoryEntity>asList(categoryEntity));
  }