use of org.xwiki.model.ModelConfiguration in project xwiki-platform by xwiki.
the class DefaultEntityReferenceProviderTest method setUp.
@Before
public void setUp() {
this.provider = new DefaultEntityReferenceProvider();
final ModelConfiguration mockConfiguration = this.mockery.mock(ModelConfiguration.class);
ReflectionUtils.setFieldValue(this.provider, "configuration", mockConfiguration);
this.mockery.checking(new Expectations() {
{
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.SPACE);
will(returnValue(DEFAULT_SPACE));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.WIKI);
will(returnValue(DEFAULT_WIKI));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.DOCUMENT);
will(returnValue(DEFAULT_PAGE));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.ATTACHMENT);
will(returnValue(DEFAULT_ATTACHMENT));
}
});
}
use of org.xwiki.model.ModelConfiguration 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);
}
use of org.xwiki.model.ModelConfiguration in project xwiki-platform by xwiki.
the class DefaultEntityReferenceValueProviderTest method setUp.
@Before
public void setUp() {
this.provider = new DefaultEntityReferenceValueProvider();
final ModelConfiguration mockConfiguration = this.mockery.mock(ModelConfiguration.class);
ReflectionUtils.setFieldValue(this.provider, "configuration", mockConfiguration);
this.mockery.checking(new Expectations() {
{
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.SPACE);
will(returnValue("defspace"));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.WIKI);
will(returnValue("defwiki"));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.DOCUMENT);
will(returnValue("defpage"));
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.ATTACHMENT);
will(returnValue("deffilename"));
}
});
}
Aggregations