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;
}
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);
}
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()));
}
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);
}
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);
}
Aggregations