use of org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl in project che-server by eclipse-che.
the class JpaWorkerDaoTest method shouldThrowServerExceptionOnExistsWhenRuntimeExceptionOccursInDoGetMethod.
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Database exception")
public void shouldThrowServerExceptionOnExistsWhenRuntimeExceptionOccursInDoGetMethod() throws Exception {
final Account account = new AccountImpl("accountId", "namespace", "test");
final WorkspaceImpl workspace = WorkspaceImpl.builder().setId("workspaceId").setAccount(account).build();
// 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();
final UserImpl user = new UserImpl("user0", "user0@com.com", "usr0");
// Persist the user
manager.getTransaction().begin();
manager.persist(user);
manager.getTransaction().commit();
manager.clear();
// Persist the worker
WorkerImpl worker = new WorkerImpl("workspaceId", "user0", Collections.singletonList(SET_PERMISSIONS));
manager.getTransaction().begin();
manager.persist(worker);
manager.getTransaction().commit();
manager.clear();
workerDao.exists("user0", "workspaceId", SET_PERMISSIONS);
}
use of org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl in project che-server by eclipse-che.
the class RemoveWorkersBeforeWorkspaceRemovedEventSubscriberTest method setupEntities.
@BeforeClass
public void setupEntities() throws Exception {
account = new AccountImpl("account1", "accountName", "test");
users = new UserImpl[] { new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2") };
workspace = new WorkspaceImpl("ws1", account, new WorkspaceConfigImpl("", "", "cfg1", null, null, null, null));
workers = new WorkerImpl[] { new WorkerImpl("ws1", "user1", Arrays.asList("read", "use", "run")), new WorkerImpl("ws1", "user2", Arrays.asList("read", "use")) };
Injector injector = Guice.createInjector(new JpaTckModule());
manager = injector.getInstance(EntityManager.class);
workerDao = injector.getInstance(JpaWorkerDao.class);
workspaceDao = injector.getInstance(JpaWorkspaceDao.class);
subscriber = injector.getInstance(RemoveWorkersBeforeWorkspaceRemovedEventSubscriber.class);
subscriber.subscribe();
tckResourcesCleaner = injector.getInstance(TckResourcesCleaner.class);
}
use of org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl in project che-server by eclipse-che.
the class WorkerDaoTest method setUp.
@BeforeMethod
public void setUp() throws TckRepositoryException {
workers = new WorkerImpl[] { new WorkerImpl("ws1", "user1", Arrays.asList("read", "use", "run")), new WorkerImpl("ws1", "user2", Arrays.asList("read", "use")), new WorkerImpl("ws2", "user1", Arrays.asList("read", "run")), new WorkerImpl("ws2", "user2", Arrays.asList("read", "use", "run", "configure")), new WorkerImpl("ws2", "user0", Arrays.asList("read", "use", "run", "configure")) };
final UserImpl[] users = new UserImpl[] { new UserImpl("user0", "user0@com.com", "usr0"), new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2") };
userRepository.createAll(Arrays.asList(users));
AccountImpl account = new AccountImpl("account1", "accountName", "test");
accountRepository.createAll(Collections.singletonList(account));
workspaceRepository.createAll(Arrays.asList(new WorkspaceImpl("ws0", account, new WorkspaceConfigImpl("ws-name0", "", "cfg0", null, null, null, null)), new WorkspaceImpl("ws1", account, new WorkspaceConfigImpl("ws-name1", "", "cfg1", null, null, null, null)), new WorkspaceImpl("ws2", account, new WorkspaceConfigImpl("ws-name2", "", "cfg2", null, null, null, null))));
workerRepository.createAll(Stream.of(workers).map(WorkerImpl::new).collect(Collectors.toList()));
}
use of org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl in project che-server by eclipse-che.
the class MultiuserJpaWorkspaceDaoTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
manager.getTransaction().begin();
manager.persist(account);
for (UserImpl user : users) {
manager.persist(user);
}
for (WorkspaceImpl ws : workspaces) {
manager.persist(ws);
}
for (WorkerImpl worker : workers) {
manager.persist(worker);
}
manager.getTransaction().commit();
manager.clear();
}
use of org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl in project devspaces-images by redhat-developer.
the class MultiuserJpaWorkspaceDaoTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
manager.getTransaction().begin();
manager.persist(account);
for (UserImpl user : users) {
manager.persist(user);
}
for (WorkspaceImpl ws : workspaces) {
manager.persist(ws);
}
for (WorkerImpl worker : workers) {
manager.persist(worker);
}
manager.getTransaction().commit();
manager.clear();
}
Aggregations