Search in sources :

Example 46 with OrganizationImpl

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

the class JpaOrganizationDao method doRemove.

@Transactional
protected void doRemove(String organizationId) {
    final EntityManager manager = managerProvider.get();
    final OrganizationImpl organization = manager.find(OrganizationImpl.class, organizationId);
    if (organization != null) {
        manager.remove(organization);
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Transactional(com.google.inject.persist.Transactional)

Example 47 with OrganizationImpl

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

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 48 with OrganizationImpl

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

the class OrganizationResourcesDistributorTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    lenient().doNothing().when(manager).checkResourcesAvailability(anyString(), any());
    lenient().when(resourcesLocks.lock(anyString())).thenReturn(lock);
    lenient().when(organizationManager.getById(ORG_ID)).thenReturn(new OrganizationImpl(ORG_ID, ORG_ID + "name", PARENT_ORG_ID));
    lenient().when(organizationManager.getById(PARENT_ORG_ID)).thenReturn(new OrganizationImpl(PARENT_ORG_ID, PARENT_ORG_ID + "name", null));
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 49 with OrganizationImpl

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

the class OrganizationalAccountAvailableResourcesProviderTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    lenient().when(resourceManagerProvider.get()).thenReturn(resourceManager);
    rootOrganization = new OrganizationImpl(ROOT_ORG_ID, ROOT_ORG_NAME, null);
    suborganization = new OrganizationImpl(SUBORG_ID, "root/suborg", ROOT_ORG_ID);
    subsuborganization = new OrganizationImpl(SUBSUBORG_ID, "root/suborg/subsuborg", SUBORG_ID);
    lenient().when(organizationManager.getById(ROOT_ORG_ID)).thenReturn(rootOrganization);
    lenient().when(organizationManager.getById(SUBORG_ID)).thenReturn(suborganization);
    lenient().when(organizationManager.getById(SUBSUBORG_ID)).thenReturn(subsuborganization);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 50 with OrganizationImpl

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

the class JpaOrganizationImplTckRepository method removeAll.

@Override
public void removeAll() throws TckRepositoryException {
    uow.begin();
    final EntityManager manager = managerProvider.get();
    try {
        manager.getTransaction().begin();
        for (int i = createdOrganizations.size() - 1; i > -1; i--) {
            // and may also ignore some configuration options, while EntityManager#remove won't
            try {
                final OrganizationImpl organizationToRemove = manager.createQuery("SELECT o FROM Organization o " + "WHERE o.id = :id", OrganizationImpl.class).setParameter("id", createdOrganizations.get(i).getId()).getSingleResult();
                manager.remove(organizationToRemove);
            } catch (NoResultException ignored) {
            // it is already removed
            }
        }
        createdOrganizations.clear();
        manager.getTransaction().commit();
    } catch (RuntimeException x) {
        if (manager.getTransaction().isActive()) {
            manager.getTransaction().rollback();
        }
        throw new TckRepositoryException(x.getLocalizedMessage(), x);
    } finally {
        uow.end();
    }
    // remove all objects that was created in tests
    super.removeAll();
}
Also used : EntityManager(javax.persistence.EntityManager) TckRepositoryException(org.eclipse.che.commons.test.tck.repository.TckRepositoryException) NoResultException(javax.persistence.NoResultException) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)

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