use of org.xwiki.model.reference.ClassPropertyReference in project xwiki-platform by xwiki.
the class DBListClassPropertyValuesProviderTest method getValuesMixedWithoutUsed.
@Test
public void getValuesMixedWithoutUsed() throws Exception {
ClassPropertyReference propertyReference = new ClassPropertyReference("category", this.classReference);
DocumentReference authorReference = this.dbListClass.getOwnerDocument().getAuthorReference();
PropertyValues values = new PropertyValues();
values.getPropertyValues().add(new PropertyValue());
when(this.authorExecutor.call(any(), eq(authorReference))).thenReturn(values);
assertSame(values, this.mocker.getComponentUnderTest().getValues(propertyReference, 1, "foo"));
assertEquals(1, values.getPropertyValues().size());
verify(this.usedValuesQueryBuilder, never()).build(any());
}
use of org.xwiki.model.reference.ClassPropertyReference in project xwiki-platform by xwiki.
the class DBListClassPropertyValuesProviderTest method configure.
@Before
public void configure() throws Exception {
super.configure();
addProperty("category", this.dbListClass, true);
addProperty("date", new DateClass(), false);
when(this.xcontext.getWiki().getDocument(new ClassPropertyReference("status", this.classReference), this.xcontext)).thenReturn(this.classDocument);
this.entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
this.authorExecutor = this.mocker.getInstance(AuthorExecutor.class);
DefaultParameterizedType listQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, ListClass.class);
}
use of org.xwiki.model.reference.ClassPropertyReference in project xwiki-platform by xwiki.
the class DefaultClassPropertyValuesProviderTest method getValuesWithMissingProvider.
@Test
public void getValuesWithMissingProvider() throws Exception {
ClassPropertyReference propertyReference = new ClassPropertyReference("category", this.classReference);
ComponentManager contextComponentManager = this.mocker.getInstance(ComponentManager.class, "context");
when(contextComponentManager.getInstance(ClassPropertyValuesProvider.class, "DBList")).thenThrow(new ComponentLookupException("Component not found."));
try {
this.mocker.getComponentUnderTest().getValues(propertyReference, 13, "one");
fail();
} catch (XWikiRestException expected) {
assertEquals("There's no value provider registered for the [DBList] property type.", expected.getMessage());
}
}
use of org.xwiki.model.reference.ClassPropertyReference in project xwiki-platform by xwiki.
the class ClassPropertyValuesResourceImpl method getClassPropertyValues.
@Override
public PropertyValues getClassPropertyValues(String wikiName, String className, String propertyName, Integer limit, List<String> filterParameters) throws XWikiRestException {
DocumentReference classReference = this.resolver.resolve(className, new WikiReference(wikiName));
ClassPropertyReference classPropertyReference = new ClassPropertyReference(propertyName, classReference);
if (!this.authorization.hasAccess(Right.VIEW, classPropertyReference)) {
throw new WebApplicationException(Status.UNAUTHORIZED);
}
if (!exists(classPropertyReference)) {
throw new WebApplicationException(Status.NOT_FOUND);
}
URI propertyURI = Utils.createURI(this.uriInfo.getBaseUri(), ClassPropertyResource.class, wikiName, className, propertyName);
Link propertyLink = this.objectFactory.createLink();
propertyLink.setHref(propertyURI.toString());
propertyLink.setRel(Relations.PROPERTY);
PropertyValues propertyValues = this.propertyValuesProvider.getValues(classPropertyReference, limit, filterParameters.toArray());
propertyValues.getLinks().add(propertyLink);
return propertyValues;
}
Aggregations