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;
}
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);
}
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());
}
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);
}
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);
}
});
}
}
Aggregations