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