use of org.xwiki.resource.internal.entity.EntityResourceActionLister in project xwiki-platform by xwiki.
the class XWikiServletURLFactoryTest method beforeComponent.
@BeforeComponent
public void beforeComponent() throws Exception {
EntityResourceActionLister actionLister = this.oldcore.getMocker().registerMockComponent(EntityResourceActionLister.class);
when(actionLister.listActions()).thenReturn(Arrays.asList("view"));
}
use of org.xwiki.resource.internal.entity.EntityResourceActionLister in project xwiki-platform by xwiki.
the class StandardExtendedURLResourceTypeResolver method registerEntityResourceReferenceResolver.
private void registerEntityResourceReferenceResolver(String registrationHint, Class<? extends ResourceReferenceResolver<ExtendedURL>> registrationImplementation, String wikiExtractorHint) throws InitializationException {
DefaultComponentDescriptor<ResourceReferenceResolver<ExtendedURL>> resolverDescriptor = new DefaultComponentDescriptor<>();
resolverDescriptor.setImplementation(registrationImplementation);
resolverDescriptor.setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
String hint = computeHint(registrationHint);
resolverDescriptor.setRoleHint(hint);
resolverDescriptor.setRoleType(new DefaultParameterizedType(null, ResourceReferenceResolver.class, ExtendedURL.class));
// Register dependencies
DefaultComponentDependency<WikiReferenceExtractor> wikiReferenceExtractorDependency = new DefaultComponentDependency<>();
wikiReferenceExtractorDependency.setRoleType(WikiReferenceExtractor.class);
wikiReferenceExtractorDependency.setRoleHint(wikiExtractorHint);
wikiReferenceExtractorDependency.setName("wikiExtractor");
resolverDescriptor.addComponentDependency(wikiReferenceExtractorDependency);
DefaultComponentDependency<EntityReferenceResolver<EntityReference>> entityReferenceResolverDependency = new DefaultComponentDependency<>();
entityReferenceResolverDependency.setRoleType(new DefaultParameterizedType(null, EntityReferenceResolver.class, EntityReference.class));
entityReferenceResolverDependency.setName("defaultReferenceEntityReferenceResolver");
resolverDescriptor.addComponentDependency(entityReferenceResolverDependency);
DefaultComponentDependency<StandardURLConfiguration> standardURLConfigurationDependency = new DefaultComponentDependency<>();
standardURLConfigurationDependency.setRoleType(StandardURLConfiguration.class);
standardURLConfigurationDependency.setName("configuration");
resolverDescriptor.addComponentDependency(standardURLConfigurationDependency);
DefaultComponentDependency<EntityResourceActionLister> entityResourceActionListerDependency = new DefaultComponentDependency<>();
entityResourceActionListerDependency.setRoleType(EntityResourceActionLister.class);
entityResourceActionListerDependency.setName("entityResourceActionLister");
resolverDescriptor.addComponentDependency(entityResourceActionListerDependency);
try {
this.rootComponentManager.registerComponent(resolverDescriptor);
} catch (ComponentRepositoryException e) {
throw new InitializationException(String.format("Failed to dynamically register Resource Reference Resolver for hint [%s]", hint), e);
}
}
use of org.xwiki.resource.internal.entity.EntityResourceActionLister in project xwiki-platform by xwiki.
the class IntegrationTest method setUpComponents.
@BeforeComponent
public void setUpComponents() throws Exception {
// Isolate from xwiki configuration file
URLConfiguration urlConfiguration = this.componentManager.registerMockComponent(URLConfiguration.class);
when(urlConfiguration.getURLFormatId()).thenReturn("standard");
// Isolate from xwiki configuration file
StandardURLConfiguration standardURLConfiguration = this.componentManager.registerMockComponent(StandardURLConfiguration.class);
when(standardURLConfiguration.getEntityPathPrefix()).thenReturn("bin");
when(standardURLConfiguration.getWikiPathPrefix()).thenReturn("wiki");
when(standardURLConfiguration.isViewActionHidden()).thenReturn(false);
// Isolate from xwiki configuration file
ModelConfiguration modelConfiguration = this.componentManager.registerMockComponent(ModelConfiguration.class);
when(modelConfiguration.getDefaultReferenceValue(EntityType.WIKI)).thenReturn("xwiki");
// Isolate from xwiki's model
WikiDescriptorManager wikiDescriptorManager = this.componentManager.registerMockComponent(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("xwiki");
// Isolate from Environment
EntityResourceActionLister actionLister = this.componentManager.registerMockComponent(EntityResourceActionLister.class);
when(actionLister.listActions()).thenReturn(Arrays.asList("view"));
// Simulate a configured Execution Context
Execution execution = this.componentManager.registerMockComponent(Execution.class);
when(execution.getContext()).thenReturn(new ExecutionContext());
// For test simplicity consider that Context CM == CM
this.componentManager.registerComponent(ComponentManager.class, "context", this.componentManager);
}
Aggregations