Search in sources :

Example 56 with OrganizationImpl

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

the class OrganizationDistributedResourcesDaoTest method setUp.

@BeforeMethod
private void setUp() throws Exception {
    parentOrganization = new OrganizationImpl("parentOrg", "parentOrgName", null);
    suborganizations = new OrganizationImpl[ORGANIZATION_RESOURCES_COUNT];
    distributedResources = new OrganizationDistributedResourcesImpl[ORGANIZATION_RESOURCES_COUNT];
    for (int i = 0; i < ORGANIZATION_RESOURCES_COUNT; i++) {
        suborganizations[i] = new OrganizationImpl("suborgId-" + i, "suborgName" + i, parentOrganization.getId());
        distributedResources[i] = new OrganizationDistributedResourcesImpl(suborganizations[i].getId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, i, "test")));
    }
    organizationsRepository.createAll(Collections.singletonList(parentOrganization));
    organizationsRepository.createAll(Arrays.asList(suborganizations));
    distributedResourcesRepository.createAll(Arrays.asList(distributedResources));
}
Also used : ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) OrganizationDistributedResourcesImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 57 with OrganizationImpl

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

the class OrganizationJpaTckModule method configure.

@Override
protected void configure() {
    install(new JpaPersistModule("main"));
    H2DBTestServer server = H2DBTestServer.startDefault();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(DBInitializer.class).asEagerSingleton();
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {
    }).to(OrganizationDomain.class);
    bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {
    }).to(JpaOrganizationImplTckRepository.class);
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserImpl.class));
    bind(new TypeLiteral<TckRepository<MemberImpl>>() {
    }).toInstance(new JpaTckRepository<>(MemberImpl.class));
    bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {
    }).toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));
    bind(OrganizationDao.class).to(JpaOrganizationDao.class);
    bind(MemberDao.class).to(JpaMemberDao.class);
    bind(OrganizationDistributedResourcesDao.class).to(JpaOrganizationDistributedResourcesDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) OrganizationDistributedResourcesDao(org.eclipse.che.multiuser.organization.spi.OrganizationDistributedResourcesDao) JpaOrganizationDistributedResourcesDao(org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDistributedResourcesDao) MemberDao(org.eclipse.che.multiuser.organization.spi.MemberDao) JpaMemberDao(org.eclipse.che.multiuser.organization.spi.jpa.JpaMemberDao) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) OrganizationDistributedResourcesImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl) JpaOrganizationDao(org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDao) OrganizationDao(org.eclipse.che.multiuser.organization.spi.OrganizationDao)

Example 58 with OrganizationImpl

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

the class OrganizationResourceDistributionServicePermissionsFilterTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    lenient().when(manager.getById(SUBORGANIZATION)).thenReturn(new OrganizationImpl(SUBORGANIZATION, "testOrg", PARENT_ORGANIZATION));
    lenient().when(manager.getById(PARENT_ORGANIZATION)).thenReturn(new OrganizationImpl(PARENT_ORGANIZATION, "parentOrg", null));
    lenient().when(subject.hasPermission(anyString(), anyString(), anyString())).thenReturn(true);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 59 with OrganizationImpl

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

the class OrganizationDaoTest method shouldGetByParent.

@Test
public void shouldGetByParent() throws Exception {
    final OrganizationImpl parent = organizations[0];
    final OrganizationImpl child1 = new OrganizationImpl("child1", "childTest1", parent.getId());
    final OrganizationImpl child2 = new OrganizationImpl("child2", "childTest2", parent.getId());
    final OrganizationImpl child3 = new OrganizationImpl("child3", "childTest3", parent.getId());
    tckRepository.createAll(asList(child1, child2, child3));
    final Page<OrganizationImpl> children = organizationDao.getByParent(parent.getId(), 1, 1);
    assertEquals(children.getTotalItemsCount(), 3);
    assertEquals(children.getItemsCount(), 1);
    assertTrue(children.getItems().contains(child1) ^ children.getItems().contains(child2) ^ children.getItems().contains(child3));
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 60 with OrganizationImpl

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

the class OrganizationDaoTest method shouldThrowConflictExceptionOnCreatingOrganizationWithExistingId.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionOnCreatingOrganizationWithExistingId() throws Exception {
    final OrganizationImpl organization = new OrganizationImpl(organizations[0].getId(), "Test", null);
    organizationDao.create(organization);
    assertEquals(organizationDao.getById(organization.getId()), organization);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Aggregations

OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)100 Test (org.testng.annotations.Test)56 Transactional (com.google.inject.persist.Transactional)18 BeforeMethod (org.testng.annotations.BeforeMethod)16 EntityManager (javax.persistence.EntityManager)14 MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)14 Organization (org.eclipse.che.multiuser.organization.shared.model.Organization)13 Response (io.restassured.response.Response)12 Page (org.eclipse.che.api.core.Page)10 ServerException (org.eclipse.che.api.core.ServerException)8 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)8 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)7 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)6 OrganizationDto (org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto)6 UserDevfilePermissionImpl (org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)5 DBInitializer (org.eclipse.che.core.db.DBInitializer)5