Search in sources :

Example 1 with AccountImpl

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

the class SnapshotDaoTest method createSnapshots.

@BeforeMethod
private void createSnapshots() throws TckRepositoryException {
    // one account for all the workspaces
    final AccountImpl account = new AccountImpl("account1", "name", "type");
    // workspaces
    workspaces = new TestWorkspace[SNAPSHOTS_SIZE / 3];
    for (int i = 0; i < workspaces.length; i++) {
        workspaces[i] = new TestWorkspace("workspace-" + i, account.getId());
    }
    // snapshots
    snapshots = new SnapshotImpl[SNAPSHOTS_SIZE];
    for (int i = 0; i < SNAPSHOTS_SIZE; i++) {
        snapshots[i] = createSnapshot("snapshot-" + i, // 3 snapshot share the same workspace id
        workspaces[i / 3].getId(), // 2 snapshots share the same env name
        "environment-" + i / 2, "machine-" + i);
    }
    accountRepo.createAll(singletonList(account));
    workspaceRepo.createAll(asList(workspaces));
    snaphotRepo.createAll(asList(snapshots));
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with AccountImpl

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

the class JpaTckModule method configure.

@Override
protected void configure() {
    install(new JpaPersistModule("main"));
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(H2TestHelper.inMemoryDefault(), "che-schema"));
    bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
    bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
    }).toInstance(new JpaTckRepository<>(RecipeImpl.class));
    bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {
    }).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
    bind(new TypeLiteral<TckRepository<Workspace>>() {
    }).toInstance(new TestWorkspacesTckRepository());
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(RecipeDao.class).to(JpaRecipeDao.class);
    bind(SnapshotDao.class).to(JpaSnapshotDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule) 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) SnapshotDao(org.eclipse.che.api.machine.server.spi.SnapshotDao) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) RecipeDao(org.eclipse.che.api.machine.server.spi.RecipeDao) RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) Workspace(org.eclipse.che.api.core.model.workspace.Workspace)

Example 3 with AccountImpl

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

the class AccountDaoTest method shouldGetAccountByName.

@Test
public void shouldGetAccountByName() throws Exception {
    final AccountImpl account = accounts[0];
    final AccountImpl found = accountDao.getByName(account.getName());
    assertEquals(account, found);
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl) Test(org.testng.annotations.Test)

Example 4 with AccountImpl

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

the class JpaAccountDao method doUpdate.

@Transactional
protected void doUpdate(AccountImpl update) throws NotFoundException {
    final EntityManager manager = managerProvider.get();
    final AccountImpl account = manager.find(AccountImpl.class, update.getId());
    if (account == null) {
        throw new NotFoundException(format("Couldn't update account with id '%s' because it doesn't exist", update.getId()));
    }
    manager.merge(update);
    manager.flush();
}
Also used : EntityManager(javax.persistence.EntityManager) AccountImpl(org.eclipse.che.account.spi.AccountImpl) NotFoundException(org.eclipse.che.api.core.NotFoundException) Transactional(com.google.inject.persist.Transactional)

Example 5 with AccountImpl

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

the class AccountDaoTest method shouldThrowNotFoundExceptionWhenUpdatingNonExistingAccount.

@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundExceptionWhenUpdatingNonExistingAccount() throws Exception {
    AccountImpl account = accounts[0];
    account.setId("nonExisting");
    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