use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class EntityReferenceConverterTest method convertSpaceFromString.
@Test
public void convertSpaceFromString() {
EntityReference reference;
reference = new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI));
assertEquals(reference, this.converterManager.convert(EntityReference.class, "space:wiki:space"));
reference = new EntityReference("space", EntityType.SPACE);
assertEquals(reference, this.converterManager.convert(EntityReference.class, "space:space"));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class ModelScriptServiceTest method createDocumentReferenceWhenWikiAndSpaceParametersEmpty.
@Test
public void createDocumentReferenceWhenWikiAndSpaceParametersEmpty() throws Exception {
when(this.componentManager.getInstance(DocumentReferenceResolver.TYPE_REFERENCE, "default")).thenReturn(this.resolver);
DocumentReference reference = new DocumentReference("wiki", "defaultspace", "defaultpage");
when(this.resolver.resolve(new EntityReference("wiki", EntityType.WIKI))).thenReturn(reference);
Assert.assertEquals(reference, this.service.createDocumentReference("wiki", "", "", "default"));
Assert.assertEquals(reference, this.service.createDocumentReference("wiki", Collections.<String>emptyList(), "", "default"));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class ModelScriptServiceTest method createDocumentReferenceWhenPageParameterEmpty.
@Test
public void createDocumentReferenceWhenPageParameterEmpty() throws Exception {
when(this.componentManager.getInstance(DocumentReferenceResolver.TYPE_REFERENCE, "default")).thenReturn(this.resolver);
DocumentReference reference = new DocumentReference("wiki", "space", "defaultpage");
when(this.resolver.resolve(new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)))).thenReturn(reference);
Assert.assertEquals(reference, this.service.createDocumentReference("wiki", "space", "", "default"));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class ModelScriptService method createSpaceReference.
/**
* Creates a {@link SpaceReference} from a list of string representing the space name and the name of its parents.
*
* @param spaces the list of the spaces name (eg ["A", "B", "C"])
* @param parent the wiki reference in which the space is located
* @return the reference to the space
* @since 7.2M2
*/
public SpaceReference createSpaceReference(List<String> spaces, WikiReference parent) {
SpaceReference spaceReference = null;
EntityReference parentReference = parent;
for (String space : spaces) {
spaceReference = new SpaceReference(space, parentReference);
parentReference = spaceReference;
}
return spaceReference;
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class RegexEntityReferenceTest method testWithOnlyWiki.
@Test
public void testWithOnlyWiki() {
EntityReference reference = new RegexEntityReference(Pattern.compile(REFERENCETOMATCH.getWikiReference().getName(), Pattern.LITERAL), EntityType.WIKI);
Assert.assertTrue(reference.equals(REFERENCETOMATCH));
}
Aggregations