use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class JpaUserDevfilePermissionDaoTest method shouldThrowServerExceptionOnExistsWhenRuntimeExceptionOccursInDoGetMethod.
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Database exception")
public void shouldThrowServerExceptionOnExistsWhenRuntimeExceptionOccursInDoGetMethod() throws Exception {
// Persist the account
manager.getTransaction().begin();
manager.persist(TestObjectGenerator.TEST_ACCOUNT);
manager.getTransaction().commit();
manager.clear();
final UserDevfileImpl userDevfile = TestObjectGenerator.createUserDevfile();
// Persist the userdevfile
manager.getTransaction().begin();
manager.persist(userDevfile);
manager.getTransaction().commit();
manager.clear();
final UserImpl user = new UserImpl(generate("user", 6), "user0@com.com", "usr0");
// Persist the user
manager.getTransaction().begin();
manager.persist(user);
manager.getTransaction().commit();
manager.clear();
// Persist the worker
UserDevfilePermissionImpl worker = new UserDevfilePermissionImpl(userDevfile.getId(), user.getId(), Collections.singletonList(SET_PERMISSIONS));
manager.getTransaction().begin();
manager.persist(worker);
manager.getTransaction().commit();
manager.clear();
userDevfilePermissionsDao.exists(user.getId(), userDevfile.getId(), SET_PERMISSIONS);
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class RemoveUserDevfilePermissionsBeforeUserDevfileRemovedEventSubscriberTest method setupEntities.
@BeforeClass
public void setupEntities() throws Exception {
users = new UserImpl[] { new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2") };
userDevfile = TestObjectGenerator.createUserDevfile("devfile_id1", generate("name", 6));
userDevfilePermissions = new UserDevfilePermissionImpl[] { new UserDevfilePermissionImpl(userDevfile.getId(), "user1", Arrays.asList("read", "use", "run")), new UserDevfilePermissionImpl(userDevfile.getId(), "user2", Arrays.asList("read", "use")) };
Injector injector = Guice.createInjector(new JpaTckModule());
manager = injector.getInstance(EntityManager.class);
userDevfilePermissionsDao = injector.getInstance(JpaUserDevfilePermissionDao.class);
userDevfileDao = injector.getInstance(JpaUserDevfileDao.class);
subscriber = injector.getInstance(RemoveUserDevfilePermissionsBeforeUserDevfileRemovedEventSubscriber.class);
subscriber.subscribe();
tckResourcesCleaner = injector.getInstance(TckResourcesCleaner.class);
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class UserDevfilePermissionDaoTest method shouldReplaceExistingPermissionOnStoring.
@Test
public void shouldReplaceExistingPermissionOnStoring() throws Exception {
UserDevfilePermissionImpl replace = new UserDevfilePermissionImpl("devfile_id1", "user1", Collections.singletonList("READ"));
permissionDao.store(replace);
Assert.assertEquals(permissionDao.getUserDevfilePermission("devfile_id1", "user1"), replace);
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class UserDevfilePermissionDaoTest method shouldStorePermissions.
@Test
public void shouldStorePermissions() throws Exception {
UserDevfilePermissionImpl permission = new UserDevfilePermissionImpl("devfile_id1", "user0", Arrays.asList(READ, DELETE, UPDATE));
permissionDao.store(permission);
Assert.assertEquals(permissionDao.getUserDevfilePermission("devfile_id1", "user0"), new UserDevfilePermissionImpl(permission));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class JpaUserDevfilePermissionDao method get.
@Override
public UserDevfilePermissionImpl get(String userId, String instanceId) throws ServerException, NotFoundException {
requireNonNull(instanceId, "User devfile identifier required");
requireNonNull(userId, "User identifier required");
try {
return new UserDevfilePermissionImpl(getEntity(wildcardToNull(userId), instanceId));
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
Aggregations