Search in sources :

Example 31 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project google-cloud-intellij by GoogleCloudPlatform.

the class TestUtils method installMockService.

/**
 * Register a service class with the container.
 */
@NotNull
public static <T> T installMockService(@NotNull Class<T> serviceInterface) {
    T mock = Mockito.mock(serviceInterface);
    MutablePicoContainer picoContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
    picoContainer.unregisterComponent(serviceInterface.getName());
    picoContainer.registerComponentInstance(serviceInterface.getName(), mock);
    return mock;
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project google-cloud-intellij by GoogleCloudPlatform.

the class RepositorySelectorTest method setUp.

@Before
public void setUp() throws Exception {
    MutablePicoContainer applicationContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
    repositoryService = mock(CloudRepositoryService.class);
    applicationContainer.unregisterComponent(CloudRepositoryService.class.getName());
    applicationContainer.registerComponentInstance(CloudRepositoryService.class.getName(), repositoryService);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) Before(org.junit.Before)

Example 33 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project idea-handlebars by dmarcotte.

the class HbParserTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final MutablePicoContainer appContainer = getApplication().getPicoContainer();
    appContainer.registerComponentInstance(PropertiesComponent.class.getName(), new PropertiesComponentStub());
    appContainer.registerComponentInstance(TemplateDataLanguageMappings.class.getName(), new TemplateDataLanguageMappings(getProject()));
    appContainer.registerComponentInstance(TemplateDataLanguagePatterns.class.getName(), new TemplateDataLanguagePatterns());
    addExplicitExtension(LanguageParserDefinitions.INSTANCE, HbLanguage.INSTANCE, new HbParseDefinition());
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) TemplateDataLanguagePatterns(com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns) PropertiesComponentStub(com.dmarcotte.handlebars.config.PropertiesComponentStub) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) TemplateDataLanguageMappings(com.intellij.psi.templateLanguages.TemplateDataLanguageMappings)

Example 34 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project jbehave-core by jbehave.

the class PicoStepsFactoryBehaviour method assertThatStepsCanBeCreated.

@Test
public void assertThatStepsCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
    // Given
    MutablePicoContainer parent = createPicoContainer();
    parent.as(Characteristics.USE_NAMES).addComponent(FooSteps.class);
    PicoStepsFactory factory = new PicoStepsFactory(new MostUsefulConfiguration(), parent);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(steps);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Example 35 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project intellij by bazelbuild.

the class ProjectViewUi method setDummyWorkspacePathResolverProvider.

private void setDummyWorkspacePathResolverProvider(WorkspacePathResolver workspacePathResolver) {
    MutablePicoContainer container = (MutablePicoContainer) getProject().getPicoContainer();
    Class<WorkspacePathResolverProvider> key = WorkspacePathResolverProvider.class;
    Object oldProvider = container.getComponentInstance(key);
    container.unregisterComponent(key.getName());
    container.registerComponentInstance(key.getName(), (WorkspacePathResolverProvider) () -> workspacePathResolver);
    if (!settingsInitialized) {
        Disposer.register(parentDisposable, () -> {
            container.unregisterComponent(key.getName());
            if (oldProvider != null) {
                container.registerComponentInstance(key.getName(), oldProvider);
            }
        });
    }
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) WorkspacePathResolverProvider(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverProvider)

Aggregations

MutablePicoContainer (org.picocontainer.MutablePicoContainer)35 Test (org.junit.Test)6 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)3 NotNull (org.jetbrains.annotations.NotNull)3 CloudSdkInternals (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkInternals)2 CloudSdkService (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 TemplateDataLanguageMappings (com.intellij.psi.templateLanguages.TemplateDataLanguageMappings)2 TemplateDataLanguagePatterns (com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns)2 CandidateSteps (org.jbehave.core.steps.CandidateSteps)2 Before (org.junit.Before)2 DefaultPicoContainer (org.picocontainer.defaults.DefaultPicoContainer)2 PropertiesComponentStub (com.dmarcotte.handlebars.config.PropertiesComponentStub)1 AppEngineStandardMavenLibrary (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary)1 AppEngineSupportConfigurable (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardSupportProvider.AppEngineSupportConfigurable)1 MavenRepositoryLibraryDownloader (com.google.cloud.tools.intellij.appengine.facet.standard.MavenRepositoryLibraryDownloader)1 AppEngineAssetProvider (com.google.cloud.tools.intellij.appengine.project.AppEngineAssetProvider)1 CloudSdkServiceManager (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager)1 WorkspacePathResolverProvider (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverProvider)1 CoreASTFactory (com.intellij.core.CoreASTFactory)1