Search in sources :

Example 6 with OrganizationDistributedResourcesImpl

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

the class OrganizationDistributedResourcesDaoTest method shouldRemoveDistributedResources.

@Test(expectedExceptions = NotFoundException.class)
public void shouldRemoveDistributedResources() throws Exception {
    // given
    OrganizationDistributedResourcesImpl distributedResource = distributedResources[0];
    // when
    distributedResourcesDao.remove(distributedResource.getOrganizationId());
    // then
    distributedResourcesDao.get(distributedResource.getOrganizationId());
}
Also used : OrganizationDistributedResourcesImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl) Test(org.testng.annotations.Test)

Example 7 with OrganizationDistributedResourcesImpl

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

the class OrganizationDistributedResourcesDaoTest method shouldGetDistributedResourcesForSpecifiedOrganizationId.

@Test
public void shouldGetDistributedResourcesForSpecifiedOrganizationId() throws Exception {
    // given
    OrganizationDistributedResourcesImpl stored = distributedResources[0];
    // when
    OrganizationDistributedResourcesImpl fetched = distributedResourcesDao.get(stored.getOrganizationId());
    // then
    assertEquals(fetched, copy(stored));
}
Also used : OrganizationDistributedResourcesImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl) Test(org.testng.annotations.Test)

Example 8 with OrganizationDistributedResourcesImpl

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

the class JpaOrganizationDistributedResourcesDao method doRemove.

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

Example 9 with OrganizationDistributedResourcesImpl

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

the class JpaOrganizationDistributedResourcesDao method doStore.

@Transactional
protected void doStore(OrganizationDistributedResourcesImpl distributedResources) throws ServerException {
    EntityManager manager = managerProvider.get();
    final OrganizationDistributedResourcesImpl existingDistributedResources = manager.find(OrganizationDistributedResourcesImpl.class, distributedResources.getOrganizationId());
    if (existingDistributedResources == null) {
        manager.persist(distributedResources);
    } else {
        existingDistributedResources.getResourcesCap().clear();
        existingDistributedResources.getResourcesCap().addAll(distributedResources.getResourcesCap());
    }
    manager.flush();
}
Also used : EntityManager(javax.persistence.EntityManager) OrganizationDistributedResourcesImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl) Transactional(com.google.inject.persist.Transactional)

Example 10 with OrganizationDistributedResourcesImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl 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)

Aggregations

OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)32 Test (org.testng.annotations.Test)16 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)8 ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)8 TypeLiteral (com.google.inject.TypeLiteral)6 Transactional (com.google.inject.persist.Transactional)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)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 MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)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 HashMap (java.util.HashMap)4