use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountDaoTest method shouldCreateAccount.
@Test(dependsOnMethods = "shouldGetAccountById")
public void shouldCreateAccount() throws Exception {
AccountImpl toCreate = new AccountImpl("account123", "test123", "test");
accountDao.create(toCreate);
assertEquals(toCreate, accountDao.getById(toCreate.getId()));
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountJpaTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClass(AccountImpl.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(AccountDao.class).to(JpaAccountDao.class);
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountManager method create.
/**
* Creates account.
*
* @param account
* account to create
* @throws NullPointerException
* when {@code account} is null
* @throws ConflictException
* when account with such name or id already exists
* @throws ServerException
* when any other error occurs during account creating
*/
public void create(Account account) throws ConflictException, ServerException {
requireNonNull(account, "Required non-null account");
accountDao.create(new AccountImpl(account));
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountManager method update.
/**
* Updates account by replacing an existing account entity with a new one.
*
* @param account
* account to update
* @throws NullPointerException
* when {@code account} is null
* @throws NotFoundException
* when account with id {@code account.getId()} is not found
* @throws ConflictException
* when account's new name is not unique
* @throws ServerException
* when any other error occurs
*/
public void update(Account account) throws NotFoundException, ConflictException, ServerException {
requireNonNull(account, "Required non-null account");
accountDao.update(new AccountImpl(account));
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class JpaAccountDao method doRemove.
@Transactional
protected Optional<AccountImpl> doRemove(String id) {
final EntityManager manager = managerProvider.get();
final Optional<AccountImpl> account = Optional.ofNullable(manager.find(AccountImpl.class, id));
account.ifPresent(manager::remove);
return account;
}
Aggregations