use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.
the class MemberDaoTest method shouldCreateNewMemberOnMemberStoring.
@Test(dependsOnMethods = { "shouldGetMember", "shouldRemoveMember" })
public void shouldCreateNewMemberOnMemberStoring() throws Exception {
final MemberImpl member = members[0];
memberDao.remove(member.getUserId(), member.getOrganizationId());
memberDao.store(member);
assertEquals(memberDao.getMember(member.getOrganizationId(), member.getUserId()), new MemberImpl(member));
}
use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.
the class MemberDaoTest method shouldThrowServerExceptionOnStoringMemberForNonExistenceUser.
@Test(expectedExceptions = ServerException.class)
public void shouldThrowServerExceptionOnStoringMemberForNonExistenceUser() throws Exception {
final MemberImpl toCreate = new MemberImpl("non-existence", members[0].getOrganizationId(), singletonList("read"));
memberDao.store(toCreate);
}
use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.
the class MemberDaoTest method shouldGetMember.
@Test
public void shouldGetMember() throws Exception {
final MemberImpl existedMember = members[0];
final MemberImpl fetchedMember = memberDao.getMember(existedMember.getOrganizationId(), existedMember.getUserId());
assertEquals(existedMember, fetchedMember);
}
use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.
the class JpaMemberDao method doRemove.
@Override
@Transactional
protected void doRemove(String organizationId, String userId) {
final EntityManager manager = managerProvider.get();
List<MemberImpl> members = manager.createNamedQuery("Member.getMember", MemberImpl.class).setParameter("userId", userId).setParameter("organizationId", organizationId).getResultList();
if (!members.isEmpty()) {
manager.remove(members.get(0));
manager.flush();
}
}
use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.
the class OrganizationManager method removeMembers.
@VisibleForTesting
List<String> removeMembers(String organizationId) throws ServerException {
List<String> removed = new ArrayList<>();
Page<MemberImpl> membersPage;
do {
// skip count always equals to 0 because elements will be shifted after removing previous
// items
membersPage = memberDao.getMembers(organizationId, 100, 0);
for (MemberImpl member : membersPage.getItems()) {
removed.add(member.getUserId());
memberDao.remove(member.getUserId(), member.getOrganizationId());
}
} while (membersPage.hasNextPage());
return removed;
}
Aggregations