Search in sources :

Example 1 with AccountManager

use of org.eclipse.che.account.api.AccountManager in project che-server by eclipse-che.

the class CascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    server = H2DBTestServer.startDefault();
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, WorkspaceActivity.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, SshPairImpl.class, VolumeImpl.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, KubernetesRuntimeState.class, KubernetesRuntimeCommandImpl.class, KubernetesMachineImpl.class, KubernetesMachineImpl.MachineId.class, KubernetesServerImpl.class, KubernetesServerImpl.ServerId.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
            bind(EventService.class).in(Singleton.class);
            install(new InitModule(PostConstruct.class));
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            bind(String[].class).annotatedWith(Names.named("che.auth.reserved_user_names")).toInstance(new String[0]);
            bind(Long.class).annotatedWith(Names.named("che.limits.workspace.idle.timeout")).toInstance(100000L);
            bind(Long.class).annotatedWith(Names.named("che.limits.workspace.run.timeout")).toInstance(0L);
            bind(UserManager.class);
            bind(AccountManager.class);
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new WorkspaceJpaModule());
            install(new WorkspaceActivityModule());
            install(new JpaKubernetesRuntimeCacheModule());
            bind(ExecutorServiceWrapper.class).to(NoopExecutorServiceWrapper.class);
            // initialize empty binder
            Multibinder.newSetBinder(binder(), WorkspaceAttributeValidator.class);
            bind(WorkspaceManager.class);
            RuntimeInfrastructure infra = mock(RuntimeInfrastructure.class);
            doReturn(emptySet()).when(infra).getRecipeTypes();
            bind(RuntimeInfrastructure.class).toInstance(infra);
            WorkspaceRuntimes wR = spy(new WorkspaceRuntimes(mock(EventService.class), emptyMap(), infra, mock(WorkspaceSharedPool.class), mock(WorkspaceDao.class), mock(DBInitializer.class), mock(ProbeScheduler.class), new DefaultWorkspaceStatusCache(), new DefaultWorkspaceLockService(), mock(DevfileConverter.class), false));
            when(wR.hasRuntime(anyString())).thenReturn(false);
            bind(WorkspaceRuntimes.class).toInstance(wR);
            bind(AccountManager.class);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null, new NoopExecutorServiceWrapper()));
            MapBinder.newMapBinder(binder(), String.class, ComponentIntegrityValidator.class).addBinding("kubernetes").toInstance(mock(ComponentIntegrityValidator.class));
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    userDao = injector.getInstance(UserDao.class);
    userManager = injector.getInstance(UserManager.class);
    accountManager = injector.getInstance(AccountManager.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
    workspaceActivityDao = injector.getInstance(WorkspaceActivityDao.class);
    k8sRuntimes = injector.getInstance(KubernetesRuntimeStateCache.class);
    k8sMachines = injector.getInstance(KubernetesMachineCache.class);
}
Also used : DefaultWorkspaceLockService(org.eclipse.che.api.workspace.server.DefaultWorkspaceLockService) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) SshPairImpl(org.eclipse.che.api.ssh.server.model.impl.SshPairImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) PreferenceEntity(org.eclipse.che.api.user.server.jpa.PreferenceEntity) ExecutorServiceWrapper(org.eclipse.che.commons.observability.ExecutorServiceWrapper) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) InitModule(org.eclipse.che.inject.lifecycle.InitModule) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) WorkspaceActivity(org.eclipse.che.api.workspace.activity.WorkspaceActivity) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) WorkspaceRuntimes(org.eclipse.che.api.workspace.server.WorkspaceRuntimes) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) AccountDao(org.eclipse.che.account.spi.AccountDao) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) WorkspaceActivityDao(org.eclipse.che.api.workspace.activity.WorkspaceActivityDao) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) RecipeImpl(org.eclipse.che.api.workspace.server.model.impl.RecipeImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.VolumeImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) AccountManager(org.eclipse.che.account.api.AccountManager) WorkspaceActivityModule(org.eclipse.che.api.workspace.activity.inject.WorkspaceActivityModule) PostConstruct(jakarta.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) RuntimeInfrastructure(org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure) DefaultWorkspaceStatusCache(org.eclipse.che.api.workspace.server.DefaultWorkspaceStatusCache) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) ComponentIntegrityValidator(org.eclipse.che.api.workspace.server.devfile.validator.ComponentIntegrityValidator) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) KubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache) JpaKubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.jpa.JpaKubernetesMachineCache) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) JpaKubernetesRuntimeCacheModule(org.eclipse.che.workspace.infrastructure.kubernetes.cache.jpa.JpaKubernetesRuntimeCacheModule) EntrypointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) EventService(org.eclipse.che.api.core.notification.EventService) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) KubernetesRuntimeStateCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache) AbstractModule(com.google.inject.AbstractModule) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) UserManager(org.eclipse.che.api.user.server.UserManager) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) WorkspaceJpaModule(org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with AccountManager

use of org.eclipse.che.account.api.AccountManager in project che-server by eclipse-che.

the class JpaEntitiesCascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            H2DBTestServer server = H2DBTestServer.startDefault();
            install(new JpaPersistModule("main"));
            bind(H2JpaCleaner.class).toInstance(new H2JpaCleaner(server));
            bind(EventService.class).in(Singleton.class);
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            install(new InitModule(PostConstruct.class));
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new FactoryJpaModule());
            install(new OrganizationJpaModule());
            install(new MultiuserWorkspaceJpaModule());
            install(new MachineAuthModule());
            install(new DevfileModule());
            install(new MultiuserUserDevfileJpaModule());
            bind(ExecutorServiceWrapper.class).to(NoopExecutorServiceWrapper.class);
            bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
            bind(RemoveFreeResourcesLimitSubscriber.class).asEagerSingleton();
            // initialize empty binder
            Multibinder.newSetBinder(binder(), WorkspaceAttributeValidator.class);
            bind(WorkspaceManager.class);
            bind(WorkspaceLockService.class).to(DefaultWorkspaceLockService.class);
            bind(WorkspaceStatusCache.class).to(DefaultWorkspaceStatusCache.class);
            bind(RuntimeInfrastructure.class).toInstance(mock(RuntimeInfrastructure.class));
            MapBinder.newMapBinder(binder(), String.class, InternalEnvironmentFactory.class);
            bind(PermissionsManager.class);
            bind(PermissionChecker.class).to(PermissionCheckerImpl.class);
            bind(AccountManager.class);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_snapshot")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_restore")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.devworkspaces.enabled")).toInstance(false);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null, new NoopExecutorServiceWrapper()));
            bind(String[].class).annotatedWith(Names.named("che.auth.reserved_user_names")).toInstance(new String[0]);
            bind(RemoveOrganizationOnLastUserRemovedEventSubscriber.class).asEagerSingleton();
            Multibinder.newSetBinder(binder(), ResourceLockKeyProvider.class);
            Multibinder.newSetBinder(binder(), ResourceUsageTracker.class);
            MapBinder.newMapBinder(binder(), String.class, AvailableResourcesProvider.class);
            bind(String.class).annotatedWith(Names.named("che.workspace.plugin_registry_url")).toInstance("");
            bind(String.class).annotatedWith(Names.named("che.factory.scm_file_fetcher_limit_bytes")).toInstance("1024");
            MapBinder.newMapBinder(binder(), String.class, ChePluginsApplier.class);
            Multibinder.newSetBinder(binder(), ResourceType.class).addBinding().to(RamResourceType.class);
            Multibinder.newSetBinder(binder(), ResourcesProvider.class).addBinding().toInstance((accountId) -> singletonList(new ProvidedResourcesImpl("test", null, accountId, -1L, -1L, singletonList(new ResourceImpl(RamResourceType.ID, 1024, RamResourceType.UNIT)))));
            bindConstant().annotatedWith(Names.named("che.workspace.probe_pool_size")).to(1);
            // setup bindings for the devfile that would otherwise be read from the config
            bindConstant().annotatedWith(Names.named("che.workspace.devfile.default_editor")).to("default/editor/0.0.1");
            bindConstant().annotatedWith(Names.named("che.websocket.endpoint")).to("che.websocket.endpoint");
            bind(String.class).annotatedWith(Names.named("che.workspace.devfile.default_editor.plugins")).toInstance("default/plugin/0.0.1");
            bind(String.class).annotatedWith(Names.named("che.workspace.devfile.async.storage.plugin")).toInstance("");
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    accountManager = injector.getInstance(AccountManager.class);
    userDao = injector.getInstance(UserDao.class);
    userManager = injector.getInstance(UserManager.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
    factoryDao = injector.getInstance(FactoryDao.class);
    workerDao = injector.getInstance(WorkerDao.class);
    userDevfileDao = injector.getInstance(UserDevfileDao.class);
    userDevfilePermissionDao = injector.getInstance(UserDevfilePermissionDao.class);
    signatureKeyDao = injector.getInstance(SignatureKeyDao.class);
    freeResourcesLimitDao = injector.getInstance(FreeResourcesLimitDao.class);
    organizationManager = injector.getInstance(OrganizationManager.class);
    memberDao = injector.getInstance(MemberDao.class);
    organizationResourcesDistributor = injector.getInstance(OrganizationResourcesDistributor.class);
    h2JpaCleaner = injector.getInstance(H2JpaCleaner.class);
}
Also used : RuntimeInfrastructure(org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure) ProvidedResourcesImpl(org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl) ExecutorServiceWrapper(org.eclipse.che.commons.observability.ExecutorServiceWrapper) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) UserDevfilePermissionDao(org.eclipse.che.multiuser.permission.devfile.server.spi.UserDevfilePermissionDao) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) MemberDao(org.eclipse.che.multiuser.organization.spi.MemberDao) InitModule(org.eclipse.che.inject.lifecycle.InitModule) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) OrganizationManager(org.eclipse.che.multiuser.organization.api.OrganizationManager) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) UserDevfileDao(org.eclipse.che.api.devfile.server.spi.UserDevfileDao) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) SignatureKeyDao(org.eclipse.che.multiuser.machine.authentication.server.signature.spi.SignatureKeyDao) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) WorkerDao(org.eclipse.che.multiuser.permission.workspace.server.spi.WorkerDao) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) PermissionChecker(org.eclipse.che.multiuser.api.permission.server.PermissionChecker) DevfileModule(org.eclipse.che.api.workspace.server.devfile.DevfileModule) FactoryDao(org.eclipse.che.api.factory.server.spi.FactoryDao) RemoveFreeResourcesLimitSubscriber(org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao.RemoveFreeResourcesLimitSubscriber) WorkspaceLockService(org.eclipse.che.api.workspace.server.WorkspaceLockService) DefaultWorkspaceLockService(org.eclipse.che.api.workspace.server.DefaultWorkspaceLockService) OrganizationResourcesDistributor(org.eclipse.che.multiuser.organization.api.resource.OrganizationResourcesDistributor) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) OrganizationJpaModule(org.eclipse.che.multiuser.organization.api.OrganizationJpaModule) DefaultWorkspaceStatusCache(org.eclipse.che.api.workspace.server.DefaultWorkspaceStatusCache) WorkspaceStatusCache(org.eclipse.che.api.workspace.server.WorkspaceStatusCache) MultiuserUserDevfileJpaModule(org.eclipse.che.multiuser.permission.devfile.server.jpa.MultiuserUserDevfileJpaModule) EventService(org.eclipse.che.api.core.notification.EventService) FactoryJpaModule(org.eclipse.che.api.factory.server.jpa.FactoryJpaModule) MultiuserWorkspaceJpaModule(org.eclipse.che.multiuser.permission.workspace.server.jpa.MultiuserWorkspaceJpaModule) AccountDao(org.eclipse.che.account.spi.AccountDao) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule) AbstractModule(com.google.inject.AbstractModule) MachineAuthModule(org.eclipse.che.multiuser.machine.authentication.server.MachineAuthModule) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) UserManager(org.eclipse.che.api.user.server.UserManager) FreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.FreeResourcesLimitDao) JpaFreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao) RemoveOrganizationOnLastUserRemovedEventSubscriber(org.eclipse.che.multiuser.organization.api.listener.RemoveOrganizationOnLastUserRemovedEventSubscriber) AccountManager(org.eclipse.che.account.api.AccountManager) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) PostConstruct(jakarta.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with AccountManager

use of org.eclipse.che.account.api.AccountManager in project devspaces-images by redhat-developer.

the class JpaEntitiesCascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            H2DBTestServer server = H2DBTestServer.startDefault();
            install(new JpaPersistModule("main"));
            bind(H2JpaCleaner.class).toInstance(new H2JpaCleaner(server));
            bind(EventService.class).in(Singleton.class);
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            install(new InitModule(PostConstruct.class));
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new FactoryJpaModule());
            install(new OrganizationJpaModule());
            install(new MultiuserWorkspaceJpaModule());
            install(new MachineAuthModule());
            install(new DevfileModule());
            install(new MultiuserUserDevfileJpaModule());
            bind(ExecutorServiceWrapper.class).to(NoopExecutorServiceWrapper.class);
            bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
            bind(RemoveFreeResourcesLimitSubscriber.class).asEagerSingleton();
            // initialize empty binder
            Multibinder.newSetBinder(binder(), WorkspaceAttributeValidator.class);
            bind(WorkspaceManager.class);
            bind(WorkspaceLockService.class).to(DefaultWorkspaceLockService.class);
            bind(WorkspaceStatusCache.class).to(DefaultWorkspaceStatusCache.class);
            bind(RuntimeInfrastructure.class).toInstance(mock(RuntimeInfrastructure.class));
            MapBinder.newMapBinder(binder(), String.class, InternalEnvironmentFactory.class);
            bind(PermissionsManager.class);
            bind(PermissionChecker.class).to(PermissionCheckerImpl.class);
            bind(AccountManager.class);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_snapshot")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_restore")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.devworkspaces.enabled")).toInstance(false);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null, new NoopExecutorServiceWrapper()));
            bind(String[].class).annotatedWith(Names.named("che.auth.reserved_user_names")).toInstance(new String[0]);
            bind(RemoveOrganizationOnLastUserRemovedEventSubscriber.class).asEagerSingleton();
            Multibinder.newSetBinder(binder(), ResourceLockKeyProvider.class);
            Multibinder.newSetBinder(binder(), ResourceUsageTracker.class);
            MapBinder.newMapBinder(binder(), String.class, AvailableResourcesProvider.class);
            bind(String.class).annotatedWith(Names.named("che.workspace.plugin_registry_url")).toInstance("");
            bind(String.class).annotatedWith(Names.named("che.factory.scm_file_fetcher_limit_bytes")).toInstance("1024");
            MapBinder.newMapBinder(binder(), String.class, ChePluginsApplier.class);
            Multibinder.newSetBinder(binder(), ResourceType.class).addBinding().to(RamResourceType.class);
            Multibinder.newSetBinder(binder(), ResourcesProvider.class).addBinding().toInstance((accountId) -> singletonList(new ProvidedResourcesImpl("test", null, accountId, -1L, -1L, singletonList(new ResourceImpl(RamResourceType.ID, 1024, RamResourceType.UNIT)))));
            bindConstant().annotatedWith(Names.named("che.workspace.probe_pool_size")).to(1);
            // setup bindings for the devfile that would otherwise be read from the config
            bindConstant().annotatedWith(Names.named("che.workspace.devfile.default_editor")).to("default/editor/0.0.1");
            bindConstant().annotatedWith(Names.named("che.websocket.endpoint")).to("che.websocket.endpoint");
            bind(String.class).annotatedWith(Names.named("che.workspace.devfile.default_editor.plugins")).toInstance("default/plugin/0.0.1");
            bind(String.class).annotatedWith(Names.named("che.workspace.devfile.async.storage.plugin")).toInstance("");
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    accountManager = injector.getInstance(AccountManager.class);
    userDao = injector.getInstance(UserDao.class);
    userManager = injector.getInstance(UserManager.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
    factoryDao = injector.getInstance(FactoryDao.class);
    workerDao = injector.getInstance(WorkerDao.class);
    userDevfileDao = injector.getInstance(UserDevfileDao.class);
    userDevfilePermissionDao = injector.getInstance(UserDevfilePermissionDao.class);
    signatureKeyDao = injector.getInstance(SignatureKeyDao.class);
    freeResourcesLimitDao = injector.getInstance(FreeResourcesLimitDao.class);
    organizationManager = injector.getInstance(OrganizationManager.class);
    memberDao = injector.getInstance(MemberDao.class);
    organizationResourcesDistributor = injector.getInstance(OrganizationResourcesDistributor.class);
    h2JpaCleaner = injector.getInstance(H2JpaCleaner.class);
}
Also used : RuntimeInfrastructure(org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure) ProvidedResourcesImpl(org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl) ExecutorServiceWrapper(org.eclipse.che.commons.observability.ExecutorServiceWrapper) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) UserDevfilePermissionDao(org.eclipse.che.multiuser.permission.devfile.server.spi.UserDevfilePermissionDao) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) MemberDao(org.eclipse.che.multiuser.organization.spi.MemberDao) InitModule(org.eclipse.che.inject.lifecycle.InitModule) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) OrganizationManager(org.eclipse.che.multiuser.organization.api.OrganizationManager) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) UserDevfileDao(org.eclipse.che.api.devfile.server.spi.UserDevfileDao) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) SignatureKeyDao(org.eclipse.che.multiuser.machine.authentication.server.signature.spi.SignatureKeyDao) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) WorkerDao(org.eclipse.che.multiuser.permission.workspace.server.spi.WorkerDao) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) PermissionChecker(org.eclipse.che.multiuser.api.permission.server.PermissionChecker) DevfileModule(org.eclipse.che.api.workspace.server.devfile.DevfileModule) FactoryDao(org.eclipse.che.api.factory.server.spi.FactoryDao) RemoveFreeResourcesLimitSubscriber(org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao.RemoveFreeResourcesLimitSubscriber) WorkspaceLockService(org.eclipse.che.api.workspace.server.WorkspaceLockService) DefaultWorkspaceLockService(org.eclipse.che.api.workspace.server.DefaultWorkspaceLockService) OrganizationResourcesDistributor(org.eclipse.che.multiuser.organization.api.resource.OrganizationResourcesDistributor) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) OrganizationJpaModule(org.eclipse.che.multiuser.organization.api.OrganizationJpaModule) DefaultWorkspaceStatusCache(org.eclipse.che.api.workspace.server.DefaultWorkspaceStatusCache) WorkspaceStatusCache(org.eclipse.che.api.workspace.server.WorkspaceStatusCache) MultiuserUserDevfileJpaModule(org.eclipse.che.multiuser.permission.devfile.server.jpa.MultiuserUserDevfileJpaModule) EventService(org.eclipse.che.api.core.notification.EventService) FactoryJpaModule(org.eclipse.che.api.factory.server.jpa.FactoryJpaModule) MultiuserWorkspaceJpaModule(org.eclipse.che.multiuser.permission.workspace.server.jpa.MultiuserWorkspaceJpaModule) AccountDao(org.eclipse.che.account.spi.AccountDao) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule) AbstractModule(com.google.inject.AbstractModule) MachineAuthModule(org.eclipse.che.multiuser.machine.authentication.server.MachineAuthModule) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) UserManager(org.eclipse.che.api.user.server.UserManager) FreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.FreeResourcesLimitDao) JpaFreeResourcesLimitDao(org.eclipse.che.multiuser.resource.spi.jpa.JpaFreeResourcesLimitDao) RemoveOrganizationOnLastUserRemovedEventSubscriber(org.eclipse.che.multiuser.organization.api.listener.RemoveOrganizationOnLastUserRemovedEventSubscriber) AccountManager(org.eclipse.che.account.api.AccountManager) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) PostConstruct(jakarta.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with AccountManager

use of org.eclipse.che.account.api.AccountManager in project devspaces-images by redhat-developer.

the class CascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    server = H2DBTestServer.startDefault();
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, WorkspaceActivity.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, SshPairImpl.class, VolumeImpl.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, KubernetesRuntimeState.class, KubernetesRuntimeCommandImpl.class, KubernetesMachineImpl.class, KubernetesMachineImpl.MachineId.class, KubernetesServerImpl.class, KubernetesServerImpl.ServerId.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
            bind(EventService.class).in(Singleton.class);
            install(new InitModule(PostConstruct.class));
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            bind(String[].class).annotatedWith(Names.named("che.auth.reserved_user_names")).toInstance(new String[0]);
            bind(Long.class).annotatedWith(Names.named("che.limits.workspace.idle.timeout")).toInstance(100000L);
            bind(Long.class).annotatedWith(Names.named("che.limits.workspace.run.timeout")).toInstance(0L);
            bind(UserManager.class);
            bind(AccountManager.class);
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new WorkspaceJpaModule());
            install(new WorkspaceActivityModule());
            install(new JpaKubernetesRuntimeCacheModule());
            bind(ExecutorServiceWrapper.class).to(NoopExecutorServiceWrapper.class);
            // initialize empty binder
            Multibinder.newSetBinder(binder(), WorkspaceAttributeValidator.class);
            bind(WorkspaceManager.class);
            RuntimeInfrastructure infra = mock(RuntimeInfrastructure.class);
            doReturn(emptySet()).when(infra).getRecipeTypes();
            bind(RuntimeInfrastructure.class).toInstance(infra);
            WorkspaceRuntimes wR = spy(new WorkspaceRuntimes(mock(EventService.class), emptyMap(), infra, mock(WorkspaceSharedPool.class), mock(WorkspaceDao.class), mock(DBInitializer.class), mock(ProbeScheduler.class), new DefaultWorkspaceStatusCache(), new DefaultWorkspaceLockService(), mock(DevfileConverter.class), false));
            when(wR.hasRuntime(anyString())).thenReturn(false);
            bind(WorkspaceRuntimes.class).toInstance(wR);
            bind(AccountManager.class);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null, new NoopExecutorServiceWrapper()));
            MapBinder.newMapBinder(binder(), String.class, ComponentIntegrityValidator.class).addBinding("kubernetes").toInstance(mock(ComponentIntegrityValidator.class));
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    userDao = injector.getInstance(UserDao.class);
    userManager = injector.getInstance(UserManager.class);
    accountManager = injector.getInstance(AccountManager.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
    workspaceActivityDao = injector.getInstance(WorkspaceActivityDao.class);
    k8sRuntimes = injector.getInstance(KubernetesRuntimeStateCache.class);
    k8sMachines = injector.getInstance(KubernetesMachineCache.class);
}
Also used : DefaultWorkspaceLockService(org.eclipse.che.api.workspace.server.DefaultWorkspaceLockService) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) SshPairImpl(org.eclipse.che.api.ssh.server.model.impl.SshPairImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) PreferenceEntity(org.eclipse.che.api.user.server.jpa.PreferenceEntity) ExecutorServiceWrapper(org.eclipse.che.commons.observability.ExecutorServiceWrapper) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) InitModule(org.eclipse.che.inject.lifecycle.InitModule) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NoopExecutorServiceWrapper(org.eclipse.che.commons.observability.NoopExecutorServiceWrapper) WorkspaceActivity(org.eclipse.che.api.workspace.activity.WorkspaceActivity) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) WorkspaceRuntimes(org.eclipse.che.api.workspace.server.WorkspaceRuntimes) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) AccountDao(org.eclipse.che.account.spi.AccountDao) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) WorkspaceActivityDao(org.eclipse.che.api.workspace.activity.WorkspaceActivityDao) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) RecipeImpl(org.eclipse.che.api.workspace.server.model.impl.RecipeImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.VolumeImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) AccountManager(org.eclipse.che.account.api.AccountManager) WorkspaceActivityModule(org.eclipse.che.api.workspace.activity.inject.WorkspaceActivityModule) PostConstruct(jakarta.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) RuntimeInfrastructure(org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure) DefaultWorkspaceStatusCache(org.eclipse.che.api.workspace.server.DefaultWorkspaceStatusCache) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) ComponentIntegrityValidator(org.eclipse.che.api.workspace.server.devfile.validator.ComponentIntegrityValidator) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) KubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache) JpaKubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.jpa.JpaKubernetesMachineCache) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) JpaKubernetesRuntimeCacheModule(org.eclipse.che.workspace.infrastructure.kubernetes.cache.jpa.JpaKubernetesRuntimeCacheModule) EntrypointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) EventService(org.eclipse.che.api.core.notification.EventService) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) KubernetesRuntimeStateCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache) AbstractModule(com.google.inject.AbstractModule) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) UserManager(org.eclipse.che.api.user.server.UserManager) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) WorkspaceJpaModule(org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

AbstractModule (com.google.inject.AbstractModule)4 PostConstruct (jakarta.annotation.PostConstruct)4 AccountManager (org.eclipse.che.account.api.AccountManager)4 AccountModule (org.eclipse.che.account.api.AccountModule)4 AccountDao (org.eclipse.che.account.spi.AccountDao)4 EventService (org.eclipse.che.api.core.notification.EventService)4 SshJpaModule (org.eclipse.che.api.ssh.server.jpa.SshJpaModule)4 SshDao (org.eclipse.che.api.ssh.server.spi.SshDao)4 UserManager (org.eclipse.che.api.user.server.UserManager)4 UserJpaModule (org.eclipse.che.api.user.server.jpa.UserJpaModule)4 PreferenceDao (org.eclipse.che.api.user.server.spi.PreferenceDao)4 ProfileDao (org.eclipse.che.api.user.server.spi.ProfileDao)4 UserDao (org.eclipse.che.api.user.server.spi.UserDao)4 DefaultWorkspaceLockService (org.eclipse.che.api.workspace.server.DefaultWorkspaceLockService)4 DefaultWorkspaceStatusCache (org.eclipse.che.api.workspace.server.DefaultWorkspaceStatusCache)4 WorkspaceSharedPool (org.eclipse.che.api.workspace.server.WorkspaceSharedPool)4 RuntimeInfrastructure (org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure)4 WorkspaceDao (org.eclipse.che.api.workspace.server.spi.WorkspaceDao)4 ExecutorServiceWrapper (org.eclipse.che.commons.observability.ExecutorServiceWrapper)4 NoopExecutorServiceWrapper (org.eclipse.che.commons.observability.NoopExecutorServiceWrapper)4