Search in sources :

Example 26 with AccountImpl

use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.

the class JpaAccountDao method getById.

@Override
@Transactional
public AccountImpl getById(String id) throws NotFoundException, ServerException {
    requireNonNull(id, "Required non-null account id");
    final EntityManager manager = managerProvider.get();
    try {
        AccountImpl account = manager.find(AccountImpl.class, id);
        if (account == null) {
            throw new NotFoundException(format("Account with id '%s' was not found", id));
        }
        return account;
    } catch (RuntimeException x) {
        throw new ServerException(x.getLocalizedMessage(), x);
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ServerException(org.eclipse.che.api.core.ServerException) AccountImpl(org.eclipse.che.account.spi.AccountImpl) NotFoundException(org.eclipse.che.api.core.NotFoundException) Transactional(com.google.inject.persist.Transactional)

Example 27 with AccountImpl

use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.

the class AccountDaoTest method shouldThrowConflictExceptionWhenUpdatingAccountWithExistingName.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenUpdatingAccountWithExistingName() throws Exception {
    AccountImpl account = accounts[0];
    account.setName(accounts[1].getName());
    accountDao.update(account);
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl) Test(org.testng.annotations.Test)

Aggregations

AccountImpl (org.eclipse.che.account.spi.AccountImpl)27 Test (org.testng.annotations.Test)13 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)12 BeforeMethod (org.testng.annotations.BeforeMethod)5 TypeLiteral (com.google.inject.TypeLiteral)4 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)4 DBInitializer (org.eclipse.che.core.db.DBInitializer)4 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)4 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)4 Transactional (com.google.inject.persist.Transactional)3 EntityManager (javax.persistence.EntityManager)3 NotFoundException (org.eclipse.che.api.core.NotFoundException)3 AccountDao (org.eclipse.che.account.spi.AccountDao)2 JpaAccountDao (org.eclipse.che.account.spi.jpa.JpaAccountDao)2 ServerException (org.eclipse.che.api.core.ServerException)2 Workspace (org.eclipse.che.api.core.model.workspace.Workspace)2 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)2 SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)2 RecipeImpl (org.eclipse.che.api.machine.server.recipe.RecipeImpl)2 RecipeDao (org.eclipse.che.api.machine.server.spi.RecipeDao)2