Search in sources :

Example 1 with EntityReferenceProvider

use of org.xwiki.model.reference.EntityReferenceProvider in project xwiki-platform by xwiki.

the class RefactoringScriptServiceTest method configure.

@Before
public void configure() throws Exception {
    this.jobExecutor = this.mocker.getInstance(JobExecutor.class);
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(executionContext);
    DocumentAccessBridge documentAccessBridge = this.mocker.getInstance(DocumentAccessBridge.class);
    when(documentAccessBridge.getCurrentUserReference()).thenReturn(this.userReference);
    EntityReferenceProvider defaultEntityReferenceProvider = this.mocker.getInstance(EntityReferenceProvider.class);
    when(defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(new EntityReference("WebHome", EntityType.DOCUMENT, null));
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) Execution(org.xwiki.context.Execution) JobExecutor(org.xwiki.job.JobExecutor) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) EntityReference(org.xwiki.model.reference.EntityReference) Before(org.junit.Before)

Example 2 with EntityReferenceProvider

use of org.xwiki.model.reference.EntityReferenceProvider in project xwiki-platform by xwiki.

the class EntityJobTest method initialize.

private void initialize(NoopEntityJob job, EntityRequest request) {
    ReflectionUtils.setFieldValue(job, "jobContext", mock(JobContext.class));
    ReflectionUtils.setFieldValue(job, "progressManager", mock(JobProgressManager.class));
    ReflectionUtils.setFieldValue(job, "authorization", this.authorization);
    ReflectionUtils.setFieldValue(job, "modelBridge", this.modelBridge);
    EntityReferenceProvider defaultEntityReferenceProvider = mock(EntityReferenceProvider.class);
    ReflectionUtils.setFieldValue(job, "defaultEntityReferenceProvider", defaultEntityReferenceProvider);
    when(defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(new EntityReference("WebHome", EntityType.DOCUMENT, null));
    job.initialize(request);
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) EntityReference(org.xwiki.model.reference.EntityReference) JobContext(org.xwiki.job.JobContext) JobProgressManager(org.xwiki.job.event.status.JobProgressManager)

Example 3 with EntityReferenceProvider

use of org.xwiki.model.reference.EntityReferenceProvider in project xwiki-platform by xwiki.

the class DefaultStringEntityReferenceResolverTest method setUp.

@Before
public void setUp() throws Exception {
    this.resolver = this.mocker.getComponentUnderTest();
    EntityReferenceProvider referenceProvider = mock(EntityReferenceProvider.class);
    ReflectionUtils.setFieldValue(this.resolver, "provider", referenceProvider);
    when(referenceProvider.getDefaultReference(EntityType.WIKI)).thenReturn(DEFAULT_WIKI_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.SPACE)).thenReturn(DEFAULT_SPACE_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(DEFAULT_PAGE_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.ATTACHMENT)).thenReturn(DEFAULT_ATTACHMENT_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.OBJECT)).thenReturn(DEFAULT_OBJECT_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.OBJECT_PROPERTY)).thenReturn(DEFAULT_OBJECT_PROPERTY_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.CLASS_PROPERTY)).thenReturn(DEFAULT_CLASS_PROPERTY_REFERENCE);
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) Before(org.junit.Before)

Example 4 with EntityReferenceProvider

use of org.xwiki.model.reference.EntityReferenceProvider in project xwiki-platform by xwiki.

the class DefaultStringEntityReferenceSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    this.serializer = this.mocker.getComponentUnderTest();
    this.resolver = this.resolverMocker.getComponentUnderTest();
    EntityReferenceProvider referenceProvider = this.resolverMocker.getInstance(EntityReferenceProvider.class);
    when(referenceProvider.getDefaultReference(EntityType.WIKI)).thenReturn(DEFAULT_WIKI_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.SPACE)).thenReturn(DEFAULT_SPACE_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(DEFAULT_PAGE_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.ATTACHMENT)).thenReturn(DEFAULT_ATTACHMENT_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.OBJECT)).thenReturn(DEFAULT_OBJECT_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.OBJECT_PROPERTY)).thenReturn(DEFAULT_OBJECT_PROPERTY_REFERENCE);
    when(referenceProvider.getDefaultReference(EntityType.CLASS_PROPERTY)).thenReturn(DEFAULT_CLASS_PROPERTY_REFERENCE);
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) Before(org.junit.Before)

Example 5 with EntityReferenceProvider

use of org.xwiki.model.reference.EntityReferenceProvider in project xwiki-platform by xwiki.

the class UserAndGroupDocumentReferenceResolverTest method afterComponent.

@AfterComponent
public void afterComponent() throws Exception {
    EntityReferenceProvider provider = this.mocker.registerMockComponent(EntityReferenceProvider.class);
    when(provider.getDefaultReference(EntityType.WIKI)).thenReturn(new WikiReference("defaultwiki"));
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) WikiReference(org.xwiki.model.reference.WikiReference) AfterComponent(org.xwiki.test.annotation.AfterComponent)

Aggregations

EntityReferenceProvider (org.xwiki.model.reference.EntityReferenceProvider)16 Before (org.junit.Before)10 EntityReference (org.xwiki.model.reference.EntityReference)7 XWikiContext (com.xpn.xwiki.XWikiContext)4 DocumentReference (org.xwiki.model.reference.DocumentReference)4 WikiReference (org.xwiki.model.reference.WikiReference)4 XWiki (com.xpn.xwiki.XWiki)3 Test (org.junit.Test)3 BinaryStringEncoder (org.xwiki.crypto.BinaryStringEncoder)3 StringReader (java.io.StringReader)2 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)2 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)2 SpaceReference (org.xwiki.model.reference.SpaceReference)2 Query (org.xwiki.query.Query)2 QueryManager (org.xwiki.query.QueryManager)2 WordBlock (org.xwiki.rendering.block.WordBlock)2 XDOM (org.xwiki.rendering.block.XDOM)2 Parser (org.xwiki.rendering.parser.Parser)2 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)2 AfterComponent (org.xwiki.test.annotation.AfterComponent)2