use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class UserDevfilePermissionDaoTest method setUp.
@BeforeMethod
public void setUp() throws TckRepositoryException {
accountRepository.createAll(ImmutableList.of(TestObjectGenerator.TEST_ACCOUNT));
permissions = new UserDevfilePermissionImpl[] { new UserDevfilePermissionImpl("devfile_id1", "user1", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id1", "user2", Arrays.asList(READ, DELETE)), new UserDevfilePermissionImpl("devfile_id2", "user1", Arrays.asList(READ, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user2", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user0", Arrays.asList(READ, DELETE, UPDATE)) };
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));
devfileRepository.createAll(ImmutableList.of(createUserDevfile("devfile_id1", generate("name", 6)), createUserDevfile("devfile_id2", generate("name", 6)), createUserDevfile("devfile_id3", generate("name", 6)), createUserDevfile("devfile_id4", generate("name", 6)), createUserDevfile("devfile_id5", generate("name", 6))));
permissionTckRepository.createAll(Stream.of(permissions).map(UserDevfilePermissionImpl::new).collect(Collectors.toList()));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class UserDevfileTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, VolumeImpl.class, // devfile
UserDevfileImpl.class, UserDevfilePermissionImpl.class, ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfilePermissionImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermissionImpl.class));
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfilePermissionDaoTest.TestDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class JpaTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, UserDevfilePermissionImpl.class, // devfile
ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, UserDevfileImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfilePermissionDaoTest.TestDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
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 che-server by eclipse-che.
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);
}
Aggregations