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());
}
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);
}
}
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);
}
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);
}
}
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;
}
Aggregations