Search in sources :

Example 1 with ModelConfiguration

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));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) ModelConfiguration(org.xwiki.model.ModelConfiguration) Before(org.junit.Before)

Example 2 with ModelConfiguration

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);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) URLConfiguration(org.xwiki.url.URLConfiguration) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ModelConfiguration(org.xwiki.model.ModelConfiguration) EntityResourceActionLister(org.xwiki.resource.internal.entity.EntityResourceActionLister) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 3 with ModelConfiguration

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"));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) ModelConfiguration(org.xwiki.model.ModelConfiguration) Before(org.junit.Before)

Aggregations

ModelConfiguration (org.xwiki.model.ModelConfiguration)3 Expectations (org.jmock.Expectations)2 Before (org.junit.Before)2 Execution (org.xwiki.context.Execution)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 EntityResourceActionLister (org.xwiki.resource.internal.entity.EntityResourceActionLister)1 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)1 URLConfiguration (org.xwiki.url.URLConfiguration)1 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)1