use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class JpaWorkspaceDaoTest method shouldSyncDbAttributesWhileUpdatingWorkspace.
@Test
public void shouldSyncDbAttributesWhileUpdatingWorkspace() throws Exception {
final AccountImpl account = new AccountImpl("accountId", "namespace", "test");
final WorkspaceImpl workspace = createWorkspace("id", account, "name");
// persist the workspace
manager.getTransaction().begin();
manager.persist(account);
manager.persist(workspace);
manager.getTransaction().commit();
manager.clear();
// put a new attribute
workspace.getConfig().getProjects().get(0).getAttributes().put("new-attr", singletonList("value"));
workspaceDao.update(workspace);
manager.clear();
// check it's okay
assertEquals(workspaceDao.get(workspace.getId()).getConfig().getProjects().get(0).getAttributes().size(), 3);
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class JpaWorkspaceDaoTest method shouldCascadeRemoveObjectsWhenTheyRemovedFromEntity.
@Test
public void shouldCascadeRemoveObjectsWhenTheyRemovedFromEntity() {
final AccountImpl account = new AccountImpl("accountId", "namespace", "test");
final WorkspaceImpl workspace = createWorkspace("id", account, "name");
// Persist the account
manager.getTransaction().begin();
manager.persist(account);
manager.getTransaction().commit();
manager.clear();
// Persist the workspace
manager.getTransaction().begin();
manager.persist(workspace);
manager.getTransaction().commit();
manager.clear();
// Cleanup one to many dependencies
manager.getTransaction().begin();
final WorkspaceConfigImpl config = workspace.getConfig();
config.getProjects().clear();
config.getCommands().clear();
config.getEnvironments().clear();
manager.merge(workspace);
manager.getTransaction().commit();
manager.clear();
// If all the One To Many dependencies are removed then all the embedded objects
// which depend on those object are also removed, which guaranteed by foreign key constraints
assertEquals(asLong("SELECT COUNT(p) FROM ProjectConfig p"), 0L, "Project configs");
assertEquals(asLong("SELECT COUNT(c) FROM Command c"), 0L, "Commands");
assertEquals(asLong("SELECT COUNT(e) FROM Environment e"), 0L, "Environments");
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountDaoTest method shouldUpdateAccount.
@Test(dependsOnMethods = "shouldGetAccountById")
public void shouldUpdateAccount() throws Exception {
AccountImpl account = accounts[0];
account.setName("newName");
account.setType("newType");
accountDao.update(account);
assertEquals(account, accountDao.getById(account.getId()));
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountDaoTest method shouldGetAccountById.
@Test
public void shouldGetAccountById() throws Exception {
final AccountImpl account = accounts[0];
final AccountImpl found = accountDao.getById(account.getId());
assertEquals(account, found);
}
use of org.eclipse.che.account.spi.AccountImpl in project che by eclipse.
the class AccountDaoTest method setUp.
@BeforeMethod
private void setUp() throws TckRepositoryException {
accounts = new AccountImpl[2];
accounts[0] = new AccountImpl(NameGenerator.generate("account", 10), "test1", "test");
accounts[1] = new AccountImpl(NameGenerator.generate("account", 10), "test2", "test");
accountRepo.createAll(asList(accounts));
}
Aggregations