Search in sources :

Example 6 with ObjectReference

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

the class WikiObjectComponentManagerEventListenerProxyTest method testWithWikiObjectComponentBuilder.

private void testWithWikiObjectComponentBuilder(WikiObjectComponentBuilder buider, BaseObjectReference objectReference, XWikiDocument source) throws Exception {
    BaseObject baseObject = mock(BaseObject.class);
    when(source.getXObject(any(ObjectReference.class))).thenReturn(baseObject);
    this.mocker.getComponentUnderTest().registerObjectComponents(objectReference, baseObject, buider);
}
Also used : BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) ObjectReference(org.xwiki.model.reference.ObjectReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 7 with ObjectReference

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

the class WikiObjectComponentManagerEventListenerProxyTest method testWikiObjectListCollection.

@Test
public void testWikiObjectListCollection() throws Exception {
    WikiObjectComponentBuilder builder1 = mock(WikiObjectComponentBuilder.class);
    WikiObjectComponentBuilder builder2 = mock(WikiObjectComponentBuilder.class);
    ObjectReference builder1Reference = new ObjectReference("builder1", mock(DocumentReference.class));
    ObjectReference builder2Reference = new ObjectReference("builder2", mock(DocumentReference.class));
    when(builder1.getClassReference()).thenReturn(builder1Reference);
    when(builder2.getClassReference()).thenReturn(builder2Reference);
    when(this.componentManager.getInstanceList(WikiObjectComponentBuilder.class)).thenReturn(Arrays.asList(builder1, builder2));
    assertEquals(2, this.mocker.getComponentUnderTest().getWikiObjectsList().size());
}
Also used : BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) ObjectReference(org.xwiki.model.reference.ObjectReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 8 with ObjectReference

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

the class LESSObjectPropertyResourceReferenceTest method serialize.

@Test
public void serialize() throws Exception {
    ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property", new ObjectReference("class", new DocumentReference("wiki", "Space", "Document")));
    LESSObjectPropertyResourceReference lessObjectPropertyResourceReference = new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge);
    // Mock
    when(entityReferenceSerializer.serialize(eq(objectPropertyReference))).thenReturn("objPropertyRef");
    // Test
    assertEquals("LessXObjectProperty[objPropertyRef]", lessObjectPropertyResourceReference.serialize());
}
Also used : ObjectPropertyReference(org.xwiki.model.reference.ObjectPropertyReference) ObjectReference(org.xwiki.model.reference.ObjectReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 9 with ObjectReference

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

the class SolrEntityReferenceResolverTest method resolve.

@Test
public void resolve() throws Exception {
    WikiReference wikiReference = new WikiReference("chess");
    assertReference(wikiReference);
    assertReference(new SpaceReference("Success", new SpaceReference("To", new SpaceReference("Path", wikiReference))));
    DocumentReference documentReference = new DocumentReference("chess", Arrays.asList("Path", "To", "Success"), "WebHome", Locale.FRENCH);
    assertReference(documentReference);
    assertReference(new AttachmentReference("image.png", documentReference));
    ObjectReference objectReference = new ObjectReference("App.Code.PlayerClass[13]", documentReference);
    assertReference(objectReference);
    assertReference(new ObjectPropertyReference("age", objectReference));
}
Also used : AttachmentReference(org.xwiki.model.reference.AttachmentReference) ObjectPropertyReference(org.xwiki.model.reference.ObjectPropertyReference) ObjectReference(org.xwiki.model.reference.ObjectReference) SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 10 with ObjectReference

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

the class DefaultMessageStream method postDirectMessageToUser.

@Override
public void postDirectMessageToUser(String message, DocumentReference user) {
    if (!this.bridge.exists(user)) {
        throw new IllegalArgumentException("Target user does not exist");
    }
    Event e = createMessageEvent(message, "directMessage");
    e.setRelatedEntity(new ObjectReference("XWiki.XWikiUsers", user));
    e.setStream(this.serializer.serialize(user));
    e.setImportance(Importance.CRITICAL);
    this.stream.addEvent(e);
}
Also used : ObjectReference(org.xwiki.model.reference.ObjectReference) Event(org.xwiki.eventstream.Event)

Aggregations

ObjectReference (org.xwiki.model.reference.ObjectReference)18 Test (org.junit.Test)8 DocumentReference (org.xwiki.model.reference.DocumentReference)8 BaseObject (com.xpn.xwiki.objects.BaseObject)6 BaseObjectReference (com.xpn.xwiki.objects.BaseObjectReference)5 ObjectPropertyReference (org.xwiki.model.reference.ObjectPropertyReference)5 Event (org.xwiki.eventstream.Event)4 ArrayList (java.util.ArrayList)2 DefaultEvent (org.xwiki.eventstream.internal.DefaultEvent)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 WikiReference (org.xwiki.model.reference.WikiReference)2 Property (org.xwiki.rest.model.jaxb.Property)2 ObjectPropertyResource (org.xwiki.rest.resources.objects.ObjectPropertyResource)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 HashSet (java.util.HashSet)1 Mock (org.jmock.Mock)1 Invocation (org.jmock.core.Invocation)1 CustomStub (org.jmock.core.stub.CustomStub)1 EntityUnifiedDiff (org.xwiki.extension.xar.job.diff.EntityUnifiedDiff)1