Search in sources :

Example 21 with AccountImpl

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()));
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl) Test(org.testng.annotations.Test)

Example 22 with AccountImpl

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);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) 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) TypeLiteral(com.google.inject.TypeLiteral) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) AccountDao(org.eclipse.che.account.spi.AccountDao) JpaAccountDao(org.eclipse.che.account.spi.jpa.JpaAccountDao) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner)

Example 23 with AccountImpl

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));
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl)

Example 24 with AccountImpl

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));
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl)

Example 25 with AccountImpl

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;
}
Also used : EntityManager(javax.persistence.EntityManager) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Transactional(com.google.inject.persist.Transactional)

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