Search in sources :

Example 26 with FreeResourcesLimitImpl

use of org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl in project che-server by eclipse-che.

the class FreeResourcesLimitDaoTest method shouldUpdateResourcesLimitWhenStoringExistentOne.

@Test
public void shouldUpdateResourcesLimitWhenStoringExistentOne() throws Exception {
    // given
    FreeResourcesLimitImpl toStore = new FreeResourcesLimitImpl(limits[0].getAccountId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    // when
    limitDao.store(toStore);
    // then
    assertEquals(limitDao.get(toStore.getAccountId()), new FreeResourcesLimitImpl(toStore));
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Example 27 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitDaoTest method shouldGetResourcesLimitForSpecifiedAccountId.

@Test
public void shouldGetResourcesLimitForSpecifiedAccountId() throws Exception {
    // given
    FreeResourcesLimitImpl stored = limits[0];
    // when
    FreeResourcesLimitImpl fetched = limitDao.get(stored.getAccountId());
    // then
    assertEquals(fetched, stored);
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) Test(org.testng.annotations.Test)

Example 28 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitDaoTest method shouldRemoveResourcesLimit.

@Test(expectedExceptions = NotFoundException.class)
public void shouldRemoveResourcesLimit() throws Exception {
    // given
    FreeResourcesLimitImpl existedLimit = limits[0];
    // when
    limitDao.remove(existedLimit.getAccountId());
    // then
    limitDao.get(existedLimit.getAccountId());
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) Test(org.testng.annotations.Test)

Example 29 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitDaoTest method shouldUpdateResourcesLimitWhenStoringExistentOne.

@Test
public void shouldUpdateResourcesLimitWhenStoringExistentOne() throws Exception {
    // given
    FreeResourcesLimitImpl toStore = new FreeResourcesLimitImpl(limits[0].getAccountId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    // when
    limitDao.store(toStore);
    // then
    assertEquals(limitDao.get(toStore.getAccountId()), new FreeResourcesLimitImpl(toStore));
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Example 30 with FreeResourcesLimitImpl

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

the class ResourceTckModule 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<TckRepository<FreeResourcesLimitImpl>>() {
    }).toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) 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) FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) TypeLiteral(com.google.inject.TypeLiteral) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) DBInitializer(org.eclipse.che.core.db.DBInitializer) JpaFreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao) FreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.FreeResourcesLimitDao) AccountImpl(org.eclipse.che.account.spi.AccountImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule)

Aggregations

FreeResourcesLimitImpl (org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl)40 Test (org.testng.annotations.Test)26 ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)20 FreeResourcesLimit (org.eclipse.che.multiuser.resource.model.FreeResourcesLimit)10 AccountImpl (org.eclipse.che.account.spi.AccountImpl)8 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 Response (io.restassured.response.Response)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 FreeResourcesLimitDao (org.eclipse.che.multiuser.resource.spi.FreeResourcesLimitDao)6 JpaFreeResourcesLimitDao (org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao)6 HashMap (java.util.HashMap)4 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)4 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)4 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)4 SystemPermissionsImpl (org.eclipse.che.multiuser.api.permission.server.model.impl.SystemPermissionsImpl)4 SystemPermissionsDaoTest (org.eclipse.che.multiuser.api.permission.server.spi.tck.SystemPermissionsDaoTest)4