Search in sources :

Example 6 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method shouldThrowServerExceptionOnStoringMemberForNonExistenceOrganization.

@Test(expectedExceptions = ServerException.class)
public void shouldThrowServerExceptionOnStoringMemberForNonExistenceOrganization() throws Exception {
    final MemberImpl toCreate = new MemberImpl(members[0].getUserId(), "non-existence", singletonList("read"));
    memberDao.store(toCreate);
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Test(org.testng.annotations.Test)

Example 7 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method setUp.

@BeforeMethod
private void setUp() throws TckRepositoryException {
    users = new UserImpl[3];
    users[0] = new UserImpl("user1-id", "user1@test.com", "user1-name");
    users[1] = new UserImpl("user2-id", "user2@test.com", "user2-name");
    users[2] = new UserImpl("user3-id", "user3@test.com", "user3-name");
    userRepo.createAll(asList(users));
    orgs = new OrganizationImpl[3];
    orgs[0] = new OrganizationImpl("org1-id", "org1-name", null);
    orgs[1] = new OrganizationImpl("org2-id", "org2-name", null);
    orgs[2] = new OrganizationImpl("org3-id", "org3-name", null);
    organizationRepo.createAll(asList(orgs));
    members = new MemberImpl[5];
    members[0] = new MemberImpl(users[0].getId(), orgs[0].getId(), asList("read", "update"));
    members[1] = new MemberImpl(users[1].getId(), orgs[0].getId(), asList("read", "update"));
    members[2] = new MemberImpl(users[2].getId(), orgs[0].getId(), asList("read", "update"));
    members[3] = new MemberImpl(users[1].getId(), orgs[1].getId(), asList("read", "update"));
    members[4] = new MemberImpl(users[1].getId(), orgs[2].getId(), asList("read", "update"));
    memberRepo.createAll(Stream.of(members).map(MemberImpl::new).collect(Collectors.toList()));
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method shouldRemoveMember.

@Test(expectedExceptions = NotFoundException.class, dependsOnMethods = "shouldThrowNotFoundExceptionOnGettingNonExistingMember")
public void shouldRemoveMember() throws Exception {
    final MemberImpl member = members[0];
    memberDao.remove(member.getOrganizationId(), member.getUserId());
    memberDao.getMember(member.getUserId(), member.getOrganizationId());
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Test(org.testng.annotations.Test)

Example 9 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project devspaces-images by redhat-developer.

the class OrganizationManagerTest method shouldCreateOrganization.

@Test
public void shouldCreateOrganization() throws Exception {
    final Organization toCreate = DtoFactory.newDto(OrganizationDto.class).withName("newOrg");
    manager.create(toCreate);
    verify(organizationDao).create(organizationCaptor.capture());
    final OrganizationImpl createdOrganization = organizationCaptor.getValue();
    assertEquals(createdOrganization.getName(), toCreate.getName());
    assertEquals(createdOrganization.getQualifiedName(), toCreate.getName());
    assertEquals(createdOrganization.getParent(), toCreate.getParent());
    verify(eventService).publish(persistEventCaptor.capture());
    assertEquals(persistEventCaptor.getValue().getOrganization(), createdOrganization);
    verify(memberDao).store(new MemberImpl(USER_ID, createdOrganization.getId(), OrganizationDomain.getActions()));
}
Also used : Organization(org.eclipse.che.multiuser.organization.shared.model.Organization) MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 10 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project devspaces-images by redhat-developer.

the class OrganizationManagerTest method shouldRemoveMembersByOrganizationId.

@Test
public void shouldRemoveMembersByOrganizationId() throws Exception {
    MemberImpl member1 = new MemberImpl("user1", "org1", singletonList("read"));
    MemberImpl member2 = new MemberImpl("user2", "org1", singletonList("read"));
    doReturn(new Page<>(singletonList(member1), 0, 1, 2)).doReturn(new Page<>(singletonList(member2), 1, 1, 2)).when(memberDao).getMembers(anyString(), anyInt(), anyLong());
    manager.removeMembers("org1");
    verify(memberDao, times(2)).getMembers("org1", 100, 0);
    verify(memberDao).remove("user1", "org1");
    verify(memberDao).remove("user2", "org1");
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Page(org.eclipse.che.api.core.Page) Test(org.testng.annotations.Test)

Aggregations

MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)36 Test (org.testng.annotations.Test)18 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)14 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)6 DBInitializer (org.eclipse.che.core.db.DBInitializer)6 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)6 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)6 MemberDao (org.eclipse.che.multiuser.organization.spi.MemberDao)6 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)6 OrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.OrganizationDistributedResourcesDao)6 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)6 JpaMemberDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaMemberDao)6 JpaOrganizationDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDao)6 JpaOrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDistributedResourcesDao)6 UserDevfilePermissionImpl (org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)6 Transactional (com.google.inject.persist.Transactional)4 HashMap (java.util.HashMap)4