Search in sources :

Example 6 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitManager method store.

/**
 * Stores (creates new one or updates existed) free resource limit.
 *
 * @param freeResourcesLimit resources limit to store
 * @return stored resources limit
 * @throws NullPointerException when {@code freeResourcesLimit} is null
 * @throws NotFoundException when resources limit contains resource with non supported type
 * @throws ConflictException when the specified account doesn't exist
 * @throws ServerException when any other error occurs
 */
public FreeResourcesLimit store(FreeResourcesLimit freeResourcesLimit) throws NotFoundException, ConflictException, ServerException {
    requireNonNull(freeResourcesLimit, "Required non-null free resources limit");
    final FreeResourcesLimitImpl toStore = new FreeResourcesLimitImpl(freeResourcesLimit);
    freeResourcesLimitDao.store(toStore);
    return toStore;
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl)

Example 7 with FreeResourcesLimitImpl

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

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 8 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitDaoTest method setUp.

@BeforeMethod
private void setUp() throws Exception {
    accounts = new AccountImpl[COUNTS_OF_LIMITS];
    limits = new FreeResourcesLimitImpl[COUNTS_OF_LIMITS];
    for (int i = 0; i < COUNTS_OF_LIMITS; i++) {
        accounts[i] = new AccountImpl("accountId-" + i, "accountName" + i, "test");
        limits[i] = new FreeResourcesLimitImpl(accounts[i].getId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, i, "test")));
    }
    accountRepository.createAll(Arrays.asList(accounts));
    limitRepository.createAll(Stream.of(limits).map(FreeResourcesLimitImpl::new).collect(Collectors.toList()));
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 9 with FreeResourcesLimitImpl

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

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)

Example 10 with FreeResourcesLimitImpl

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

the class FreeResourcesLimitDaoTest method shouldThrowConflictExceptionWhenTryStoreNewResourcesWithSpecifiedNotExistingAccount.

@Test(expectedExceptions = ConflictException.class, expectedExceptionsMessageRegExp = "The specified account 'non-existing' does not exist")
public void shouldThrowConflictExceptionWhenTryStoreNewResourcesWithSpecifiedNotExistingAccount() throws Exception {
    // given
    FreeResourcesLimitImpl toStore = new FreeResourcesLimitImpl("non-existing", limits[0].getResources());
    // when
    limitDao.store(toStore);
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) Test(org.testng.annotations.Test)

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