Search in sources :

Example 11 with ObjectReference

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

the class MessageStreamTest method testPostDirectMessage.

@Test
public void testPostDirectMessage() throws Exception {
    Event postedMessage = setupForDirectMessage();
    this.stream.postDirectMessageToUser("Hello World!", this.targetUser);
    Assert.assertEquals("Hello World!", postedMessage.getBody());
    Assert.assertEquals(Importance.CRITICAL, postedMessage.getImportance());
    Assert.assertEquals("directMessage", postedMessage.getType());
    Assert.assertEquals("wiki:XWiki.JaneBuck", postedMessage.getStream());
    Assert.assertEquals(new ObjectReference("XWiki.XWikiUsers", this.targetUser), postedMessage.getRelatedEntity());
}
Also used : ObjectReference(org.xwiki.model.reference.ObjectReference) Event(org.xwiki.eventstream.Event) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) Test(org.junit.Test)

Example 12 with ObjectReference

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

the class DocumentUnifiedDiffBuilder method addObjectDiff.

private void addObjectDiff(BaseObject previousObject, BaseObject nextObject, DocumentUnifiedDiff documentDiff) {
    ObjectReference previousReference = getObjectVersionReference(previousObject, documentDiff.getPreviousReference());
    ObjectReference nextReference = getObjectVersionReference(nextObject, documentDiff.getNextReference());
    EntityUnifiedDiff<ObjectReference> objectDiff = new EntityUnifiedDiff<>(previousReference, nextReference);
    addObjectDiff(previousObject == null ? new BaseObject() : previousObject, nextObject == null ? new BaseObject() : nextObject, objectDiff);
    if (objectDiff.size() > 0) {
        documentDiff.getObjectDiffs().add(objectDiff);
    }
}
Also used : EntityUnifiedDiff(org.xwiki.extension.xar.job.diff.EntityUnifiedDiff) BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) ObjectReference(org.xwiki.model.reference.ObjectReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 13 with ObjectReference

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

the class CurrentMixedReferenceEntityReferenceResolverTest method testResolveDocumentFromObjectReference.

@Test
public void testResolveDocumentFromObjectReference() {
    DocumentReference documentReference = new DocumentReference("wiki", "space", "page");
    ObjectReference objectReference = new ObjectReference("object", documentReference);
    EntityReference reference = this.resolver.resolve(objectReference, EntityType.DOCUMENT);
    Assert.assertEquals(documentReference, reference);
}
Also used : ObjectReference(org.xwiki.model.reference.ObjectReference) EntityReference(org.xwiki.model.reference.EntityReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 14 with ObjectReference

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

the class TestUtils method setWikiPreference.

/**
 * Sets the value of an existing property of XWiki.XWikiPreferences.
 *
 * @param propertyName name of the property to set
 * @param value value to set to the property
 * @since 9.7RC1
 */
public void setWikiPreference(String propertyName, String value) throws Exception {
    DocumentReference documentReference = new DocumentReference(getCurrentWiki(), "XWiki", "XWikiPreferences");
    ObjectReference objectReference = new ObjectReference("XWiki.XWikiPreferences[0]", documentReference);
    Property property = RestTestUtils.property(propertyName, value);
    org.xwiki.rest.model.jaxb.Object preferenceObject = rest().get(objectReference, false);
    if (preferenceObject == null) {
        // The object does not exist, create it
        preferenceObject = RestTestUtils.object("XWiki.XWikiPreferences");
        preferenceObject.withProperties(property);
        TestUtils.assertStatusCodes(rest().executePost(ObjectsResource.class, preferenceObject, rest().toElements(documentReference)), true, STATUS_CREATED);
    } else {
        // The object exist just set the property (faster than updating the whole object)
        ObjectPropertyReference propertyReference = new ObjectPropertyReference(propertyName, objectReference);
        TestUtils.assertStatusCodes(rest().executePut(ObjectPropertyResource.class, property, rest().toElements(propertyReference)), true, STATUS_ACCEPTED);
    }
}
Also used : ObjectsResource(org.xwiki.rest.resources.objects.ObjectsResource) ObjectPropertyReference(org.xwiki.model.reference.ObjectPropertyReference) ObjectReference(org.xwiki.model.reference.ObjectReference) Property(org.xwiki.rest.model.jaxb.Property) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentReference(org.xwiki.model.reference.DocumentReference) ObjectPropertyResource(org.xwiki.rest.resources.objects.ObjectPropertyResource)

Example 15 with ObjectReference

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

the class WikiUIExtensionComponentBuilderTest method createExtensionObject.

private BaseObject createExtensionObject(String id, String extensionPointId, String content, String parameters, String scope) {
    BaseObject extensionObject = mock(BaseObject.class, id);
    when(extensionObject.getStringValue(ID_PROPERTY)).thenReturn(id);
    when(extensionObject.getStringValue(EXTENSION_POINT_ID_PROPERTY)).thenReturn(extensionPointId);
    when(extensionObject.getStringValue(CONTENT_PROPERTY)).thenReturn(content);
    when(extensionObject.getStringValue(PARAMETERS_PROPERTY)).thenReturn(parameters);
    when(extensionObject.getStringValue(SCOPE_PROPERTY)).thenReturn(scope);
    BaseObjectReference objectReference = new BaseObjectReference(new ObjectReference("XWiki.UIExtensionClass[0]", DOC_REF));
    when(extensionObject.getReference()).thenReturn(objectReference);
    when(extensionObject.getOwnerDocument()).thenReturn(this.componentDoc);
    return extensionObject;
}
Also used : BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) ObjectReference(org.xwiki.model.reference.ObjectReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

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